Changeset 5610 for branches/4.1


Ignore:
Timestamp:
10/16/09 08:05:14 (11 years ago)
Author:
melissa
Message:

Added appendServerMap(String, String) method to FlexReader.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.1/components/bio-formats/src/loci/formats/in/FlexReader.java

    r5599 r5610  
    12511251  // -- FlexReader API methods -- 
    12521252 
    1253   /** Map the server named 'alias' to the path 'realName'.  */ 
     1253  /** 
     1254   * Add the path 'realName' to the mapping for the server named 'alias'. 
     1255   * @throws FormatException if 'realName' does not exist 
     1256   */ 
     1257  public static void appendServerMap(String alias, String realName) 
     1258    throws FormatException 
     1259  { 
     1260    LogTools.debug("appendServerMap(" + alias + ", " + realName + ")"); 
     1261 
     1262    if (alias != null) { 
     1263      if (realName == null) { 
     1264        LogTools.debug("removing mapping for " + alias); 
     1265        serverMap.remove(alias); 
     1266      } 
     1267      else { 
     1268        // verify that 'realName' exists 
     1269        Location server = new Location(realName); 
     1270        if (!server.exists()) { 
     1271          throw new FormatException("Server " + realName + " was not found."); 
     1272        } 
     1273        String[] names = serverMap.get(alias); 
     1274        if (names == null) { 
     1275          serverMap.put(alias, new String[] {realName}); 
     1276        } 
     1277        else { 
     1278          String[] tmpNames = new String[names.length + 1]; 
     1279          System.arraycopy(names, 0, tmpNames, 0, names.length); 
     1280          tmpNames[tmpNames.length - 1] = realName; 
     1281          serverMap.put(alias, tmpNames); 
     1282        } 
     1283      } 
     1284    } 
     1285  } 
     1286 
     1287  /** 
     1288   * Map the server named 'alias' to the path 'realName'. 
     1289   * If other paths were mapped to 'alias', they will be overwritten. 
     1290   */ 
    12541291  public static void mapServer(String alias, String realName) { 
    12551292    LogTools.debug("mapSever(" + alias + ", " + realName + ")"); 
     
    12601297      } 
    12611298      else { 
    1262         // verify that 'realName' exists 
    12631299        Location server = new Location(realName); 
    1264         if (!server.exists()) { 
    1265           LogTools.debug("Server " + realName + " was not found."); 
    1266           return; 
    1267         } 
    12681300 
    12691301        LogTools.debug("Finding base server name..."); 
     
    12991331  } 
    13001332 
    1301   /** Map the server named 'alias' to the path 'realName'.  */ 
     1333  /** 
     1334   * Map the server named 'alias' to the paths in 'realNames'. 
     1335   * If other paths were mapped to 'alias', they will be overwritten. 
     1336   */ 
    13021337  public static void mapServer(String alias, String[] realNames) { 
    13031338    StringBuffer msg = new StringBuffer("mapServer("); 
     
    13201355      } 
    13211356      else { 
    1322         Vector<String> names = new Vector<String>(); 
    13231357        for (String server : realNames) { 
    1324           if (!new Location(server).getAbsoluteFile().exists()) { 
    1325             LogTools.debug("Server " + server + " does not exist."); 
     1358          try { 
     1359            appendServerMap(alias, server); 
    13261360          } 
    1327           else names.add(server); 
    1328         } 
    1329  
    1330         serverMap.put(alias, names.toArray(new String[names.size()])); 
     1361          catch (FormatException e) { 
     1362            LogTools.traceDebug(e); 
     1363          } 
     1364        } 
    13311365      } 
    13321366    } 
Note: See TracChangeset for help on using the changeset viewer.