Changeset 3386


Ignore:
Timestamp:
11/19/07 12:13:27 (12 years ago)
Author:
curtis
Message:

Split LineTracker into separate source file.

Location:
trunk/loci/formats/auto
Files:
1 added
1 edited

Legend:

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

    r3384 r3386  
    798798  } 
    799799 
    800   /** A helper class for managing line output with intelligent wrapping. */ 
    801   public static class LineTracker { 
    802     private static final int MAX_LEN = 80; 
    803     private Vector lines = new Vector(); 
    804     private StringBuffer line = new StringBuffer(); 
    805     private boolean wrapped = false; 
    806     public void newline() { 
    807       lines.add(line.toString()); 
    808       line.setLength(0); 
    809       wrapped = false; 
    810     } 
    811     public void add(String s) { add(s, ""); } 
    812     public void add(String s, String lead) { 
    813       if (line.length() + s.length() > MAX_LEN) { 
    814         newline(); 
    815         wrapped = true; 
    816         s = lead + s.trim(); 
    817       } 
    818       line.append(s); 
    819     } 
    820     public void addTokens(String s, String lead) { 
    821       StringTokenizer st = new StringTokenizer(s); 
    822       String lastToken = st.hasMoreTokens() ? st.nextToken() : null; 
    823       if (lastToken != null) add(lastToken); 
    824       while (st.hasMoreTokens()) { 
    825         String token = st.nextToken(); 
    826         if (!lastToken.endsWith("(")) token = " " + token; 
    827         add(token, lead); 
    828         lastToken = token; 
    829       } 
    830     } 
    831     public boolean hasWrapped() { return wrapped; } 
    832     public String toString() { 
    833       StringBuffer sb = new StringBuffer(); 
    834       for (int i=0; i<lines.size(); i++) sb.append(lines.get(i) + "\n"); 
    835       if (line.length() > 0) sb.append(line); 
    836       return sb.toString(); 
    837     } 
    838   } 
    839  
    840800  /** A helper class for managing open output files. */ 
    841801  public static class OutFiles { 
Note: See TracChangeset for help on using the changeset viewer.