| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
package net.sf.saxon.event; |
| 10 |
|
| 11 |
import net.sf.saxon.expr.parser.Location; |
| 12 |
import net.sf.saxon.om.Item; |
| 13 |
import net.sf.saxon.om.NamespaceBindingSet; |
| 14 |
import net.sf.saxon.om.NodeName; |
| 15 |
import net.sf.saxon.trans.XPathException; |
| 16 |
import net.sf.saxon.type.SchemaType; |
| 17 |
import net.sf.saxon.type.SimpleType; |
| 18 |
|
| 19 |
import java.util.ArrayList; |
| 20 |
import java.util.List; |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public class EventBuffer extends SequenceReceiver { |
| 34 |
|
| 35 |
List<Event> buffer = new ArrayList<>(); |
| 36 |
|
| 37 |
public EventBuffer(PipelineConfiguration pipe){ |
| 38 |
super(pipe); |
| 39 |
} |
| 40 |
|
| 41 |
@Override |
| 42 |
public void startDocument(int properties) throws XPathException { |
| 43 |
buffer.add(new Event.StartDocument(properties)); |
| 44 |
} |
| 45 |
|
| 46 |
@Override |
| 47 |
public void endDocument() throws XPathException { |
| 48 |
buffer.add(new Event.EndDocument()); |
| 49 |
} |
| 50 |
|
| 51 |
@Override |
| 52 |
public void startElement(NodeName elemName, SchemaType typeCode, Location location, int properties) throws XPathException { |
| 53 |
buffer.add(new Event.StartElement(elemName, typeCode, location, properties)); |
| 54 |
} |
| 55 |
|
| 56 |
@Override |
| 57 |
public void namespace(NamespaceBindingSet namespaceBindings, int properties) throws XPathException { |
| 58 |
buffer.add(new Event.Namespace(namespaceBindings, properties)); |
| 59 |
} |
| 60 |
|
| 61 |
@Override |
| 62 |
public void attribute(NodeName attName, SimpleType typeCode, CharSequence value, Location location, int properties) throws XPathException { |
| 63 |
buffer.add(new Event.Attribute(attName, typeCode, location, value, properties)); |
| 64 |
} |
| 65 |
|
| 66 |
@Override |
| 67 |
public void startContent() throws XPathException { |
| 68 |
buffer.add(new Event.StartContent()); |
| 69 |
} |
| 70 |
|
| 71 |
@Override |
| 72 |
public void endElement() throws XPathException { |
| 73 |
buffer.add(new Event.EndElement()); |
| 74 |
} |
| 75 |
|
| 76 |
@Override |
| 77 |
public void characters(CharSequence chars, Location location, int properties) throws XPathException { |
| 78 |
buffer.add(new Event.Text(chars, location, properties)); |
| 79 |
} |
| 80 |
|
| 81 |
@Override |
| 82 |
public void processingInstruction(String name, CharSequence data, Location location, int properties) throws XPathException { |
| 83 |
buffer.add(new Event.ProcessingInstruction(name, data, location, properties)); |
| 84 |
} |
| 85 |
|
| 86 |
@Override |
| 87 |
public void comment(CharSequence content, Location location, int properties) throws XPathException { |
| 88 |
buffer.add(new Event.Comment(content, location, properties)); |
| 89 |
} |
| 90 |
|
| 91 |
@Override |
| 92 |
public void append(Item item, Location location, int properties) throws XPathException { |
| 93 |
buffer.add(new Event.Append(item, location, properties)); |
| 94 |
} |
| 95 |
|
| 96 |
@Override |
| 97 |
public void close() throws XPathException { |
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
public void replay(Receiver out) throws XPathException { |
| 108 |
for (Event event : buffer) { |
| 109 |
event.replay(out); |
| 110 |
} |
| 111 |
} |
| 112 |
} |
| 113 |
|