/** * Constructs a DOM4J Entity from the provided event stream. The stream must * be positioned before an {@link EntityReference}event. * * @param reader * The event stream from which to read the {@link * EntityReference}. * * @return The {@link org.dom4j.Entity}that was read from the stream. * * @throws XMLStreamException * If an error occured reading events from the stream, or the * stream was not positioned before an {@link EntityReference} * event. */ public Entity readEntityReference(XMLEventReader reader) throws XMLStreamException { XMLEvent event = reader.peek(); if (event.isEntityReference()) { EntityReference entityRef = (EntityReference) reader.nextEvent(); return createEntity(entityRef); } else { throw new XMLStreamException("Expected EntityRef event, found: " + event); } }
@Override public boolean isEntityReference() { return this.event.isEntityReference(); }
@Override public boolean isEntityReference() { return delegate.isEntityReference(); }
@Override public boolean isEntityReference() { return delegate.isEntityReference(); }
@Override public boolean isEntityReference() { return this.event.isEntityReference(); }
} else if (event.isProcessingInstruction()) { return readProcessingInstruction(reader); } else if (event.isEntityReference()) { return readEntityReference(reader); } else if (event.isAttribute()) {
current.addContent(comment); } else if (event.isEntityReference()) { current.addContent(factory.entityRef( ((javax.xml.stream.events.EntityReference)event).getName()));
public Entry(String key, String value) { super(); this.key = key; this.value = value; try { XMLEventReader xer = fac.createXMLEventReader(new StringReader(wrapInRootElement(value))); while (xer.hasNext()) { XMLEvent event = xer.nextEvent(); if (event.isEntityReference()) { EntityReference er = (EntityReference) event; processingEnv.getMessager().printMessage(Kind.ERROR, "Entity " + er.getName() + " found, but not allowed.", e); } } } catch (XMLStreamException f) { value = ""; processingEnv.getMessager().printMessage(Kind.WARNING, f.getMessage(), e); } }
/** * Constructs a DOM4J Entity from the provided event stream. The stream must * be positioned before an {@link EntityReference}event. * * @param reader * The event stream from which to read the {@link * EntityReference}. * * @return The {@link org.dom4j.Entity}that was read from the stream. * * @throws XMLStreamException * If an error occured reading events from the stream, or the * stream was not positioned before an {@link EntityReference} * event. */ public Entity readEntityReference(XMLEventReader reader) throws XMLStreamException { XMLEvent event = reader.peek(); if (event.isEntityReference()) { EntityReference entityRef = (EntityReference) reader.nextEvent(); return createEntity(entityRef); } else { throw new XMLStreamException("Expected EntityRef event, found: " + event); } }
/** * Constructs a DOM4J Entity from the provided event stream. The stream must * be positioned before an {@link EntityReference}event. * * @param reader * The event stream from which to read the {@link * EntityReference}. * * @return The {@link org.dom4j.Entity}that was read from the stream. * * @throws XMLStreamException * If an error occured reading events from the stream, or the * stream was not positioned before an {@linkEntityReference} * event. */ public Entity readEntityReference(XMLEventReader reader) throws XMLStreamException { XMLEvent event = reader.peek(); if (event.isEntityReference()) { EntityReference entityRef = (EntityReference) reader.nextEvent(); return createEntity(entityRef); } else { throw new XMLStreamException("Expected EntityRef event, found: " + event); } }
/** * Constructs a DOM4J Entity from the provided event stream. The stream must * be positioned before an {@link EntityReference}event. * * @param reader * The event stream from which to read the {@link * EntityReference}. * * @return The {@link org.dom4j.Entity}that was read from the stream. * * @throws XMLStreamException * If an error occured reading events from the stream, or the * stream was not positioned before an {@linkEntityReference} * event. */ public Entity readEntityReference(XMLEventReader reader) throws XMLStreamException { XMLEvent event = reader.peek(); if (event.isEntityReference()) { EntityReference entityRef = (EntityReference) reader.nextEvent(); return createEntity(entityRef); } else { throw new XMLStreamException("Expected EntityRef event, found: " + event); } }
/** * Constructs a DOM4J Entity from the provided event stream. The stream must * be positioned before an {@link EntityReference}event. * * @param reader * The event stream from which to read the {@link * EntityReference}. * * @return The {@link org.dom4j.Entity}that was read from the stream. * * @throws XMLStreamException * If an error occured reading events from the stream, or the * stream was not positioned before an {@linkEntityReference} * event. */ public Entity readEntityReference(XMLEventReader reader) throws XMLStreamException { XMLEvent event = reader.peek(); if (event.isEntityReference()) { EntityReference entityRef = (EntityReference) reader.nextEvent(); return createEntity(entityRef); } else { throw new XMLStreamException("Expected EntityRef event, found: " + event); } }
/** * Constructs a DOM4J Entity from the provided event stream. The stream must * be positioned before an {@link EntityReference}event. * * @param reader * The event stream from which to read the {@link * EntityReference}. * * @return The {@link org.dom4j.Entity}that was read from the stream. * * @throws XMLStreamException * If an error occured reading events from the stream, or the * stream was not positioned before an {@linkEntityReference} * event. */ public Entity readEntityReference(XMLEventReader reader) throws XMLStreamException { XMLEvent event = reader.peek(); if (event.isEntityReference()) { EntityReference entityRef = (EntityReference) reader.nextEvent(); return createEntity(entityRef); } else { throw new XMLStreamException("Expected EntityRef event, found: " + event); } }
/** * Constructs a DOM4J Entity from the provided event stream. The stream must * be positioned before an {@link EntityReference}event. * * @param reader * The event stream from which to read the {@link * EntityReference}. * * @return The {@link org.dom4j.Entity}that was read from the stream. * * @throws XMLStreamException * If an error occured reading events from the stream, or the * stream was not positioned before an {@linkEntityReference} * event. */ public Entity readEntityReference(XMLEventReader reader) throws XMLStreamException { XMLEvent event = reader.peek(); if (event.isEntityReference()) { EntityReference entityRef = (EntityReference) reader.nextEvent(); return createEntity(entityRef); } else { throw new XMLStreamException("Expected EntityRef event, found: " + event); } }
public String getText() { requiredEventType(CHARACTERS, DTD, ENTITY_REFERENCE, COMMENT, SPACE); if (current.isCharacters()) { return current.asCharacters().getData(); } else if (current.isEntityReference()) { return ((EntityReference)current).getDeclaration().getReplacementText(); } else if (current instanceof DTD) { // no idea what to do here return ""; } else if (current instanceof Comment) { return ((Comment) current).getText(); } else { // should never get here throw new IllegalStateException("Unexpected element type " + current); } }
public String getText() { requiredEventType(CHARACTERS, DTD, ENTITY_REFERENCE, COMMENT, SPACE); if (current.isCharacters()) { return current.asCharacters().getData(); } else if (current.isEntityReference()) { return ((EntityReference)current).getDeclaration().getReplacementText(); } else if (current instanceof DTD) { // no idea what to do here return ""; } else if (current instanceof Comment) { return ((Comment) current).getText(); } else { // should never get here throw new IllegalStateException("Unexpected element type " + current); } }
/** * Consumes all StAX events and passes them on to the content handler */ public void parse(XMLEventReader xmlReader) throws XMLStreamException, SAXException { while (xmlReader.hasNext()) { XMLEvent e = xmlReader.nextEvent(); if (e.isStartDocument()) handler.startDocument(); else if (e.isEndDocument()) handler.endDocument(); else if (e.isStartElement()) emitSE(e.asStartElement()); else if (e.isEndElement()) emitEE(e.asEndElement()); else if (e.isProcessingInstruction()) emitPi((ProcessingInstruction) e); else if (e.isCharacters()) emitChars(e.asCharacters()); else if (e.isAttribute()) emitAttr((Attribute) e); else if (e.isEntityReference()) emitEnt((EntityDeclaration) e); else if (e.isNamespace()) emitNS((Namespace) e); else if (e instanceof Comment) emitComment((Comment) e); else if (e instanceof DTD) emitDTD((DTD) e); else { //System.err.println("Unknown / unhandled event type " + e); //throw new SAXException("Unknown / unhandled event type " + e); } } }
/** * Consumes all StAX events and passes them on to the content handler */ public void parse(XMLEventReader xmlReader) throws XMLStreamException, SAXException { while (xmlReader.hasNext()) { XMLEvent e = xmlReader.nextEvent(); if (e.isStartDocument()) handler.startDocument(); else if (e.isEndDocument()) handler.endDocument(); else if (e.isStartElement()) emitSE(e.asStartElement()); else if (e.isEndElement()) emitEE(e.asEndElement()); else if (e.isProcessingInstruction()) emitPi((ProcessingInstruction) e); else if (e.isCharacters()) emitChars(e.asCharacters()); else if (e.isAttribute()) emitAttr((Attribute) e); else if (e.isEntityReference()) emitEnt((EntityDeclaration) e); else if (e.isNamespace()) emitNS((Namespace) e); else if (e instanceof Comment) emitComment((Comment) e); else if (e instanceof DTD) emitDTD((DTD) e); else { //System.err.println("Unknown / unhandled event type " + e); //throw new SAXException("Unknown / unhandled event type " + e); } } }
/** * Consumes all StAX events and passes them on to the content handler */ public void parse(XMLEventReader xmlReader) throws XMLStreamException, SAXException { while (xmlReader.hasNext()) { XMLEvent e = xmlReader.nextEvent(); if (e.isStartDocument()) handler.startDocument(); else if (e.isEndDocument()) handler.endDocument(); else if (e.isStartElement()) emitSE(e.asStartElement()); else if (e.isEndElement()) emitEE(e.asEndElement()); else if (e.isProcessingInstruction()) emitPi((ProcessingInstruction) e); else if (e.isCharacters()) emitChars(e.asCharacters()); else if (e.isAttribute()) emitAttr((Attribute) e); else if (e.isEntityReference()) emitEnt((EntityDeclaration) e); else if (e.isNamespace()) emitNS((Namespace) e); else if (e instanceof Comment) emitComment((Comment) e); else if (e instanceof DTD) emitDTD((DTD) e); else { //System.err.println("Unknown / unhandled event type " + e); //throw new SAXException("Unknown / unhandled event type " + e); } } }
/** * Handle the next event * @return true if the end of the document has been reached. (ie, we are back at level 0) * @throws SAXException */ private void handleXMLEvent(XMLEvent e) throws SAXException { if (e.isStartDocument()) handler.startDocument(); else if (e.isEndDocument()) handler.endDocument(); else if (e.isStartElement()) emitSE(e.asStartElement()); else if (e.isEndElement()) emitEE(e.asEndElement()); else if (e.isProcessingInstruction()) emitPi((ProcessingInstruction) e); else if (e.isCharacters()) emitChars(e.asCharacters()); else if (e.isAttribute()) emitAttr((Attribute) e); else if (e.isEntityReference()) emitEnt((EntityDeclaration) e); else if (e.isNamespace()) emitNS((Namespace) e); else if (e instanceof Comment) emitComment((Comment) e); else if (e instanceof DTD) emitDTD((DTD) e); else { //System.err.println("Unknown / unhandled event type " + e); //throw new SAXException("Unknown / unhandled event type " + e); } }