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; }
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; }
/** * */ 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 == 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; }
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; }
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; }