out.println(",");
println(out,",");
    void writeClass(PrintWriter out, String context, String className) {      String isDep = p.get(context,"deprecated");      if (isDep!=null) {        out.println("/** @deprecated "+isDep+" **/");      }      String ext = p.get(context,"extends");      if (ext == null) ext = "AbstractMeasure";      boolean isFinal = !("false".equals(p.get(context,"final")));      out.println("public "+                  (isFinal?"final ":"")+                  "class "+className+" extends "+ext+" implements Externalizable {");      // get units      Vector units = getUnitV(context);      String base = getBaseUnit(context);      String baseabbrev = p.get(context, "baseabbrev");      if (baseabbrev == null) baseabbrev=base;      String baseC = toConstantName(base);            // write static factors      out.println("  // Conversion factor constants");      Enumeration ue = units.elements();      while (ue.hasMoreElements()) {        String unit = (String)ue.nextElement();        if (! unit.equals(base)) {          // f is the factor of (1 unit) = f * (1 baseunit);          String fact1 = toConstantName(base+"_PER_"+unit);          double fromf = computeFromFactor(context,unit);          out.println("  public static final double "+fact1+" = "+fromf+";");          String fact2 = toConstantName(unit+"_PER_"+base);          double tof = computeToFactor(context,unit);          out.println("  public static final double "+fact2+" = "+tof+";");        }      }      out.println();      // the storage      out.println("  // the value is stored as "+base);      out.println("  private double theValue;");      out.println();      out.println("  /** No-arg constructor is only for use by serialization **/");      out.println("  public "+className+"() {}");      out.println();      // constructor      out.println("  // private constructor");      out.println("  private "+className+"(double v) {");      out.println("    theValue = v;");      out.println("  }");      out.println();      // public constructor      out.println("  /** parameterized constructor **/");      out.println("  public "+className+"(double v, int unit) {");      out.println("    if (unit >= 0 && unit <= MAXUNIT)");      out.println("      theValue = v*convFactor[unit];");      out.println("    else");      out.println("      throw new UnknownUnitException();");      out.println("  }");      out.println();      out.println("  /** takes strings of the form \"Number unit\" **/");      out.println("  public "+className+"(String s) {");      out.println("    int i = indexOfType(s);");      out.println("    if (i < 0) throw new UnknownUnitException();");      out.println("    double n = Double.valueOf(s.substring(0,i).trim()).doubleValue();");      out.println("    String u = s.substring(i).trim().toLowerCase();");      out.print("    ");      ue = units.elements();      while (ue.hasMoreElements()) {        String unit = (String)ue.nextElement();        String unitName = toClassName(unit);        String fexpr="";        if (!unit.equals(base)) {          fexpr = "*"+toConstantName(base+"_PER_"+unit);        }        out.println("if (u.equals(\""+unitName.toLowerCase()+"\")) ");        out.println("      theValue=n"+fexpr+";");        out.print("    else ");      }      out.println("\n      throw new UnknownUnitException();");      out.println("  }");      out.println();      // Named type factory methods      out.println("  // TypeNamed factory methods");      ue = units.elements();      while (ue.hasMoreElements()) {        String unit = (String)ue.nextElement();        String unitName = toClassName(unit);        String fexpr="";        if (!unit.equals(base)) {          fexpr = "*"+toConstantName(base+"_PER_"+unit);        }        out.println("  public static final "+className+" new"+unitName+"(double v) {");        out.println("    return new "+className+"(v"+fexpr+");");        out.println("  }");        out.println("  public static final "+className+" new"+unitName+"(String s) {");        out.println("    return new "+className+"((Double.valueOf(s).doubleValue())"+fexpr+");");        out.println("  }");      }      out.println();      // common unit support - mostly a bogon      out.println();      out.println("  public int getCommonUnit() {");      String cus = p.get(context, "common");      if (cus == null) {         out.println("    return 0;");      } else {                out.println("    return "+cus.toUpperCase()+";");      }      out.println("  }");      out.println();      out.println("  public int getMaxUnit() { return MAXUNIT; }");      out.println();      out.println("  // unit names for getUnitName");      out.println("  private static final String unitNames[]={");      ue = units.elements();      while (ue.hasMoreElements()) {        String unit = (String)ue.nextElement();        out.print("    \""+unit+"\"");        if (ue.hasMoreElements())          out.println(",");        else          out.println();      }      out.println("  };");      out.println();      out.println("  public String getUnitName(int unit) {");      out.println("    return unitNames[unit];");      out.println("  }");      out.println();      // index typed factory methods      out.println("  // Index Typed factory methods");      out.println("  static final double convFactor[]={");      ue = units.elements();      while (ue.hasMoreElements()) {        String unit = (String)ue.nextElement();        String unitName = toClassName(unit);        String fexpr="1.0";        if (!unit.equals(base)) {          fexpr = toConstantName(base+"_PER_"+unit);        }        out.print("    "+fexpr);        if (ue.hasMoreElements())          out.println(",");        else          out.println();      }      out.println("  };");      out.println("  // indexes into factor array");      ue = units.elements();      int i = 0;      while (ue.hasMoreElements()) {        String unit = (String)ue.nextElement();        String unitName = toConstantName(unit);        out.println("  public static final int "+unitName+" = "+i+";");        i++;      }      out.println("  static final int MAXUNIT = "+(i-1)+";");      out.println();      out.println("  // Index Typed factory methods");      out.println("  public static final "+className+" new"+className+"(double v, int unit) {");      out.println("    if (unit >= 0 && unit <= MAXUNIT)");      out.println("      return new "+className+"(v*convFactor[unit]);");      out.println("    else");      out.println("      throw new UnknownUnitException();");      out.println("  }");      out.println();      out.println("  public static final "+className+" new"+className+"(String s, int unit) {");      out.println("    if (unit >= 0 && unit <= MAXUNIT)");      out.println("      return new "+className+"((Double.valueOf(s).doubleValue())*convFactor[unit]);");      out.println("    else");      out.println("      throw new UnknownUnitException();");      out.println("  }");      out.println();      // abstractmeasure-level concretefactory      out.println("  // Support for AbstractMeasure-level constructor");      out.println("  public static final AbstractMeasure newMeasure(String s, int unit) {");      out.println("    return new"+className+"(s, unit);");      out.println("  }");      out.println("  public static final AbstractMeasure newMeasure(double v, int unit) {");      out.println("    return new"+className+"(v, unit);");      out.println("  }");      // getters      out.println("  // Unit-based Reader methods");      ue = units.elements();      while (ue.hasMoreElements()) {        String unit = (String)ue.nextElement();        String unitName = toClassName(unit);        String fexpr="";        if (!unit.equals(base)) {          fexpr = "*"+toConstantName(unit+"_PER_"+base);        }        out.println("  public double get"+unitName+"() {");        out.println("    return (theValue"+fexpr+");");        out.println("  }");      }      out.println();      // unit-as-argument getter      out.println("  public double getValue(int unit) {");      out.println("    if (unit >= 0 && unit <= MAXUNIT)");      out.println("      return (theValue/convFactor[unit]);");      out.println("    else");      out.println("      throw new UnknownUnitException();");      out.println("  }");      out.println();      // equals et al      out.println("  public boolean equals(Object o) {");      out.println("    return ( o instanceof "+className+" &&");      out.println("             theValue == (("+className+") o).theValue);");      out.println("  }");      out.println("  public String toString() {");      out.println("    return Double.toString(theValue) + \""+                  baseabbrev+"\";");      out.println("  }");      out.println("  public int hashCode() {");      out.println("    return (new Double(theValue)).hashCode();");      out.println("  }");      out.println();      out.println("  // serialization");      out.println("  public void writeExternal(ObjectOutput out) throws IOException {\n"+                  "    out.writeDouble(theValue);\n"+                  "  }");      out.println("  public void readExternal(ObjectInput in) throws IOException {\n"+                  "    theValue = in.readDouble();\n"+                  "  }");      // that's all, folks      out.println("}");    }