Changeset 3346


Ignore:
Timestamp:
11/07/07 13:54:37 (12 years ago)
Author:
curtis
Message:

Use class resources instead of files directly;
output files with proper directory structure.

File:
1 edited

Legend:

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

    r3345 r3346  
    5555  public static void main(String[] args) throws IOException { 
    5656    System.out.print("Parsing input files... "); 
     57    File ome = new File("ome"); 
     58    if (!ome.exists()) ome.mkdir(); 
    5759 
    5860    // parse global input file 
     
    100102    String version = null; 
    101103    Hashtable vars = null; 
    102     BufferedReader in = new BufferedReader(new FileReader(GLOBAL_SRC)); 
     104    BufferedReader in = new BufferedReader(new InputStreamReader( 
     105      MetadataAutogen.class.getResourceAsStream(GLOBAL_SRC))); 
    103106    while (true) { 
    104107      String line = in.readLine(); 
     
    128131  } 
    129132 
    130   private static String parseHeader(String id) { 
    131     int len = (int) new File(id).length(); 
    132     byte[] b = null; 
    133     try { 
    134       DataInputStream in = new DataInputStream(new FileInputStream(id)); 
    135       b = new byte[len]; 
    136       in.readFully(b); 
    137       in.close(); 
    138     } 
    139     catch (IOException exc) { exc.printStackTrace(); } 
    140     return new String(b); 
     133  private static String parseHeader(String id) throws IOException { 
     134    BufferedReader in = new BufferedReader(new InputStreamReader( 
     135      MetadataAutogen.class.getResourceAsStream(id))); 
     136    StringBuffer sb = new StringBuffer(); 
     137    while (true) { 
     138      String line = in.readLine(); 
     139      if (line == null) break; 
     140      sb.append(line); 
     141      sb.append("\n"); 
     142    } 
     143    in.close(); 
     144    return sb.toString(); 
    141145  } 
    142146 
     
    144148    Vector nodes = new Vector(); 
    145149    Node node = null; 
    146     BufferedReader in = new BufferedReader(new FileReader(NODES_SRC)); 
     150    BufferedReader in = new BufferedReader(new InputStreamReader( 
     151      MetadataAutogen.class.getResourceAsStream(NODES_SRC))); 
    147152    while (true) { 
    148153      String line = in.readLine(); 
     
    210215      } 
    211216      // OME-XML implementation 
    212       doSetters("OMEXML" + key + "Metadata.java", value, node, false); 
     217      doSetters("ome/OMEXML" + key + "Metadata.java", value, node, false); 
    213218    } 
    214219  } 
     
    227232      } 
    228233      // OME-XML implementations 
    229       doGetters("OMEXML" + key + "Metadata.java", value, node, false); 
     234      doGetters("ome/OMEXML" + key + "Metadata.java", value, node, false); 
    230235    } 
    231236  } 
     
    456461      vars = basicVars; 
    457462    } 
    458     else { // id.startsWith("OMEXML") 
     463    else { // id.startsWith("ome/OMEXML") 
    459464      header = omexmlHeader; 
    460       vars = (Hashtable) versions.get(id.substring(6, id.length() - 13)); 
     465      vars = (Hashtable) versions.get(id.substring(10, id.length() - 13)); 
    461466    } 
    462467    header = filterHeader(header, vars); 
Note: See TracChangeset for help on using the changeset viewer.