+ public int available() { return 0; }
+ public int getDepth() { return depth; }
+
+ /** Set the current character source. */
+ public void setReader(Reader in) { xml.setReader(in); }
+
+ public Tree.Leaf next() throws IOException { return xml.next(); }
+
+ public void skip() throws IOException {
+ int d = depth;
+ do { next(); } while (d != depth);
+ }
+
+ /** Used to hide implementation from public interface. */
+ private final class SXML extends XML {
+ private StringBuffer chars = new StringBuffer();
+ private Tree.Element element = null;
+ private Queue queue = new Queue(10);
+ int depth0 = 0;
+
+ private SXML(int b) { super(b, false); }
+ public void startElement(Tree.Element e) {
+ if (chars.length() > 0) {
+ queue.append(chars.toString());
+ queue.append(new Integer(depth0));
+ chars.setLength(0);
+ }
+ queue.append(e);
+ queue.append(new Integer(depth0));
+ depth0++;
+ }
+ public void endElement(Tree.Element e) {
+ if (chars.length() > 0) {
+ queue.append(chars.toString());
+ queue.append(new Integer(depth0));
+ chars.setLength(0);
+ }
+ depth0--;
+ }
+ public void whitespace(char[] ch, int s, int l) { characters(ch, s, l); }
+ public void characters(char[] ch, int s, int l) { chars.append(ch, s, l); }
+ private Tree.Leaf next() throws IOException, Exn {
+ while (queue.size() == 0)
+ if (!parseNext()) return null;
+ Object o = queue.remove();
+ depth = ((Integer)queue.remove()).intValue();
+ if (o instanceof String) return new Text(current(), (String)o);
+ else return (Tree.Leaf)o;
+ }