Examples of PrintfFormat


Examples of org.dmd.util.formatting.PrintfFormat

  }
 
  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

Examples of org.dmd.util.formatting.PrintfFormat

  }

  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

Examples of org.dmd.util.formatting.PrintfFormat

  }

  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

Examples of org.dmd.util.formatting.PrintfFormat

    /**
     * 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

Examples of org.dmd.util.formatting.PrintfFormat

  public DmcTraceableInputStream(InputStream is, SchemaManager sm, boolean cf, int padding){
    dis     = new DataInputStream(is);
    schema     = sm;
    calledFrom   = cf;
    format     = new PrintfFormat("%-" + padding + "s");
  }
View Full Code Here

Examples of org.dmd.util.formatting.PrintfFormat

  PrintfFormat    format;
 
  public DmcTraceableOutputStream(OutputStream os, boolean cf, int padding) {
    dos = new DataOutputStream(os);
    calledFrom = cf;
    format = new PrintfFormat("%-" + padding + "s");
    isFile = true;
  }
View Full Code Here

Examples of org.dmd.util.formatting.PrintfFormat

  }

  public DmcTraceableOutputStream(OutputStream os, boolean cf, int padding, boolean mode) {
    dos = new DataOutputStream(os);
    calledFrom = cf;
    format = new PrintfFormat("%-" + padding + "s");
    isFile = mode;
  }
View Full Code Here

Examples of org.dmd.util.formatting.PrintfFormat

  }

  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

Examples of org.dmd.util.formatting.PrintfFormat

     */
    public void run(String[] args) {
        CommandLine         cl          = new CommandLine();
        ResultSet           rs          = new ResultSet();

        nameFormat = new PrintfFormat("%-30s");
        numFormat  = new PrintfFormat("%10d");
        colFormat  = new PrintfFormat("%10s");
        longestName = 0;

        packages    = new TreeMap<String,TreeMap<String,CodeCountInfo>>();
        out         = null;

        help = new StringBuffer();
        //            ***************************************************************************
        help.append("count -h -workspace -id -of -r -skip\n\n");
        help.append("The code count tool provides a simple code count mechansism. It indicates the\n");
        help.append("number of source, comment, import and blank lines in a set of Java files\n");
        help.append("and how many files are auto generated.\n");
        help.append("\n");
        help.append("-h          Dumps the help information\n");
        help.append("\n");
        help.append("-workspace  Indicates the workspace prefix.\n");
        help.append("\n");
        help.append("-id         Indicates the directory beneath the workspace at which parsing should start. \n");
        help.append("\n");
        help.append("-of         The output file name.\n");
        help.append("\n");
        help.append("-r          Indicates that you want to recurse through all subdirectories. \n");
        help.append("\n");
        help.append("-skip      (suffix) Indicates that you want to skip subdirectories that end with the \n");
        help.append("           specified suffix.\n");
        help.append("\n");
        help.append("\n");

        cl.addOption("-h",helpFlag,"Dumps the help message.");
        cl.addOption("-o",ofn,"Output file name.");
        cl.addOption("-workspace",   workspace,   "The workspace prefix");
        cl.addOption("-indir",inDir,"The input directory");
        cl.addOption("-of",outDir,"The output directory");
        cl.addOption("-r",recursiveFlag,"Recurses through all subdirectories.");
        cl.addOption("-skip",skip,"Skips the specified directory.");

        cl.parseArgs(args);

        if (ofn.length() > 0){
            try {
                out = new BufferedWriter(new FileWriter(ofn.toString()));
            } catch (IOException e) {
                System.out.println("IO Error:\n" + e);
                System.exit(1);
            }
        }

        // println("The args " + args[0] + "\n");

        if ((args.length == 0) || helpFlag.booleanValue() == true){
            println(help.toString());
            System.exit(0);
        }

        if (workspace.length() == 0){
          System.err.println("You must specify the -workspace argument");
          System.exit(1);
        }
       
        String startDir = workspace.toString();
       
        if (inDir.length() > 0){
          startDir = startDir + File.separator + inDir.toString();
        }

        readDirectory(rs,startDir);

        nameFormat = new PrintfFormat("%-" + longestName + "s");
        totalFormat = new PrintfFormat("%" + longestName + "s");
        dumpInfo();

        println(rs.toString());

        if (out != null){
View Full Code Here

Examples of org.dmd.util.formatting.PrintfFormat

//        Iterator<AttributeDefinition> adit = attrDefs.values().iterator();
//        Iterator<ClassDefinition> cdit = classDefs.values().iterator();
//        AttributeDefinition ad  = null;
//        ClassDefinition     cd  = null;
        StringBuffer    sb  = new StringBuffer();
        PrintfFormat  format = null;
       
        if (longestAttrName > longest)
          longest = longestAttrName;
       
        String  longestStr = "" + longest;
        format = new PrintfFormat("%-" + longestStr + "s ");

        sb.append("*** Attributes\n");
        TreeMap<StringName,AttributeDefinition> sattrs = new TreeMap<StringName, AttributeDefinition>();
       
        for(AttributeDefinition ad : attrDefs.values())
          sattrs.put(ad.getName(), ad);
       
        for(AttributeDefinition ad : sattrs.values())
            sb.append(format.sprintf(ad.getObjectName()) + ad.getDefinedIn().getName() + "\n");
       

        sb.append("*** Classes\n");
        TreeMap<StringName,ClassDefinition> scdefs = new TreeMap<StringName, ClassDefinition>();
       
        for(ClassDefinition cd : classDefs.values())
          scdefs.put(cd.getName(), cd);
       
        for(ClassDefinition cd : scdefs.values()){
            sb.append(format.sprintf(cd.getObjectName()));
            if (cd.getAbbrev() != null)
                sb.append(" AB " + cd.getAbbrev());
            sb.append(cd.getDefinedIn().getName() + "\n");
        }
      
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.