Java Code Examples for javax.xml.stream.events.StartDocument#encodingSet()
The following examples show how to use
javax.xml.stream.events.StartDocument#encodingSet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StaxEventXMLReader.java From spring-analysis-note with MIT License | 4 votes |
private void handleStartDocument(final XMLEvent event) throws SAXException { if (event.isStartDocument()) { StartDocument startDocument = (StartDocument) event; String xmlVersion = startDocument.getVersion(); if (StringUtils.hasLength(xmlVersion)) { this.xmlVersion = xmlVersion; } if (startDocument.encodingSet()) { this.encoding = startDocument.getCharacterEncodingScheme(); } } if (getContentHandler() != null) { final Location location = event.getLocation(); getContentHandler().setDocumentLocator(new Locator2() { @Override public int getColumnNumber() { return (location != null ? location.getColumnNumber() : -1); } @Override public int getLineNumber() { return (location != null ? location.getLineNumber() : -1); } @Override @Nullable public String getPublicId() { return (location != null ? location.getPublicId() : null); } @Override @Nullable public String getSystemId() { return (location != null ? location.getSystemId() : null); } @Override public String getXMLVersion() { return xmlVersion; } @Override @Nullable public String getEncoding() { return encoding; } }); getContentHandler().startDocument(); } }
Example 2
Source File: StaxEventXMLReader.java From java-technology-stack with MIT License | 4 votes |
private void handleStartDocument(final XMLEvent event) throws SAXException { if (event.isStartDocument()) { StartDocument startDocument = (StartDocument) event; String xmlVersion = startDocument.getVersion(); if (StringUtils.hasLength(xmlVersion)) { this.xmlVersion = xmlVersion; } if (startDocument.encodingSet()) { this.encoding = startDocument.getCharacterEncodingScheme(); } } if (getContentHandler() != null) { final Location location = event.getLocation(); getContentHandler().setDocumentLocator(new Locator2() { @Override public int getColumnNumber() { return (location != null ? location.getColumnNumber() : -1); } @Override public int getLineNumber() { return (location != null ? location.getLineNumber() : -1); } @Override @Nullable public String getPublicId() { return (location != null ? location.getPublicId() : null); } @Override @Nullable public String getSystemId() { return (location != null ? location.getSystemId() : null); } @Override public String getXMLVersion() { return xmlVersion; } @Override @Nullable public String getEncoding() { return encoding; } }); getContentHandler().startDocument(); } }
Example 3
Source File: StaxEventXMLReader.java From lams with GNU General Public License v2.0 | 4 votes |
private void handleStartDocument(final XMLEvent event) throws SAXException { if (event.isStartDocument()) { StartDocument startDocument = (StartDocument) event; String xmlVersion = startDocument.getVersion(); if (StringUtils.hasLength(xmlVersion)) { this.xmlVersion = xmlVersion; } if (startDocument.encodingSet()) { this.encoding = startDocument.getCharacterEncodingScheme(); } } if (getContentHandler() != null) { final Location location = event.getLocation(); getContentHandler().setDocumentLocator(new Locator2() { @Override public int getColumnNumber() { return (location != null ? location.getColumnNumber() : -1); } @Override public int getLineNumber() { return (location != null ? location.getLineNumber() : -1); } @Override public String getPublicId() { return (location != null ? location.getPublicId() : null); } @Override public String getSystemId() { return (location != null ? location.getSystemId() : null); } @Override public String getXMLVersion() { return xmlVersion; } @Override public String getEncoding() { return encoding; } }); getContentHandler().startDocument(); } }
Example 4
Source File: StaxEventXMLReader.java From spring4-understanding with Apache License 2.0 | 4 votes |
private void handleStartDocument(final XMLEvent event) throws SAXException { if (event.isStartDocument()) { StartDocument startDocument = (StartDocument) event; String xmlVersion = startDocument.getVersion(); if (StringUtils.hasLength(xmlVersion)) { this.xmlVersion = xmlVersion; } if (startDocument.encodingSet()) { this.encoding = startDocument.getCharacterEncodingScheme(); } } if (getContentHandler() != null) { final Location location = event.getLocation(); getContentHandler().setDocumentLocator(new Locator2() { @Override public int getColumnNumber() { return (location != null ? location.getColumnNumber() : -1); } @Override public int getLineNumber() { return (location != null ? location.getLineNumber() : -1); } @Override public String getPublicId() { return (location != null ? location.getPublicId() : null); } @Override public String getSystemId() { return (location != null ? location.getSystemId() : null); } @Override public String getXMLVersion() { return xmlVersion; } @Override public String getEncoding() { return encoding; } }); getContentHandler().startDocument(); } }