FileOutputStream fos = new FileOutputStream(new File(targetdir,outname));
FileOutputStream fos = new FileOutputStream(new File(getTargetDir(),outname));
    public void writeFactory () throws IOException {      String outname = "PropertyGroupFactory.java";      if (cleanp) {        (new File(outname)).delete();        return;      }      debug("Writing FactoryImplementation to \""+outname+"\"");      noteFile(outname);      FileOutputStream fos = new FileOutputStream(new File(targetdir,outname));      OutputStreamWriter osw = new OutputStreamWriter(fos);      PrintWriter out = new PrintWriter(osw);      writeCR(out);            out.println("/** AbstractFactory implementation for Properties.");      out.println(" * Prevents clients from needing to know the implementation");      out.println(" * class(es) of any of the properties.");      out.println(" **/");      out.println();      doPackaging(out,"global");      out.println();      String xclause = "";      String exts = p.get("global", "factoryExtends");      if (exts != null) {        xclause = "extends "+exts+" ";      }      out.println("public class PropertyGroupFactory "+xclause+"{");      Enumeration contexts = p.getContexts();      while ( contexts.hasMoreElements()) {        String context = (String) contexts.nextElement();        if (! context.equals("global") &&             (p.get(context, "abstract") == null)) {          String newclassName = "New"+context;          String icn = context+"Impl";          out.println("  // brand-new instance factory");          out.println("  public static "+newclassName+" new"+context+"() {");          out.println("    return new "+icn+"();");          out.println("  }");                    boolean timephased = (p.get(context, PGParser.TIMEPHASED) != null);          if (timephased) {            out.println("  // brand-new instance factory");            out.println("  public static PropertyGroupSchedule new"+context+                        "Schedule() {");            out.println("    return new PropertyGroupSchedule(new"+context+"());");            out.println("  }");          }          out.println("  // instance from prototype factory");          out.println("  public static "+newclassName+" new"+context+"("+context+" prototype) {");          out.println("    return new "+icn+"(prototype);");          out.println("  }");          out.println();          if (timephased) {            out.println("  // instance from prototype factory");            out.println("  public static PropertyGroupSchedule new"+context+                        "Schedule("+context+" prototype) {");            out.println("    return new PropertyGroupSchedule(new"+context+"(prototype));");            out.println("  }");          }        }      }      out.println("  /** Abstract introspection information.");      out.println("   * Tuples are {<classname>, <factorymethodname>}");      out.println("   * return value of <factorymethodname> is <classname>.");      out.println("   * <factorymethodname> takes zero or one (prototype) argument.");      out.println("   **/");      out.println("  public static String properties[][]={");      contexts = p.getContexts();      while ( contexts.hasMoreElements()) {        String context = (String) contexts.nextElement();        if (! context.equals("global") &&             (p.get(context, "abstract") == null)) {          String newclassName = "New"+context;          String pkg = findPackage(context);          out.print("    {\""+pkg+"."+context+"\", \"new"+context+"\"}");          if (p.get(context, PGParser.TIMEPHASED) != null) {            out.print(",");            out.println();            out.print("    {\""+pkg+".PropertyGroupSchedule\", \"new"+context+"Schedule\"}");          }          if (contexts.hasMoreElements())            out.print(",");          out.println();        }      }      out.println("  };");            out.println("}");      out.close();    }