static public boolean getEosInfo(NetcdfFile ncfile, Group eosGroup, Formatter f) throws IOException { String smeta = getStructMetadata(eosGroup); if (smeta == null) { f.format("No StructMetadata variables in group %s %n", eosGroup.getFullName()); return false; } f.format("raw = %n%s%n", smeta); ODLparser parser = new ODLparser(); parser.parseFromString(smeta); // now we have the ODL in JDOM elements StringWriter sw = new StringWriter(5000); parser.showDoc(new PrintWriter(sw)); f.format("parsed = %n%s%n", sw.toString()); return true; }
public Element parseFromString(String text) throws IOException { if (showRaw) System.out.println("Raw ODL=\n"+text); Element rootElem = new Element("odl"); doc = new Document(rootElem); Element current = rootElem; StringTokenizer lineFinder = new StringTokenizer(text, "\t\n\r\f"); while (lineFinder.hasMoreTokens()) { String line = lineFinder.nextToken(); if (line.startsWith("GROUP")) { current = startGroup(current, line); } else if (line.startsWith("OBJECT")) { current = startObject(current, line); } else if (line.startsWith("END_OBJECT")) { endObject( current, line); current = current.getParentElement(); } else if (line.startsWith("END_GROUP")) { endGroup( current, line); current = current.getParentElement(); } else { addField( current, line); } } if (show) showDoc(System.out); return rootElem; }
public static Element getEosElement(String name, Group eosGroup) throws IOException { String smeta = getEosMetadata(name, eosGroup); if (smeta == null) { return null; } smeta = smeta.replaceAll("\\s+=\\s+", "="); smeta = smeta.replaceAll("\\?", "_"); // XML names cannot contain the character "?". StringBuilder sb = new StringBuilder(smeta.length()); StringTokenizer lineFinder = new StringTokenizer(smeta, "\t\n\r\f"); while (lineFinder.hasMoreTokens()) { String line = lineFinder.nextToken().trim(); sb.append(line); sb.append("\n"); } ODLparser parser = new ODLparser(); return parser.parseFromString(sb.toString());// now we have the ODL in JDOM elements }
void addField(Element parent, String line) throws IOException { StringTokenizer stoke = new StringTokenizer(line, "="); String name = stoke.nextToken(); if (stoke.hasMoreTokens()) { Element field = new Element(name); parent.addContent(field); String value = stoke.nextToken(); if (value.startsWith("(")) { parseValueCollection(field, value); return; } value = stripQuotes(value); field.addContent(value); } }
void parseFile(String filename) throws IOException { String text = new String(IO.readFileToByteArray(filename), CDM.utf8Charset); parseFromString(text); }
public Element parseFromString(String text) throws IOException { if (showRaw) System.out.println("Raw ODL=\n"+text); Element rootElem = new Element("odl"); doc = new Document(rootElem); Element current = rootElem; StringTokenizer lineFinder = new StringTokenizer(text, "\t\n\r\f"); while (lineFinder.hasMoreTokens()) { String line = lineFinder.nextToken(); if (line == null) continue; if (line.startsWith("GROUP")) { current = startGroup(current, line); } else if (line.startsWith("OBJECT")) { current = startObject(current, line); } else if (line.startsWith("END_OBJECT")) { endObject( current, line); current = current.getParentElement(); if (current == null) throw new IllegalStateException(); } else if (line.startsWith("END_GROUP")) { endGroup( current, line); current = current.getParentElement(); if (current == null) throw new IllegalStateException(); } else { addField( current, line); } } if (show) showDoc(new PrintWriter( new OutputStreamWriter(System.out))); return rootElem; }
Group rootg = ncfile.getRootGroup(); ODLparser parser = new ODLparser(); Element root = parser.parseFromString(structMetadata); // now we have the ODL in JDOM elements FeatureType featureType = null;
void addField(Element parent, String line) throws IOException { StringTokenizer stoke = new StringTokenizer(line, "="); String name = stoke.nextToken(); if (stoke.hasMoreTokens()) { Element field = new Element(name); parent.addContent(field); String value = stoke.nextToken(); if (value.startsWith("(")) { parseValueCollection(field, value); return; } value = stripQuotes(value); field.addContent(value); } }
void parseFile(String filename) throws IOException { String text = new String(IO.readFileToByteArray(filename), CDM.utf8Charset); parseFromString(text); }
public Element parseFromString(String text) throws IOException { if (showRaw) System.out.println("Raw ODL=\n"+text); Element rootElem = new Element("odl"); doc = new Document(rootElem); Element current = rootElem; StringTokenizer lineFinder = new StringTokenizer(text, "\t\n\r\f"); while (lineFinder.hasMoreTokens()) { String line = lineFinder.nextToken(); if (line == null) continue; if (line.startsWith("GROUP")) { current = startGroup(current, line); } else if (line.startsWith("OBJECT")) { current = startObject(current, line); } else if (line.startsWith("END_OBJECT")) { endObject( current, line); current = current.getParentElement(); if (current == null) throw new IllegalStateException(); } else if (line.startsWith("END_GROUP")) { endGroup( current, line); current = current.getParentElement(); if (current == null) throw new IllegalStateException(); } else { addField( current, line); } } if (show) showDoc(new PrintWriter( new OutputStreamWriter(System.out, CDM.utf8Charset))); return rootElem; }
static public boolean getEosInfo(NetcdfFile ncfile, Group eosGroup, Formatter f) throws IOException { String smeta = getStructMetadata(eosGroup); if (smeta == null) { f.format("No StructMetadata variables in group %s %n", eosGroup.getFullName()); return false; } f.format("raw = %n%s%n", smeta); ODLparser parser = new ODLparser(); parser.parseFromString(smeta); // now we have the ODL in JDOM elements ByteArrayOutputStream bos = new ByteArrayOutputStream(1000 * 1000); parser.showDoc(bos); f.format("parsed = %n%s%n", bos.toString()); return true; }
Group rootg = ncfile.getRootGroup(); ODLparser parser = new ODLparser(); Element root = parser.parseFromString(structMetadata); // now we have the ODL in JDOM elements FeatureType featureType = null;
void addField(Element parent, String line) throws IOException { StringTokenizer stoke = new StringTokenizer(line, "="); String name = stoke.nextToken(); if (stoke.hasMoreTokens()) { Element field = new Element(name); parent.addContent(field); String value = stoke.nextToken(); if (value.startsWith("(")) { parseValueCollection(field, value); return; } value = stripQuotes(value); field.addContent(value); } }
void parseFile(String filename) throws IOException { String text = new String(IO.readFileToByteArray(filename)); parseFromString(text); }
/** * */ static public boolean getEosInfo(NetcdfFile ncfile, Group eosGroup, Formatter f) throws IOException { String smeta = getStructMetadata(eosGroup); if (smeta == null) { f.format("No StructMetadata variables in group %s %n", eosGroup.getFullName()); return false; } f.format("raw = %n%s%n", smeta); ODLparser parser = new ODLparser(); parser.parseFromString(smeta); // now we have the ODL in JDOM elements StringWriter sw = new StringWriter(5000); parser.showDoc(new PrintWriter(sw)); f.format("parsed = %n%s%n", sw.toString()); return true; }
Group rootg = ncfile.getRootGroup(); ODLparser parser = new ODLparser(); Element root = parser.parseFromString(structMetadata); // now we have the ODL in JDOM elements FeatureType featureType = null;