Refine search
private Matcher matchFilename(final String filename) { final String name = new Location(filename).getName(); if (cellomicsPattern == null) { Matcher m = PATTERN_O.matcher(name); if (m.matches() && m.group(4) != null) { cellomicsPattern = PATTERN_O; return m; } else { cellomicsPattern = PATTERN_D; } } return cellomicsPattern.matcher(name); } private String getPlateName(final String filename) {
private Matcher matchFilename(final String filename) { final String name = new Location(filename).getName(); if (cellomicsPattern == null) { Matcher m = PATTERN_O.matcher(name); if (m.matches() && m.group(4) != null) { cellomicsPattern = PATTERN_O; return m; } else { cellomicsPattern = PATTERN_D; } } return cellomicsPattern.matcher(name); } private String getPlateName(final String filename) {
public void setResolution(int series, int resolution) throws IndexOutOfBoundsException { Location file = new Location(dataFile); String tableName = file.getName() + SERIES + series + " " + RESOLUTION + resolution; currentTable = ini.getTable(tableName); if (currentTable == null && resolution == 0) { // don't require the resolution key for single-resolution series currentTable = ini.getTable(file.getName() + SERIES + series); } if (currentTable == null) { throw new IndexOutOfBoundsException("Invalid table name: " + tableName); } }
/** * Identifies the group pattern from a given filename and directory. * * @param name The file basename to use as a template for the match. * @param dir The directory in which to search for matching files. * @return the identified pattern. */ public static String findPattern(String name, String dir) { if (dir == null) dir = ""; // current directory else if (!dir.equals("") && !dir.endsWith(File.separator)) { dir += File.separator; } Location dirFile = new Location(dir.equals("") ? "." : dir); // list files in the given directory Location[] f = dirFile.listFiles(); if (f == null) return null; String[] nameList = new String[f.length]; for (int i=0; i<nameList.length; i++) nameList[i] = f[i].getName(); return findPattern(name, dir, nameList); }
/** * Identifies the group pattern from a given filename and directory. * * @param name The file basename to use as a template for the match. * @param dir The directory in which to search for matching files. * @return the identified pattern. */ public static String findPattern(String name, String dir) { if (dir == null) dir = ""; // current directory else if (!dir.equals("") && !dir.endsWith(File.separator)) { dir += File.separator; } Location dirFile = new Location(dir.equals("") ? "." : dir); // list files in the given directory Location[] f = dirFile.listFiles(); if (f == null) return null; String[] nameList = new String[f.length]; for (int i=0; i<nameList.length; i++) nameList[i] = f[i].getName(); return findPattern(name, dir, nameList); }
/** * Look up a filename in the cache. * @param name the name to look up (case insensitive). * @return the filename on disc (case sensitive). * @throws IOException */ public Location lookup(Location name) throws IOException { Location parent = name.getParentFile(); if (parent != null) { HashMap<String, String> s = fill(parent); if (s != null) { String realname = name.getName(); String lower = realname.toLowerCase(); String f = s.get(lower); if (f != null) { return new Location(parent, f); } } } return name; } }
@Override public boolean isSingleFile(String id) throws FormatException, IOException { Location file = new Location(id).getAbsoluteFile(); String name = file.getName(); if (name.equals(XML_FILE) || name.equals(EXPERIMENT_FILE) || name.equals(ACQUISITION_FILE)) { return true; } Location parent = file.getParentFile(); if (parent != null) { parent = parent.getParentFile(); } return new Location(parent, XML_FILE).exists(); }
@Override public boolean isSingleFile(String id) throws FormatException, IOException { Location file = new Location(id).getAbsoluteFile(); String name = file.getName(); if (name.equals(XML_FILE) || name.equals(EXPERIMENT_FILE) || name.equals(ACQUISITION_FILE)) { return true; } Location parent = file.getParentFile(); if (parent != null) { parent = parent.getParentFile(); } return new Location(parent, XML_FILE).exists(); }
private void pruneINI() { IniList newIni = new IniList(); for (IniTable table : ini) { String tableName = table.get(IniTable.HEADER_KEY); Location file = new Location(dataFile); if (tableName.startsWith(file.getName() + " ")) { newIni.add(table); if (tableName.endsWith("global")) { globalTable = table; } } } ini = newIni; } }
@Override public boolean isThisType(String name, boolean open) { String localName = new Location(name).getName(); if (localName.equals(XML_FILE) || localName.equals(EXPERIMENT_FILE) || localName.equals(ACQUISITION_FILE)) { return true; } Location parent = new Location(name).getAbsoluteFile().getParentFile(); if (checkSuffix(name, "tif") && parent.getName().equalsIgnoreCase("Data")) { parent = parent.getParentFile(); } Location xmlFile = new Location(parent, XML_FILE); if (!xmlFile.exists()) { return false; } return super.isThisType(name, open); }