Changeset 5639


Ignore:
Timestamp:
10/27/09 20:49:35 (10 years ago)
Author:
melissa
Message:

Updated IEnumerationHandler interface.

Location:
trunk/components/bio-formats/src/loci/formats/enums/handler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/enums/handler/CorrectionEnumHandler.java

    r5630 r5639  
    2424package loci.formats.enums.handler; 
    2525 
     26import java.util.Hashtable; 
    2627import java.util.List; 
    2728 
     
    4142 
    4243  /** Every Correction value must match one of these patterns. */ 
    43   private static final String[] patterns = new String[] { 
    44     "^\\s*Pl.*Apo.*$", 
    45     "^\\s*Pl.*Flu.*$", 
    46     "^\\s*Sup.*Flu.*$", 
    47     "^\\s*Vio.*Corr.*$", 
    48     "^\\s*Achr.*Flu.*$", 
    49     "^\\s*Neo.*flu.*$", 
    50     "^\\s*Apo.*$" 
    51   }; 
     44  private static final Hashtable<String, String> patterns = makePatterns(); 
     45 
     46  private static Hashtable<String, String> makePatterns() { 
     47    Hashtable<String, String> p = new Hashtable<String, String>(); 
     48    p.put("^\\s*Pl.*Apo.*$", "PlanApo"); 
     49    p.put("^\\s*Pl.*Flu.*$", "PlanFluor"); 
     50    p.put("^\\s*Sup.*Flu.*$", "SuperFluor"); 
     51    p.put("^\\s*Vio.*Corr.*$", "VioletCorrected"); 
     52    p.put("^\\s*Achr.*Flu.*$", "Achromat"); 
     53    p.put("^\\s*Neo.*flu.*$", "Neofluar"); 
     54    p.put("^\\s*Apo.*$", "Apo"); 
     55    p.put("^\\s*UV.*$", "UV"); 
     56    p.put("^\\s*Fluar.*$", "Fluar"); 
     57    p.put("^\\s*Neo.*fluar.*$", "Neofluar"); 
     58    p.put("^\\s*Pl.*Neo.*flu.*$", "PlanNeofluar"); 
     59    p.put("[Oo]ther", "Other"); 
     60    return p; 
     61  } 
    5262 
    5363  // -- IEnumerationHandler API methods -- 
    5464 
    55   /* @see IEnumerationHandler#getEnumeration(List<T>, String) */ 
    56   public <T extends Enumeration> T getEnumeration(List<T> enumerations, 
    57     String value) throws EnumerationException 
     65  /* @see IEnumerationHandler#getEnumeration(String) */ 
     66  public <T extends Enumeration> T getEnumeration(String value) 
     67    throws EnumerationException 
    5868  { 
    59     for (String pattern : patterns) { 
     69    for (String pattern : patterns.keySet()) { 
    6070      if (value.matches(pattern)) { 
    61         for (T e : enumerations) { 
    62           if (e.toString().matches(pattern)) { 
    63             return e; 
    64           } 
    65         } 
    66         throw new EnumerationException(this.getClass().getName() + 
    67           " could not find enumeration for " + value); 
     71        String v = patterns.get(pattern); 
     72        // TODO : uncomment this once enum classes are committed 
     73        //Correction c = Correction.fromString(v); 
     74        //return c; 
    6875      } 
    6976    } 
    70     return null; 
     77    throw new EnumerationException(this.getClass().getName() + 
     78     " could not find enumeration for " + value); 
    7179  } 
    7280 
  • trunk/components/bio-formats/src/loci/formats/enums/handler/IEnumerationHandler.java

    r5630 r5639  
    4343   * @param value Value for which to find an enumeration. 
    4444   */ 
    45   <T extends Enumeration> T getEnumeration(List<T> enumerations, String value) 
     45  <T extends Enumeration> T getEnumeration(String value) 
    4646    throws EnumerationException; 
    4747 
Note: See TracChangeset for help on using the changeset viewer.