Package org.dmd.util.formatting

Examples of org.dmd.util.formatting.PrintfFormat$ConversionSpecification


    String eventName   = capped;
    String handlerName   = capped + "Handler";
        BufferedWriter   out = FileUpdateManager.instance().getWriter(outdir, eventName + ".java");
       
    int       padding = longestType+2;
    PrintfFormat   format   = new PrintfFormat("%-" + padding + "s");

    ImportManager.resetStatic();
        ImportManager.addImportStatic("com.google.gwt.event.shared.GwtEvent", "The base event type");
       
        if (event.getImportThisHasValue()){
          for(String imp: event.getImportThisIterable()){
            ImportManager.addImportStatic(imp, "Required type");
          }
        }
       
        out.write("package " + event.getDefinedInModule().getGenPackage() + ".generated.mvw.events;\n\n");
   
        out.write(ImportManager.getFormattedImportsStatic() + "\n");
       
        out.write("// Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
        out.write("public class " + eventName + " extends GwtEvent<" + handlerName + "> {\n\n");
       
        if (types.size() > 0){
          for(int i=0; i<types.size(); i++){
            out.write("    " + format.sprintf(types.get(i)) + " " + members.get(i) + ";\n");
          }
          out.write("\n");
        }
       
        out.write("    public static Type<" + handlerName + "> TYPE = new Type<" + handlerName + ">();\n\n");
View Full Code Here


    parser = new MvwParser(baseWithMVWSchema, configFinder, defManager);
   
    codeGenerator = new MvwGenerator(defManager,System.out);
   
    String f = "%-" + configFinder.getLongestName() + "s";
    format = new PrintfFormat(f);
  }
View Full Code Here

      for(String importStr: uniqueImports.keySet()){
        if (importStr.length() > longest)
          longest = importStr.length();
      }
    int padding = longest+17;
    PrintfFormat format = new PrintfFormat("%-" + padding + "s");
     
        for(String importStr: uniqueImports.keySet()){
        String comment = uniqueImports.get(importStr);
//        sb.append("import " + importStr + "; // " + comment + "\n");
      sb.append(format.sprintf("import " + importStr + ";") + "// " + comment + "\n");
      }
      sb.append("\n");
     
      return(sb.toString());
    }
View Full Code Here

    }
  }

  void dumpMetaSchema(String od) throws IOException, ResultException {
    BufferedWriter out = null;
    PrintfFormat pf = null;

    // out = new BufferedWriter(new FileWriter(od + "/MetaSchemaAG.java"));
    out = FileUpdateManager.instance().getWriter(od, "MetaSchemaAG.java");

    // Strip the nameAttribute from all name types so that we don't cause
    // problems
    // when loading the meta schema
    for (DmcUncheckedObject type : typeDefs.values()) {
      type.rem("nameAttributeDef");
      type.rem("filterAttributeDef");
    }

    out.write(LGPL.toString());
    out.write("package org.dmd.dms;\n\n");

    out.write("import org.dmd.dmc.DmcValueException;\n");
    out.write("import org.dmd.dms.generated.enums.*;\n");

    out.write("\n");

    out.write("/**\n");
    out.write("  * This class creates the basic definitions that allow for the definition of schemas.\n");
    out.write("  * Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
    out.write("  */\n");

    out.write("abstract public class MetaSchemaAG extends SchemaDefinition {\n");

    out.write("    public static SchemaDefinition    _metaSchema;\n\n");

    out.write("    // Generated from: " + DebugInfo.getWhereWeAreNow()
        + "\n");
    for (int i = 0; i < origOrderClasses.size(); i++) {
      out.write("    public static ClassDefinition     _"
          + origOrderClasses.get(i) + ";\n");
    }
    out.write("\n");

    out.write("    // Generated from: " + DebugInfo.getWhereWeAreNow()
        + "\n");
    for (int i = 0; i < origOrderEnums.size(); i++)
      out.write("    public static EnumDefinition      _"
          + origOrderEnums.get(i) + ";\n");
    out.write("\n");

    out.write("    // Generated from: " + DebugInfo.getWhereWeAreNow()
        + "\n");
    for (int i = 0; i < origOrderTypes.size(); i++)
      out.write("    public static TypeDefinition      _"
          + origOrderTypes.get(i) + ";\n");
    out.write("\n");

    out.write("    // Generated from: " + DebugInfo.getWhereWeAreNow()
        + "\n");
    for (int i = 0; i < origOrderAttrs.size(); i++)
      out.write("    public static AttributeDefinition _"
          + origOrderAttrs.get(i) + ";\n");
    out.write("\n");

    out.write("    // Generated from: " + DebugInfo.getWhereWeAreNow()
        + "\n");
    for (int i = 0; i < origOrderCategories.size(); i++)
      out.write("    public static RuleCategory        _"
          + origOrderCategories.get(i) + ";\n");
    out.write("\n");

    out.write("    // Generated from: " + DebugInfo.getWhereWeAreNow()
        + "\n");
    for (int i = 0; i < origOrderRules.size(); i++)
      out.write("    public static RuleDefinition      _"
          + origOrderRules.get(i) + ";\n");
    out.write("\n");

    // METASCHEMA START
    out.write("    public MetaSchemaAG() throws DmcValueException {\n\n");
    // out.write("        super(\"metaSchema\");\n\n");
    // DebugInfo.debug("META SCHEMA NAME CHANGE!!!!");
    out.write("        super(\"meta\");\n\n");
    out.write("        staticRefName = new String(\"MetaSchema._\");\n\n");

    pf = new PrintfFormat("%-28s");

    out.write("        // We only ever want to initialize the schema once, so check\n");
    out.write("        // to see if we've initialized the first class definition\n");

    // START INIT METASCHEMA
    out.write("        if (_metaSchema == null){\n");

    out.write("            try{\n");

    out.write("            _metaSchema = this;\n");

    out.write("            // Create the class definitions\n");
    out.write("            // Generated from: "
        + DebugInfo.getWhereWeAreNow() + "\n");
    for (int i = 0; i < origOrderClasses.size(); i++) {
      String defn = origOrderClasses.get(i);
      out.write("            _" + pf.sprintf(defn));
      out.write("= new ClassDefinition(\"" + defn + "\");\n");
    }
    out.write("\n");

    out.write("            // Create the enum definitions\n");
    out.write("            // Generated from: "
        + DebugInfo.getWhereWeAreNow() + "\n");
    for (int i = 0; i < origOrderEnums.size(); i++) {
      String defn = origOrderEnums.get(i);
      out.write("            _" + pf.sprintf(defn));
      out.write("= new EnumDefinition(\"" + defn + "\");\n");
    }
    out.write("\n");

    out.write("            // Create the type definitions\n");
    out.write("            // Generated from: "
        + DebugInfo.getWhereWeAreNow() + "\n");
    for (int i = 0; i < origOrderTypes.size(); i++) {
      String defn = origOrderTypes.get(i);

      String predefname = origOrderTypes.get(i);
      if (predefname.indexOf("Enum") != -1) {
        if (predefname.equals("EnumValue")
            || predefname.equals("EnumDefinitionREF")) {

        } else
          predefname = predefname.replace("REF", "");
        // predefname = origOrderTypes.get(i) + "REF";
      }

      DmcUncheckedObject typeObj = typeDefs.get(defn);
      String typeClassName = typeObj.getSV("typeClassName");
      String wrapperClassName = typeObj.getSV("wrapperClassName");
      out.write("            _" + pf.sprintf(defn));
      if (wrapperClassName == null)
        out.write("= new TypeDefinition(\"" + predefname + "\", "
            + typeClassName + ".class);\n");
      else
        out.write("= new TypeDefinition(\"" + predefname + "\", "
            + typeClassName + ".class, " + wrapperClassName
            + ".class);\n");
    }
    out.write("\n");

    out.write("            // Create the attribute definitions\n");
    out.write("            // Generated from: "
        + DebugInfo.getWhereWeAreNow() + "\n");
    for (int i = 0; i < origOrderAttrs.size(); i++) {
      String attrName = origOrderAttrs.get(i);
      String mediatorName = null;

      DmcUncheckedObject attrDef = attributeDefs.get(attrName);
      String typeName = attrDef.getSV("type");
      DmcUncheckedObject typeDef = typeDefs.get(typeName);

      // If we couldn't find the type by its name, it's because its a
      // reference
      // to a class or enum, and the actual TypeDefinition name will be
      // _<ClassName>Reference
      if (typeDef == null) {
        mediatorName = typeName + "REF";
      } else {
        mediatorName = typeName;
      }

      out.write("            _" + pf.sprintf(attrName));
      out.write("= new AttributeDefinition(\"" + attrName + "\", _"
          + mediatorName + ");\n");
    }
    out.write("\n");

    out.write("            // Create the rule category definitions\n");
    out.write("            // Generated from: "
        + DebugInfo.getWhereWeAreNow() + "\n");
    for (int i = 0; i < origOrderCategories.size(); i++) {
      String defn = origOrderCategories.get(i);
      out.write("            _" + pf.sprintf(defn));
      out.write("= new RuleCategory(\"" + defn + "\");\n");
    }
    out.write("\n");

    out.write("            // Create the rule definitions\n");
    out.write("            // Generated from: "
        + DebugInfo.getWhereWeAreNow() + "\n");
    for (int i = 0; i < origOrderRules.size(); i++) {
      String defn = origOrderRules.get(i);
      out.write("            _" + pf.sprintf(defn));
      out.write("= new RuleDefinition(\"" + defn + "\");\n");
    }
    out.write("\n");

    // Set the attribute values on all objects
View Full Code Here

   
    Iterator<RunContextItem> it = null;
    String interfaceName = GenUtility.capTheName(module.getModuleName().getNameString());
        BufferedWriter   out = FileUpdateManager.instance().getWriter(outdir, interfaceName + "RunContextIF.java");
        String       typefmt   = "%-" + rcic.getLongestTypeName() + "s";
        PrintfFormat  typeformat   = new PrintfFormat(typefmt);

        out.write("package " + module.getGenPackage() + ".generated.mvw;\n\n");
       
        ImportManager manager = new ImportManager();
       
View Full Code Here

  }
 
  static public void formatAppRunContextInterface(String outdir, WebApplication app, RunContextItemCollection rcic) throws IOException{
        ImportManager   manager   = new ImportManager();
        String       typefmt   = "%-" + rcic.getLongestTypeName() + "s";
        PrintfFormat  typeformat   = new PrintfFormat(typefmt);
   
        String rcName = app.getAppName() + "RunContextIF";
        BufferedWriter   out = FileUpdateManager.instance().getWriter(outdir, rcName + ".java");

        out.write("package " + app.getDefinedInModule().getGenPackage() + ".generated.mvw;\n\n");
View Full Code Here

  }
 
  static public void formatImplementation(String outdir, WebApplication app, RunContextItemCollection rcic) throws IOException{
        ImportManager manager = new ImportManager();
        String       typefmt   = "%-" + rcic.getLongestTypeName() + "s";
        PrintfFormat  typeformat   = new PrintfFormat(typefmt);
        String       itemfmt   = "%-" + rcic.getLongestItemName() + "s";
        PrintfFormat  itemformat   = new PrintfFormat(itemfmt);
   
        String rcName = app.getAppName() + "RunContext";
        BufferedWriter   out = FileUpdateManager.instance().getWriter(outdir, rcName + ".java");

        out.write("package " + app.getDefinedInModule().getGenPackage() + ".generated.mvw;\n\n");
View Full Code Here

  }

  String formatImports(TreeMap<String,String> map, int longest){
    int padding = longest+17;
    StringBuffer sb = new StringBuffer();
    PrintfFormat format = new PrintfFormat("%-" + padding + "s");
   
    sb.append("// Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
   
    Iterator<String> keys = map.keySet().iterator();
    while(keys.hasNext()){
      String key = keys.next();
      sb.append(format.sprintf("import " + key + ";") + "// " + map.get(key) + "\n");
    }
   
    sb.append("\n");
   
    return(sb.toString());
View Full Code Here

  }

  String formatImports(TreeMap<String,String> map, int longest){
    int padding = longest+17;
    StringBuffer sb = new StringBuffer();
    PrintfFormat format = new PrintfFormat("%-" + padding + "s");
   
    sb.append("// Generated from: " + DebugInfo.getWhereWeAreNow() + "\n");
   
    Iterator<String> keys = map.keySet().iterator();
    while(keys.hasNext()){
      String key = keys.next();
      sb.append(format.sprintf("import " + key + ";") + "// " + map.get(key) + "\n");
    }
   
    sb.append("\n");
   
    return(sb.toString());
View Full Code Here

    /**
     * Formats the token list as a String.
     */
    public String toString(){
        PrintfFormat formatid = new PrintfFormat("%-6d");
        PrintfFormat formatud = new PrintfFormat("%-15s");
        StringBuffer    sb = new StringBuffer();

        sb.append("#     Type  Pos   UserData       \n");
        for(int i=0; i<size(); i++){
            Token t = (Token)get(i);
            sb.append(formatid.sprintf(i));
            sb.append(formatid.sprintf(t.getType()));
            sb.append(formatid.sprintf(t.getPos()));
            if (t.getUserData() == null)
                sb.append(formatud.sprintf("null"));
            else{
                String cn = t.getUserData().getClass().getName();

                sb.append(formatud.sprintf(cn.substring(cn.lastIndexOf(".")+1)));
            }
            sb.append(" " + t.getValue() + "\n");
        }
        return(sb.toString());
    }
View Full Code Here

TOP

Related Classes of org.dmd.util.formatting.PrintfFormat$ConversionSpecification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.