import java.lang.String; import java.util.*; public class Getpar { public static void main(String[] argv) { /* First get all the command-line args into one String */ String str = Getpar.concat(argv); /* Check if String str begins with a comment character */ if (Getpar.isComment(str)) { System.out.println("Command line was commented out."); return; } /* Just define one Getpar object */ Getpar gp; /* Define an int variable and get the last of any "ival=int" parameter-value pairs from the String */ int ival = 1; /* set default value */ /* Construct the Getpar object with the default value */ gp = new Getpar(ival); /* Redefine ival only if an interpretable value is in String str */ if (gp.getIntPar(str, "ival")) { ival = gp.getInt(); System.out.println("ival=" + ival); } /* Define a float variable and get the last of any "fval=float" parameter-value pairs from the String */ float fval = 2F; /* set default value */ /* Construct the Getpar object with the default value */ gp = new Getpar(fval); /* Redefine fval only if an interpretable value is in String str */ if (gp.getFloatPar(str, "fval")) { fval = gp.getFloat(); System.out.println("fval=" + fval); } /* Define a double variable and get the last of any "dval=double" parameter-value pairs from the String */ double dval = 3; /* set default value */ /* Construct the Getpar object with the default value */ gp = new Getpar(dval); /* Redefine dval only if an interpretable value is in String str */ if (gp.getDoublePar(str, "dval")) { dval = gp.getDouble(); System.out.println("dval=" + dval); } /* Define a String variable and get the last of any "sval=String" parameter-value pairs from the String */ String sval = "default"; /* set default value */ /* Construct the Getpar object with the default value */ gp = new Getpar(sval); /* Redefine sval only if an interpretable value is in String str */ if (gp.getStringPar(str, "sval")) { sval = gp.getString(); System.out.println("sval=" + sval); } } /* class Getpar data block */ int ival; float fval; double dval; String sval; /* Constructors */ Getpar() { init(); } Getpar(int ival) { init(); this.ival = ival; } Getpar(float fval) { init(); this.fval = fval; } Getpar(double dval) { init(); this.dval = dval; } Getpar(String sval) { init(); this.sval = new String(sval); } /* Methods */ void init() { ival = -1; fval = 0F; dval = 0; sval = ""; } int getInt() { return ival; } float getFloat() { return fval; } double getDouble() { return dval; } String getString() { return sval; } static boolean isComment(String s) { StringTokenizer st = new StringTokenizer(s); String tok; if (st.hasMoreTokens()) { tok = st.nextToken(); if (tok.startsWith("!") || tok.startsWith("@") || tok.startsWith("#") || tok.startsWith("%") || tok.startsWith("&") || tok.startsWith("*") || tok.startsWith("/")) return true; } return false; } /* Is the first word in the string the one given? */ static boolean isType(String s, String type) { if (Getpar.isComment(s)) return false; StringTokenizer st = new StringTokenizer(s); String tok; if (st.hasMoreTokens()) { tok = st.nextToken(); if (tok.equals(type)) return true; } return false; } static String findLastLine(Vector input, String type) { int nlines=0; String line, tline=null; for (int i=0; i