static public ConfigCatalog readCatalog(String catalogFullPath) throws IOException { // see if it exists File catFile = new File(catalogFullPath); if (!catFile.exists()) { int pos = catalogFullPath.indexOf("content/thredds/"); String filename = (pos > 0) ? catalogFullPath.substring(pos+16) : catalogFullPath; throw new FileNotFoundException(filename); } URI uri; try { uri = new URI("file:" + StringUtil2.escape(catalogFullPath, "/:-_.")); // LOOK needed ? } catch (URISyntaxException e) { logger.error(ERROR + "readCatalog(): URISyntaxException=" + e.getMessage()); return null; } ConfigCatalogBuilder builder = new ConfigCatalogBuilder(); ConfigCatalog cat = (ConfigCatalog) builder.buildFromURI(uri); // LOOK use file and keep lastModified if (builder.hasFatalError()) { throw new IOException("invalid catalog " + catalogFullPath); } return cat; }
public static void main2(String args[]) { if (args.length < 2) { showUsage(); return; } if (args[0].equalsIgnoreCase("escape")) { String ok = (args.length > 2) ? args[2] : ""; System.out.println(" escape(" + args[1] + "," + ok + ")= " + StringUtil2.escape(args[1], ok)); } else if (args[0].equalsIgnoreCase("unescape")) { System.out.println(" unescape(" + args[1] + ")= " + StringUtil2.unescape(args[1])); } else { showUsage(); } }
public static void main3(String args[]) { if (args.length < 2) { showUsage(); return; } if (args[0].equalsIgnoreCase("escape")) { String ok = (args.length > 2) ? args[2] : ""; System.out.println(" escape(" + args[1] + "," + ok + ")= " + StringUtil2.escape(args[1], ok)); } else if (args[0].equalsIgnoreCase("unescape")) { System.out.println(" unescape(" + args[1] + ")= " + StringUtil2.unescape(args[1])); } else { showUsage(); } }