public static void main(String args[]) throws URISyntaxException { if (args.length > 0) { checkUnEsc(args[0]); } else { String s = "/thredds/dodsC/grib/NCEP/NAM/CONUS_12km/best.dods?Relative_humidity_pressure%5b0:1:0%5d%5b0:1:24%5d%5b0:10:420%5d%5b0:10:610%5d"; decode(s); } }
private static void checkEsc(String s) { System.out.printf("org = %s%n", s); System.out.printf("escapeQuery = %s%n", escapeQuery(s)); System.out.printf("escapeQueryNew = %s%n", escapeQueryNew(s)); System.out.printf("escQueryURIUtil= %s%n", escapeQueryURIUtil(s)); System.out.printf("escQueryEncoder= %s%n", escapeQueryEncoder(s)); System.out.printf("unescQueryDODS = %s%n", unescapeQueryDODS(escapeQuery(s))); System.out.printf("%n"); }
private static void checkUnEsc(String esc) { System.out.printf("esc = %s%n", esc); System.out.printf("unescQueryDODS = %s%n", unescapeQueryDODS(esc)); System.out.printf("unescapeDecoder = %s%n", unescapeQueryDecoder(esc)); System.out.printf("escapeQuery = %s%n", escapeQuery(unescapeQueryDODS(esc))); System.out.printf("%n"); }
String realLocation = URLnaming.resolveFile(ncmlLocation, location); realLocationRunTimeMap.put(realLocation, runTime); dirLocation = URLnaming.resolve(ncmlLocation, dirLocation); // possible relative location
static public void writeNcML(NetcdfFile ncfile, Formatter out, WantValues showValues, String url) throws IOException { out.format("<?xml version='1.0' encoding='UTF-8'?>%n"); out.format("<netcdf xmlns='http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2'%n"); if (url != null) out.format(" location='%s' >%n%n", StringUtil2.quoteXmlAttribute(url)); else out.format(" location='%s' >%n%n", StringUtil2.quoteXmlAttribute(URLnaming.canonicalizeWrite(ncfile.getLocation()))); if (ncfile.getId() != null) out.format(" id='%s'%n", StringUtil2.quoteXmlAttribute(ncfile.getId())); if (ncfile.getTitle() != null) out.format(" title='%s'%n", StringUtil2.quoteXmlAttribute(ncfile.getTitle())); writeNcMLGroup(ncfile, ncfile.getRootGroup(), out, new Indent(2), showValues); out.format("</netcdf>%n"); out.flush(); }
public static void main2(String args[]) { test("file:test/dir"); test("file:/test/dir"); test("file://test/dir"); test("file:///test/dir"); test("file:C:/Program Files (x86)/Apache Software Foundation/Tomcat 5.0/content/thredds/cache"); test("file:C:\\Program Files (x86)\\Apache Software Foundation\\Tomcat 5.0\\content\\thredds\\cache"); test("http://localhost:8080/thredds/catalog.html?hi=lo"); }
dirLocation = URLnaming.resolve(ncmlLocation, dirLocation); String realLocation = URLnaming.resolveFile(ncmlLocation, location); realLocationRunTimeMap.put(realLocation, runTime); realLocationList.add(realLocation); cacheName += "#" + Integer.toString(netcdfElemNested.hashCode()); // need a unique name, in case file has been modified by ncml String realLocation = URLnaming.resolveFile(ncmlLocation, location); dirLocation = URLnaming.resolve(ncmlLocation, dirLocation);
private static void checkUnEsc(String esc) { System.out.printf("esc = %s%n", esc); System.out.printf("unescQueryDODS = %s%n", unescapeQueryDODS(esc)); System.out.printf("unescapeDecoder = %s%n", unescapeQueryDecoder(esc)); System.out.printf("escapeQuery = %s%n", escapeQuery(unescapeQueryDODS(esc))); System.out.printf("%n"); }
static public void writeNcML(NetcdfFile ncfile, Formatter out, WantValues showValues, String url) throws IOException { out.format("<?xml version='1.0' encoding='UTF-8'?>%n"); out.format("<netcdf xmlns='http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2'%n"); if (url != null) out.format(" location='%s' >%n%n", StringUtil2.quoteXmlAttribute(url)); else out.format(" location='%s' >%n%n", StringUtil2.quoteXmlAttribute(URLnaming.canonicalizeWrite(ncfile.getLocation()))); if (ncfile.getId() != null) out.format(" id='%s'%n", StringUtil2.quoteXmlAttribute(ncfile.getId())); if (ncfile.getTitle() != null) out.format(" title='%s'%n", StringUtil2.quoteXmlAttribute(ncfile.getTitle())); writeNcMLGroup(ncfile, ncfile.getRootGroup(), out, new Indent(2), showValues); out.format("</netcdf>%n"); out.flush(); }
public static void main2() { test("file:test/dir"); test("file:/test/dir"); test("file://test/dir"); test("file:///test/dir"); test("file:C:/Program Files (x86)/Apache Software Foundation/Tomcat 5.0/content/thredds/cache"); test("file:C:\\Program Files (x86)\\Apache Software Foundation\\Tomcat 5.0\\content\\thredds\\cache"); test("http://localhost:8080/thredds/catalog.html?hi=lo"); }
private static void checkEsc(String s) { System.out.printf("org = %s%n", s); System.out.printf("escapeQuery = %s%n", escapeQuery(s)); System.out.printf("escapeQueryNew = %s%n", escapeQueryNew(s)); System.out.printf("escQueryURIUtil= %s%n", escapeQueryURIUtil(s)); System.out.printf("escQueryEncoder= %s%n", escapeQueryEncoder(s)); System.out.printf("unescQueryDODS = %s%n", unescapeQueryDODS(escapeQuery(s))); System.out.printf("%n"); }
dirLocation = URLnaming.resolve(ncmlLocation, dirLocation); cacheName += "#" + Integer.toString(netcdfElemNested.hashCode()); // need a unique name, in case file has been modified by ncml String realLocation = URLnaming.resolveFile(ncmlLocation, location); agg.addExplicitDataset(cacheName, realLocation, id, ncoords, coordValueS, sectionSpec, reader); dirLocation = URLnaming.resolve(ncmlLocation, dirLocation);
/** * Write the NcML representation for a file. * Note that ucar.nc2.dataset.NcMLWriter has a JDOM implementation, for complete NcML. * This method implements only the "core" NcML for plain ole netcdf files. * * @param ncfile write NcML for this file * @param os write to this Output Stream. * @param showCoords show coordinate variable values. * @param uri use this for the url attribute; if null use getLocation(). // ?? * @throws IOException on write error */ static public void writeNcML( NetcdfFile ncfile, java.io.OutputStream os, boolean showCoords, String uri) throws IOException { PrintStream out = new PrintStream( os); out.print("<?xml version='1.0' encoding='UTF-8'?>\n"); out.print("<netcdf xmlns='http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2'\n"); // out.print(" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n"); // out.print(" xsi:schemaLocation='http://www.unidata.edu/schemas/ncml-2.2 http://www.unidata.ucar.edu/schemas/ncml-2.2.xsd'\n"); if (uri != null) out.print(" location='"+ StringUtil2.quoteXmlAttribute(uri)+"' >\n\n"); else out.print(" location='"+ StringUtil2.quoteXmlAttribute(URLnaming.canonicalizeWrite(ncfile.getLocation()))+"' >\n\n"); if (ncfile.getId() != null) out.print(" id='"+ StringUtil2.quoteXmlAttribute(ncfile.getId())+"' >\n"); if (ncfile.getTitle() != null) out.print(" title='"+ StringUtil2.quoteXmlAttribute(ncfile.getTitle())+"' >\n"); writeNcMLGroup( ncfile, ncfile.getRootGroup(), out, new Indent(2), showCoords); out.print("</netcdf>\n"); out.flush(); }
public static void main(String args[]) throws URISyntaxException { if (args.length > 0) { checkUnEsc(args[0]); } else { String s = "/thredds/dodsC/grib/NCEP/NAM/CONUS_12km/best.dods?Relative_humidity_pressure%5b0:1:0%5d%5b0:1:24%5d%5b0:10:420%5d%5b0:10:610%5d"; decode(s); } }
dirLocation = URLnaming.resolve(ncmlLocation, dirLocation); cacheName += "#" + Integer.toString(netcdfElemNested.hashCode()); // need a unique name, in case file has been modified by ncml String realLocation = URLnaming.resolveFile(ncmlLocation, location); agg.addExplicitDataset(cacheName, realLocation, id, ncoords, coordValueS, sectionSpec, reader); dirLocation = URLnaming.resolve(ncmlLocation, dirLocation);
/** * Resolve reletive URIs, using the catalog's base URI. If the uriString is not reletive, then * no resolution is done. This also allows baseURI to be a file: scheme. * * @param uriString any url, reletive or absolute * @return resolved url string, or null on error * @throws java.net.URISyntaxException if uriString violates RFC 2396 * @see java.net.URI#resolve */ public URI resolveUri(String uriString) throws URISyntaxException { if (baseURI == null) return new URI(uriString); String resolved = URLnaming.resolve(baseURI.toString(), uriString); return new URI(resolved); }
/** * Write the NcML representation for a file. * Note that ucar.nc2.dataset.NcMLWriter has a JDOM implementation, for complete NcML. * This method implements only the "core" NcML for plain ole netcdf files. * * @param ncfile write NcML for this file * @param os write to this Output Stream. * @param showCoords show coordinate variable values. * @param uri use this for the url attribute; if null use getLocation(). // ?? * @throws IOException on write error */ static public void writeNcML( NetcdfFile ncfile, java.io.OutputStream os, boolean showCoords, String uri) throws IOException { PrintStream out = new PrintStream( os); out.print("<?xml version='1.0' encoding='UTF-8'?>\n"); out.print("<netcdf xmlns='http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2'\n"); // out.print(" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n"); // out.print(" xsi:schemaLocation='http://www.unidata.edu/schemas/ncml-2.2 http://www.unidata.ucar.edu/schemas/ncml-2.2.xsd'\n"); if (uri != null) out.print(" location='"+ StringUtil2.quoteXmlAttribute(uri)+"' >\n\n"); else out.print(" location='"+ StringUtil2.quoteXmlAttribute(URLnaming.canonicalizeWrite(ncfile.getLocation()))+"' >\n\n"); if (ncfile.getId() != null) out.print(" id='"+ StringUtil2.quoteXmlAttribute(ncfile.getId())+"' >\n"); if (ncfile.getTitle() != null) out.print(" title='"+ StringUtil2.quoteXmlAttribute(ncfile.getTitle())+"' >\n"); writeNcMLGroup( ncfile, ncfile.getRootGroup(), out, new Indent(2), showCoords); out.print("</netcdf>\n"); out.flush(); }
private ThreddsMetadata.UriResolved readUri(Element elemWithHref, String what) { if (elemWithHref == null) { return null; } String mapHref = elemWithHref.getAttributeValue("href", Catalog.xlinkNS); if (mapHref == null) { return null; } try { String mapUri = URLnaming.resolve(baseURI.toString(), mapHref); return new ThreddsMetadata.UriResolved(mapHref, new URI(mapUri)); } catch (Exception e) { errlog.format(" ** Invalid %s URI= '%s' err='%s'%n", what, mapHref, e.getMessage()); return null; } } }