Changeset 4134


Ignore:
Timestamp:
06/23/08 10:47:34 (11 years ago)
Author:
curtis
Message:

Initial version of metadata property documentation generator. No groups yet.

Location:
trunk/loci/formats/auto
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/auto/IniParser.java

    r4048 r4134  
    4242 
    4343  /** Key to use for storing header value (in brackets). */ 
    44   public static final String HEADER_KEY = "name"; 
     44  public static final String HEADER_KEY = "header"; 
    4545 
    4646  // -- IniParser API methods -- 
  • trunk/loci/formats/auto/MetadataAutogen.java

    r4079 r4134  
    3535 * interfaces, as well as the implementations for various flavors of OME-XML. 
    3636 * 
     37 * Uses data from the entities.txt and versions.txt files. 
     38 * 
    3739 * <dl><dt><b>Source code:</b></dt> 
    3840 * <dd><a href="https://skyking.microscopy.wisc.edu/trac/java/browser/trunk/loci/formats/auto/MetadataAutogen.java">Trac</a>, 
     
    5254    if (!meta.exists()) meta.mkdir(); 
    5355 
    54     // initialize Velocity engine; enable loading of templates as resources 
    55     VelocityEngine ve = new VelocityEngine(); 
    56     Properties p = new Properties(); 
    57     p.setProperty("resource.loader", "class"); 
    58     p.setProperty("class.resource.loader.class", 
    59       "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); 
    60     ve.init(p); 
    61  
    62     // populate Velocity context 
    63     VelocityContext context = new VelocityContext(); 
    64     context.put("user", System.getProperty("user.name")); 
    65     DateFormat dateFmt = DateFormat.getDateInstance(DateFormat.MEDIUM); 
    66     DateFormat timeFmt = DateFormat.getTimeInstance(DateFormat.LONG); 
    67     Date date = Calendar.getInstance().getTime(); 
    68     context.put("timestamp", dateFmt.format(date) + " " + timeFmt.format(date)); 
     56    // get Velocity objects 
     57    VelocityEngine ve = VelocityTools.createEngine(); 
     58    VelocityContext context = VelocityTools.createContext(); 
    6959 
    7060    // parse entity list 
     
    7363 
    7464    // generate base metadata classes 
    75     processTemplate(ve, context, 
     65    VelocityTools.processTemplate(ve, context, 
    7666      "MetadataStore.vm", "meta/MetadataStore.java"); 
    77     processTemplate(ve, context, 
     67    VelocityTools.processTemplate(ve, context, 
    7868      "MetadataRetrieve.vm", "meta/MetadataRetrieve.java"); 
    79     processTemplate(ve, context, 
     69    VelocityTools.processTemplate(ve, context, 
    8070      "DummyMetadata.vm", "meta/DummyMetadata.java"); 
    81     processTemplate(ve, context, 
     71    VelocityTools.processTemplate(ve, context, 
    8272      "FilterMetadata.vm", "meta/FilterMetadata.java"); 
    83     processTemplate(ve, context, 
     73    VelocityTools.processTemplate(ve, context, 
    8474      "AggregateMetadata.vm", "meta/AggregateMetadata.java"); 
    8575    context.put("convertMetadataBody", generateConvertMetadata(entityList)); 
    86     processTemplate(ve, context, 
     76    VelocityTools.processTemplate(ve, context, 
    8777      "MetadataConverter.vm", "meta/MetadataConverter.java"); 
    8878 
     
    9080    for (String versionKey : entityList.versions()) { 
    9181      entityList.setVersion(versionKey); 
    92       processTemplate(ve, context, "OMEXMLMetadata.vm", 
     82      VelocityTools.processTemplate(ve, context, "OMEXMLMetadata.vm", 
    9383        "ome/OMEXML" + versionKey + "Metadata.java"); 
    9484    } 
     
    9686 
    9787  // -- Helper methods -- 
    98  
    99   private static void processTemplate(VelocityEngine ve, 
    100     VelocityContext context, String inFile, String outFile) 
    101     // NB: No choice, as VelocityEngine.getTemplate(String) throws Exception 
    102     throws Exception 
    103   { 
    104     System.out.print("Writing " + outFile + ": "); 
    105     Template t = ve.getTemplate("loci/formats/auto/" + inFile); 
    106     StringWriter writer = new StringWriter(); 
    107     t.merge(context, writer); 
    108     PrintWriter out = new PrintWriter(new FileWriter(outFile)); 
    109     out.print(writer.toString()); 
    110     out.close(); 
    111     System.out.println("done."); 
    112   } 
    11388 
    11489  private static String generateConvertMetadata(final MetaEntityList q) { 
Note: See TracChangeset for help on using the changeset viewer.