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; }