@Override public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException { this.eventWriter.add(this.eventFactory.createAttribute(prefix, namespaceURI, localName, value)); }
@Override protected void endDocumentInternal() throws XMLStreamException { this.eventWriter.add(this.eventFactory.createEndDocument()); }
@Override protected void cDataInternal(String data) throws XMLStreamException { this.eventWriter.add(this.eventFactory.createCData(data)); }
private int moveToNextElement(XMLStreamReader streamReader) throws XMLStreamException { int event = streamReader.getEventType(); while (event != XMLStreamReader.START_ELEMENT && event != XMLStreamReader.END_DOCUMENT) { event = streamReader.next(); } return event; }
@Override protected XMLInputFactory createXmlInputFactory() { XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, true); return inputFactory; } };
/** * Check if the reader is closed, and throws a {@code XMLStreamException} if so. * @throws XMLStreamException if the reader is closed * @see #close() */ protected void checkIfClosed() throws XMLStreamException { if (this.closed) { throw new XMLStreamException("XMLEventReader has been closed"); } }
JaxbResponseConverter(JAXBContext context, Class<T> type) { this.context = context; this.type = type; // Prevent XML External Entity attacks (XXE). xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); xmlInputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false); }
@Override public int getLineNumber() { return (location != null ? location.getLineNumber() : -1); } @Override
@Override public int getColumnNumber() { return (location != null ? location.getColumnNumber() : -1); } @Override
@Override protected void charactersInternal(String data) throws XMLStreamException { this.eventWriter.add(this.eventFactory.createCharacters(data)); }
@Override protected void startDocumentInternal() throws XMLStreamException { this.eventWriter.add(this.eventFactory.createStartDocument()); }
@Override protected void commentInternal(String comment) throws XMLStreamException { this.eventWriter.add(this.eventFactory.createComment(comment)); }
@Override protected void processingInstructionInternal(String target, String data) throws XMLStreamException { this.eventWriter.add(this.eventFactory.createProcessingInstruction(target, data)); }
@Override protected void ignorableWhitespaceInternal(String data) throws XMLStreamException { this.eventWriter.add(this.eventFactory.createIgnorableSpace(data)); }
/** * Construct a new instance of the {@code StaxEventContentHandler} that writes to the * given {@code XMLEventWriter}. A default {@code XMLEventFactory} will be created. * @param eventWriter the writer to write events to */ public StaxEventHandler(XMLEventWriter eventWriter) { this.eventFactory = XMLEventFactory.newInstance(); this.eventWriter = eventWriter; }
@Override public int getLineNumber() { return (location != null ? location.getLineNumber() : -1); } @Override
@Override public int getColumnNumber() { return this.location.getColumnNumber(); } }
@Override public void writeAttribute(String localName, String value) throws XMLStreamException { this.eventWriter.add(this.eventFactory.createAttribute(localName, value)); }
@Override public int getColumnNumber() { return (location != null ? location.getColumnNumber() : -1); } @Override