📄 parseacd.java
字号:
while((stop = help.indexOf(' ',55))>0) { helpText = helpText.concat(help.substring(start,stop) + "\n"); help = help.substring(stop+1,help.length()); } helpText = helpText.concat(help); return helpText; } /** * * Determine if there is a optional parameter in a field of the ACD. * @param field field number * @return true if this is an "optional" field. * */ public boolean isOptionalParamValue(int field) { int num = getNumofParams(field); for(int i=0;i<num;i++) { if(getParameterAttribute(field,i).startsWith("opt")) return true; } return false; } /** * * Determine if data type of a field is seqout. * @param field field number * @return true if this is an "seqout" field. * */ public boolean isOutputSequence(int field) { int num = getNumofParams(field); for(int i=0;i<num;i++) { if (getParameterAttribute(field,i).startsWith("seqout")) return true; } return false; } /** * * Gets the name of the output sequence field (seqout). * @param field field number * @return parameter name for the seqout data type. * */ public String getOutputSequenceFile(int field) { int num = getNumofParams(field); for(int i=0;i<num;i++) if (getParameterAttribute(field,i).startsWith("seqout")) return getParamValueStr(field,i); return ""; } /** * * Determine if a field is data type graph or xygraph. * @param field field number * @return true if the field is of "graph" or * "xygraph" type. * */ public boolean isOutputGraph(int field) { int num = getNumofParams(field); for(int i=0;i<num;i++) { if ( getParameterAttribute(field,i).startsWith("graph") || getParameterAttribute(field,i).startsWith("xygraph") ) return true; } return false; } /** * * Determine if a field is data type outfile. * @param field field number * @return true if the field is of "outfile" type. * */ public boolean isOutputFile(int field) { int num = getNumofParams(field); for(int i=0;i<num;i++) { if (getParameterAttribute(field,i).startsWith("outfile")) return true; } return false; } /** * * Gets a String default parameter. * @param field field number * @return default parameter for this field. * */ public String getDefaultParamValueStr(int field) { int num = getNumofParams(field); ApplicationFields aF = (ApplicationFields)vappF.get(field); for(int i=0;i<num;i++) { if (getParameterAttribute(field,i).startsWith("def")) return aF.getParamValueStr(i); } return ""; } /** * * Used for a list data type to put the list items in a String array. * @param field field number * @return String array representation of the list type. * */ public String[] getList(int field) { int num = getNumofParams(field); String delim = ";"; // list item delimeter default String codedelim = ":"; // label delimeter default String listAll = null; String list[]; String item; ApplicationFields aF = (ApplicationFields)vappF.get(field); for(int i=0;i<num;i++) { if (getParameterAttribute(field,i).startsWith("val")) listAll = aF.getParamValueStr(i); if (getParameterAttribute(field,i).startsWith("delim")) delim = aF.getParamValueStr(i); if (getParameterAttribute(field,i).startsWith("codedelim")) codedelim = aF.getParamValueStr(i); } if(delim == null || listAll == null) System.out.println("getList ERROR"); StringTokenizer st = new StringTokenizer(listAll,delim); int n = 0; while (st.hasMoreTokens()) { st.nextToken(delim); n++; } list = new String[n]; st = new StringTokenizer(listAll); n = 0; boolean ldef = false; Vector def = new Vector(); //put the default values into a vector if(isDefaultParamValueStr(field)) { ldef = true; String sdef = getDefaultParamValueStr(field); StringTokenizer stdef = new StringTokenizer(sdef); while(stdef.hasMoreTokens()) def.add(stdef.nextToken(delim)); } listdefault = new Vector(); while (st.hasMoreTokens()) { String key = st.nextToken(codedelim); item = st.nextToken(delim); if(ldef) { int newline = key.indexOf("\n"); if(newline > -1) key = key.substring(newline+1,key.length()); newline = key.indexOf(delim); if(newline > -1) key = key.substring(newline+1,key.length()); key = key.trim(); // check if it is a default value for(int i=0;i<def.size();i++) if(key.equals((String)def.get(i))) listdefault.add(new Integer(n)); } item = item.substring(1,item.length()).trim(); list[n] = new String(item); n++; } return list; } /** * * For a list data type determine the appropriate String entry. * @param field field number * @param index index into the list * @return String for that entry. * */ public String getListLabel(int field, int index) { int num = getNumofParams(field); String delim = ";"; // list item delimeter default String codedelim = ":"; // label delimeter default String listAll = null; String item; String key=""; ApplicationFields aF = (ApplicationFields)vappF.get(field); for(int i=0;i<num;i++) { if (getParameterAttribute(field,i).startsWith("val")) listAll = aF.getParamValueStr(i); if (getParameterAttribute(field,i).startsWith("delim")) delim = aF.getParamValueStr(i); if (getParameterAttribute(field,i).startsWith("codedelim")) codedelim = aF.getParamValueStr(i); } if(delim == null || listAll == null) System.out.println("getList ERROR"); StringTokenizer st = new StringTokenizer(listAll,delim); st = new StringTokenizer(listAll); for(int i=0;i<index+1;i++) { key = st.nextToken(codedelim); item = st.nextToken(delim); } if(index>0) key = key.substring(1,key.length()).trim(); else key = key.substring(0,key.length()).trim(); return key; } /** * * Used for a selection type to put the list items in a String array. * @param field field number * @return String array representation of the select type. * */ public String[] getSelect(int field) { int num = getNumofParams(field); String delim = ";"; // select item delimeter default String listAll = null; String list[]; String item; ApplicationFields aF = (ApplicationFields)vappF.get(field); for(int i=0;i<num;i++) { if (getParameterAttribute(field,i).startsWith("val")) listAll = aF.getParamValueStr(i); if (getParameterAttribute(field,i).startsWith("delim")) delim = aF.getParamValueStr(i); } if(delim == null || listAll == null) System.out.println("getSelect ERROR"); StringTokenizer st = new StringTokenizer(listAll,delim); int n = 0; while (st.hasMoreTokens()) { st.nextToken(delim); n++; } list = new String[n]; boolean ldef = false; Vector def = new Vector(); //put the default values into a vector if(isDefaultParamValueStr(field)) { ldef = true; String sdef = getDefaultParamValueStr(field); StringTokenizer stdef = new StringTokenizer(sdef); while(stdef.hasMoreTokens()) def.add(stdef.nextToken(delim).trim()); } st = new StringTokenizer(listAll); n = 0; listdefault = new Vector(); while (st.hasMoreTokens()) { item = st.nextToken(delim); if(ldef) {// if (item.endsWith(getDefaultParamValueStr(field)))// listdefault.add(new Integer(n)); for(int i=0;i<def.size();i++) if( item.equals((String)def.get(i)) || Integer.toString(n+1).equals((String)def.get(i)) ) listdefault.add(new Integer(n)); } item = item.substring(0,item.length()).trim(); list[n] = new String(item); n++; } return list; } /** * * Use this after getList or getSelect to retrieve default * @return default for list or select data type * */ public Vector getListOrSelectDefault() { return listdefault; } /** * * Determine if there is a optional parameter in any field of the ACD. * @param true if there is an optional parameter in any field. * */ public boolean isOptionalParam() { for(int i=0;i<numofFields;i++) if(isOptionalParamValue(i)) return true; return false; } /** * * Gets the number of fields in the ACD file. * @return total number of fields in an ACD file * */ public int getNumofFields() { return numofFields; } /** * * Gets the number of parameters in a ACD field. * @param field field number * @return number of parameters in the field. * */ public int getNumofParams(int field) { ApplicationFields aF = (ApplicationFields)vappF.get(field); return aF.getNumberOfParam(); } /** * * Parses a parameter in a ACD field * @param in BufferedReader * @param st tokenizer * @return string tokenizer type or zero * */ public int parseParam(BufferedReader in, StreamTokenizer st) throws IOException { char c; svalue = null; st.eolIsSignificant(false); // the following are not token delimeters st.wordChars((int)'-',(int)'-'); st.wordChars((int)'$',(int)'$'); st.wordChars((int)'(',(int)'('); st.wordChars((int)')',(int)')'); st.wordChars((int)'@',(int)'@'); st.wordChars((int)'?',(int)'?'); st.wordChars((int)'!',(int)'!'); st.wordChars((int)'#', (int)'#');// the following are token delimeters st.whitespaceChars((int)'\n',(int)'\n'); st.whitespaceChars((int)' ',(int)' '); st.whitespaceChars((int)':',(int)':'); st.whitespaceChars((int)'=',(int)'='); st.ordinaryChars((int)'\"', (int)'\"'); st.ordinaryChars((int)'\'',(int)'\''); st.nextToken(); attr = st.sval; if(attr == null) return 0;//skip commented lines if(attr.startsWith("#")) { while( (c = (char)in.read()) != '\n') {} st.nextToken(); attr = st.sval; } if(attr == null) return 0; st.nextToken(); svalue = st.sval; nvalue = st.nval; // cope with double quotes by forwarding to end quote // and remove unwanted white space if( svalue == null && st.ttype != java.io.StreamTokenizer.TT_NUMBER ) { svalue = ""; char last = ' '; while( (c = (char)in.read()) != '\"') { if( c != ' ' || last != ' ') svalue = svalue.concat(java.lang.String.valueOf(c)); last = c; } } numofParams++; return st.ttype; } public int getNumMultiTextField() { return nmultiTextField; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -