Java Code Examples for javax.xml.stream.XMLStreamException#getLocation()
The following examples show how to use
javax.xml.stream.XMLStreamException#getLocation() .
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: AbstractStaxXMLReader.java From spring-analysis-note with MIT License | 6 votes |
private void parse() throws SAXException { try { parseInternal(); } catch (XMLStreamException ex) { Locator locator = null; if (ex.getLocation() != null) { locator = new StaxLocator(ex.getLocation()); } SAXParseException saxException = new SAXParseException(ex.getMessage(), locator, ex); if (getErrorHandler() != null) { getErrorHandler().fatalError(saxException); } else { throw saxException; } } }
Example 2
Source File: AbstractStaxXMLReader.java From java-technology-stack with MIT License | 6 votes |
private void parse() throws SAXException { try { parseInternal(); } catch (XMLStreamException ex) { Locator locator = null; if (ex.getLocation() != null) { locator = new StaxLocator(ex.getLocation()); } SAXParseException saxException = new SAXParseException(ex.getMessage(), locator, ex); if (getErrorHandler() != null) { getErrorHandler().fatalError(saxException); } else { throw saxException; } } }
Example 3
Source File: AbstractStaxXMLReader.java From lams with GNU General Public License v2.0 | 6 votes |
private void parse() throws SAXException { try { parseInternal(); } catch (XMLStreamException ex) { Locator locator = null; if (ex.getLocation() != null) { locator = new StaxLocator(ex.getLocation()); } SAXParseException saxException = new SAXParseException(ex.getMessage(), locator, ex); if (getErrorHandler() != null) { getErrorHandler().fatalError(saxException); } else { throw saxException; } } }
Example 4
Source File: AbstractStaxXMLReader.java From spring4-understanding with Apache License 2.0 | 6 votes |
private void parse() throws SAXException { try { parseInternal(); } catch (XMLStreamException ex) { Locator locator = null; if (ex.getLocation() != null) { locator = new StaxLocator(ex.getLocation()); } SAXParseException saxException = new SAXParseException(ex.getMessage(), locator, ex); if (getErrorHandler() != null) { getErrorHandler().fatalError(saxException); } else { throw saxException; } } }
Example 5
Source File: StAXSource.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public void parse() throws SAXException { // parses from a StAX reader and generates SAX events which // go through the repeater and are forwarded to the appropriate // component try { reader.bridge(); } catch( XMLStreamException e ) { // wrap it in a SAXException SAXParseException se = new SAXParseException2( e.getMessage(), null, null, e.getLocation() == null ? -1 : e.getLocation().getLineNumber(), e.getLocation() == null ? -1 : e.getLocation().getColumnNumber(), e); // if the consumer sets an error handler, it is our responsibility // to notify it. if(errorHandler!=null) errorHandler.fatalError(se); // this is a fatal error. Even if the error handler // returns, we will abort anyway. throw se; } finally { try { staxReader.close(); } catch(XMLStreamException xe) { //falls through. Not much can be done. } } }
Example 6
Source File: StAXSource.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void parse() throws SAXException { // parses from a StAX reader and generates SAX events which // go through the repeater and are forwarded to the appropriate // component try { reader.bridge(); } catch( XMLStreamException e ) { // wrap it in a SAXException SAXParseException se = new SAXParseException2( e.getMessage(), null, null, e.getLocation() == null ? -1 : e.getLocation().getLineNumber(), e.getLocation() == null ? -1 : e.getLocation().getColumnNumber(), e); // if the consumer sets an error handler, it is our responsibility // to notify it. if(errorHandler!=null) errorHandler.fatalError(se); // this is a fatal error. Even if the error handler // returns, we will abort anyway. throw se; } finally { try { staxReader.close(); } catch(XMLStreamException xe) { //falls through. Not much can be done. } } }
Example 7
Source File: StAXSource.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public void parse() throws SAXException { // parses from a StAX reader and generates SAX events which // go through the repeater and are forwarded to the appropriate // component try { reader.bridge(); } catch( XMLStreamException e ) { // wrap it in a SAXException SAXParseException se = new SAXParseException2( e.getMessage(), null, null, e.getLocation() == null ? -1 : e.getLocation().getLineNumber(), e.getLocation() == null ? -1 : e.getLocation().getColumnNumber(), e); // if the consumer sets an error handler, it is our responsibility // to notify it. if(errorHandler!=null) errorHandler.fatalError(se); // this is a fatal error. Even if the error handler // returns, we will abort anyway. throw se; } finally { try { staxReader.close(); } catch(XMLStreamException xe) { //falls through. Not much can be done. } } }
Example 8
Source File: StAXSource.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public void parse() throws SAXException { // parses from a StAX reader and generates SAX events which // go through the repeater and are forwarded to the appropriate // component try { reader.bridge(); } catch( XMLStreamException e ) { // wrap it in a SAXException SAXParseException se = new SAXParseException2( e.getMessage(), null, null, e.getLocation() == null ? -1 : e.getLocation().getLineNumber(), e.getLocation() == null ? -1 : e.getLocation().getColumnNumber(), e); // if the consumer sets an error handler, it is our responsibility // to notify it. if(errorHandler!=null) errorHandler.fatalError(se); // this is a fatal error. Even if the error handler // returns, we will abort anyway. throw se; } finally { try { staxReader.close(); } catch(XMLStreamException xe) { //falls through. Not much can be done. } } }
Example 9
Source File: StAXSource.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public void parse() throws SAXException { // parses from a StAX reader and generates SAX events which // go through the repeater and are forwarded to the appropriate // component try { reader.bridge(); } catch( XMLStreamException e ) { // wrap it in a SAXException SAXParseException se = new SAXParseException2( e.getMessage(), null, null, e.getLocation() == null ? -1 : e.getLocation().getLineNumber(), e.getLocation() == null ? -1 : e.getLocation().getColumnNumber(), e); // if the consumer sets an error handler, it is our responsibility // to notify it. if(errorHandler!=null) errorHandler.fatalError(se); // this is a fatal error. Even if the error handler // returns, we will abort anyway. throw se; } finally { try { staxReader.close(); } catch(XMLStreamException xe) { //falls through. Not much can be done. } } }
Example 10
Source File: StAXSource.java From hottub with GNU General Public License v2.0 | 5 votes |
public void parse() throws SAXException { // parses from a StAX reader and generates SAX events which // go through the repeater and are forwarded to the appropriate // component try { reader.bridge(); } catch( XMLStreamException e ) { // wrap it in a SAXException SAXParseException se = new SAXParseException2( e.getMessage(), null, null, e.getLocation() == null ? -1 : e.getLocation().getLineNumber(), e.getLocation() == null ? -1 : e.getLocation().getColumnNumber(), e); // if the consumer sets an error handler, it is our responsibility // to notify it. if(errorHandler!=null) errorHandler.fatalError(se); // this is a fatal error. Even if the error handler // returns, we will abort anyway. throw se; } finally { try { staxReader.close(); } catch(XMLStreamException xe) { //falls through. Not much can be done. } } }
Example 11
Source File: StAXSource.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public void parse() throws SAXException { // parses from a StAX reader and generates SAX events which // go through the repeater and are forwarded to the appropriate // component try { reader.bridge(); } catch( XMLStreamException e ) { // wrap it in a SAXException SAXParseException se = new SAXParseException2( e.getMessage(), null, null, e.getLocation() == null ? -1 : e.getLocation().getLineNumber(), e.getLocation() == null ? -1 : e.getLocation().getColumnNumber(), e); // if the consumer sets an error handler, it is our responsibility // to notify it. if(errorHandler!=null) errorHandler.fatalError(se); // this is a fatal error. Even if the error handler // returns, we will abort anyway. throw se; } finally { try { staxReader.close(); } catch(XMLStreamException xe) { //falls through. Not much can be done. } } }
Example 12
Source File: StAXSource.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public void parse() throws SAXException { // parses from a StAX reader and generates SAX events which // go through the repeater and are forwarded to the appropriate // component try { reader.bridge(); } catch( XMLStreamException e ) { // wrap it in a SAXException SAXParseException se = new SAXParseException2( e.getMessage(), null, null, e.getLocation() == null ? -1 : e.getLocation().getLineNumber(), e.getLocation() == null ? -1 : e.getLocation().getColumnNumber(), e); // if the consumer sets an error handler, it is our responsibility // to notify it. if(errorHandler!=null) errorHandler.fatalError(se); // this is a fatal error. Even if the error handler // returns, we will abort anyway. throw se; } finally { try { staxReader.close(); } catch(XMLStreamException xe) { //falls through. Not much can be done. } } }
Example 13
Source File: MappedXMLStreamReaderTest.java From jettison with Apache License 2.0 | 5 votes |
public void testExceptionLocation() throws Exception { String str = "{\"junk"; Configuration config = new Configuration(); MappedXMLInputFactory factory = new MappedXMLInputFactory(config); try { factory.createXMLStreamReader(new StringReader(str)); fail("Exception expected"); } catch (XMLStreamException ex) { Location loc = ex.getLocation(); assertNotNull(loc); assertEquals(0, loc.getLineNumber()); assertEquals(6, loc.getColumnNumber()); } }
Example 14
Source File: AntXmlParser.java From rich-test-results with Apache License 2.0 | 5 votes |
/** * Returns the list of {@link TestSuite} objects parsed from the Ant XML format input stream. */ public ImmutableList<TestSuite> parse(InputStream in, Charset encoding) throws XmlParseException { try { XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(in, encoding.name()); try { while (xmlStreamReader.hasNext()) { int next = xmlStreamReader.next(); if (next == XMLStreamConstants.END_DOCUMENT) { break; } if (!xmlStreamReader.hasName()) { continue; } String tagName = xmlStreamReader.getName().toString(); if (xmlStreamReader.isStartElement()) { switch (tagName) { case "testsuites": return parseSuites(xmlStreamReader); case "testsuite": return ImmutableList.of(parseSuite(xmlStreamReader)); default: handleUnsupportedElement("root", tagName); } } } } finally { xmlStreamReader.close(); } } catch (XMLStreamException e) { if (e.getLocation() != null) { throw new XmlParseException(e.getMessage(), e); } else { throw new RuntimeException(e); } } throw new XmlParseException("No testsuites or testsuite element found."); }
Example 15
Source File: ParsingException.java From keycloak with Apache License 2.0 | 4 votes |
public ParsingException(XMLStreamException xmle) { super(xmle); location = xmle.getLocation(); }