/** * Initialize the pool. * * @throws XMLParserException thrown if pool can not be initialized, * or if it is already initialized * **/ public synchronized void initialize() throws XMLParserException { if (initialized) { throw new XMLParserException("Parser pool was already initialized"); } initializeFactory(); initialized = true; }
/** {@inheritDoc} */ public Document parse(InputStream input) throws XMLParserException { DocumentBuilder builder = getBuilder(); try { Document document = builder.parse(input); return document; } catch (SAXException e) { throw new XMLParserException("Invalid XML", e); } catch (IOException e) { throw new XMLParserException("Unable to read XML from input stream", e); } finally { returnBuilder(builder); } }
/** {@inheritDoc} */ public Document parse(InputStream input) throws XMLParserException { DocumentBuilder builder = getBuilder(); try { Document document = builder.parse(input); return document; } catch (SAXException e) { throw new XMLParserException("Invalid XML", e); } catch (IOException e) { throw new XMLParserException("Unable to read XML from input stream", e); } finally { returnBuilder(builder); } }
/** {@inheritDoc} */ public Document parse(InputStream input) throws XMLParserException { DocumentBuilder builder = getBuilder(); try { Document document = builder.parse(input); return document; } catch (SAXException e) { throw new XMLParserException("Invalid XML", e); } catch (IOException e) { throw new XMLParserException("Unable to read XML from input stream", e); } finally { returnBuilder(builder); } }
/** * Creates a new document builder. * * @return newly created document builder * * @throws XMLParserException thrown if their is a configuration error with the builder factory */ protected DocumentBuilder createBuilder() throws XMLParserException { try { DocumentBuilder builder = builderFactory.newDocumentBuilder(); if (entityResolver != null) { builder.setEntityResolver(entityResolver); } if (errorHandler != null) { builder.setErrorHandler(errorHandler); } return builder; } catch (ParserConfigurationException e) { log.error("Unable to create new document builder", e); throw new XMLParserException("Unable to create new document builder", e); } }
/** {@inheritDoc} */ public Document parse(InputStream input) throws XMLParserException { DocumentBuilder builder = getBuilder(); try { Document document = builder.parse(input); return document; } catch (SAXException e) { throw new XMLParserException("Invalid XML", e); } catch (IOException e) { throw new XMLParserException("Unable to read XML from input stream", e); } finally { returnBuilder(builder); } }
/** {@inheritDoc} */ public Document parse(Reader input) throws XMLParserException { DocumentBuilder builder = getBuilder(); try { Document document = builder.parse(new InputSource(input)); return document; } catch (SAXException e) { throw new XMLParserException("Invalid XML", e); } catch (IOException e) { throw new XMLParserException("Unable to read XML from input stream", e); } finally { returnBuilder(builder); } }
/** * Creates a new document builder. * * @return newly created document builder * * @throws XMLParserException thrown if their is a configuration error with the builder factory */ protected DocumentBuilder createBuilder() throws XMLParserException { try { DocumentBuilder builder = builderFactory.newDocumentBuilder(); if (entityResolver != null) { builder.setEntityResolver(entityResolver); } if (errorHandler != null) { builder.setErrorHandler(errorHandler); } return builder; } catch (ParserConfigurationException e) { log.error("Unable to create new document builder", e); throw new XMLParserException("Unable to create new document builder", e); } }
/** {@inheritDoc} */ public Document parse(Reader input) throws XMLParserException { DocumentBuilder builder = getBuilder(); try { Document document = builder.parse(new InputSource(input)); return document; } catch (SAXException e) { throw new XMLParserException("Invalid XML", e); } catch (IOException e) { throw new XMLParserException("Unable to read XML from input stream", e); } finally { returnBuilder(builder); } }
/** {@inheritDoc} */ public Document parse(Reader input) throws XMLParserException { DocumentBuilder builder = getBuilder(); try { Document document = builder.parse(new InputSource(input)); return document; } catch (SAXException e) { throw new XMLParserException("Invalid XML", e); } catch (IOException e) { throw new XMLParserException("Unable to read XML from input stream", e); } finally { returnBuilder(builder); } }
/** {@inheritDoc} */ public Document parse(Reader input) throws XMLParserException { DocumentBuilder builder = getBuilder(); try { Document document = builder.parse(new InputSource(input)); return document; } catch (SAXException e) { throw new XMLParserException("Invalid XML", e); } catch (IOException e) { throw new XMLParserException("Unable to read XML from input stream", e); } finally { returnBuilder(builder); } }
/** * Initialize the pool. * * @throws XMLParserException thrown if pool can not be initialized, * or if it is already initialized * **/ public synchronized void initialize() throws XMLParserException { if (initialized) { throw new XMLParserException("Parser pool was already initialized"); } initializeFactory(); initialized = true; }
/** * Creates a new document builder. * * @return newly created document builder * * @throws XMLParserException thrown if their is a configuration error with the builder factory */ protected DocumentBuilder createBuilder() throws XMLParserException { try { DocumentBuilder builder = builderFactory.newDocumentBuilder(); if (entityResolver != null) { builder.setEntityResolver(entityResolver); } if (errorHandler != null) { builder.setErrorHandler(errorHandler); } return builder; } catch (ParserConfigurationException e) { log.error("Unable to create new document builder", e); throw new XMLParserException("Unable to create new document builder", e); } }
/** * Creates a new document builder. * * @return newly created document builder * * @throws XMLParserException thrown if their is a configuration error with the builder factory */ protected DocumentBuilder createBuilder() throws XMLParserException { try { DocumentBuilder builder = builderFactory.newDocumentBuilder(); if (entityResolver != null) { builder.setEntityResolver(entityResolver); } if (errorHandler != null) { builder.setErrorHandler(errorHandler); } return builder; } catch (ParserConfigurationException e) { log.error("Unable to create new document builder", e); throw new XMLParserException("Unable to create new document builder", e); } }
/** {@inheritDoc} */ public DocumentBuilder getBuilder() throws XMLParserException { DocumentBuilder builder = null; if (!initialized) { throw new XMLParserException("Parser pool has not been initialized"); } synchronized(builderPool) { if (!builderPool.isEmpty()) { builder = builderPool.pop().get(); } } // Will be null if either the stack was empty, or the SoftReference // has been garbage-collected if (builder == null) { builder = createBuilder(); } if (builder != null) { return new DocumentBuilderProxy(builder, this); } return null; }
/** {@inheritDoc} */ public DocumentBuilder getBuilder() throws XMLParserException { DocumentBuilder builder = null; if (!initialized) { throw new XMLParserException("Parser pool has not been initialized"); } synchronized(builderPool) { if (!builderPool.isEmpty()) { builder = builderPool.pop().get(); } } // Will be null if either the stack was empty, or the SoftReference // has been garbage-collected if (builder == null) { builder = createBuilder(); } if (builder != null) { return new DocumentBuilderProxy(builder, this); } return null; }
throw new XMLParserException("Unable to resolve namespace prefix " + namespacePrefix + " found on element " + getNodeQName(domElement)); namespaceURI = lookupNamespaceURI(upperNamespaceSearchBound, null, namespacePrefix); if (namespaceURI == null) { throw new XMLParserException("Unable to resolve namespace prefix " + namespacePrefix + " found on attribute " + getNodeQName(attributeNode) + " found on element " + getNodeQName(domElement));
throw new XMLParserException("Unable to resolve namespace prefix " + namespacePrefix + " found on element " + getNodeQName(domElement)); namespaceURI = lookupNamespaceURI(upperNamespaceSearchBound, null, namespacePrefix); if (namespaceURI == null) { throw new XMLParserException("Unable to resolve namespace prefix " + namespacePrefix + " found on attribute " + getNodeQName(attributeNode) + " found on element " + getNodeQName(domElement));
final EntitiesDescriptor ed = (EntitiesDescriptor) o; if (ed.getEntityDescriptors() == null) { throw new XMLParserException("EntityDescriptors is null"); throw new XMLParserException("EntityDescriptors is empty");