private void parse(Reader in, String publicId, String systemId) throws IOException, SAXException { ExpatParser parser = new ExpatParser( ExpatParser.CHARACTER_ENCODING, this, processNamespaces, publicId, systemId ); parser.parseDocument(in); }
if (reader != null) { try { entityParser.append("<externalEntity>"); entityParser.parseFragment(reader); entityParser.append("</externalEntity>"); } finally { IoUtils.closeQuietly(reader); if (in != null) { try { entityParser.append("<externalEntity>" .getBytes(entityParser.encoding)); entityParser.parseFragment(in); entityParser.append("</externalEntity>" .getBytes(entityParser.encoding)); } finally { in = openUrl(systemId); try { entityParser.append("<externalEntity>" .getBytes(entityParser.encoding)); entityParser.parseFragment(in); entityParser.append("</externalEntity>" .getBytes(entityParser.encoding)); } finally {
/** * Parses XML from the given input stream. */ private void parseFragment(InputStream in) throws IOException, SAXException { byte[] buffer = new byte[BUFFER_SIZE]; int length; while ((length = in.read(buffer)) != -1) { try { appendBytes(this.pointer, buffer, 0, length); } catch (ExpatException e) { throw new ParseException(e.getMessage(), this.locator); } } }
/** * Parses an XML document from the given input stream. */ /*package*/ void parseDocument(InputStream in) throws IOException, SAXException { startDocument(); parseFragment(in); finish(); endDocument(); }
String encoding = pickEncoding(inputSource); long pointer = createEntityParser(this.pointer, context); try { EntityParser entityParser = new EntityParser(encoding, xmlReader, inputSource.getSystemId()); parseExternalEntity(entityParser, inputSource); } finally { releaseParser(pointer);
/** * Indicate that we're finished parsing. * * @throws SAXException if the xml is incomplete */ /*package*/ void finish() throws SAXException { try { appendString(this.pointer, "", true); } catch (ExpatException e) { throw new ParseException(e.getMessage(), this.locator); } }
/** * Parses XML from the given Reader. */ private void parseFragment(Reader in) throws IOException, SAXException { char[] buffer = new char[BUFFER_SIZE / 2]; int length; while ((length = in.read(buffer)) != -1) { try { appendChars(this.pointer, buffer, 0, length); } catch (ExpatException e) { throw new ParseException(e.getMessage(), locator); } } }
/** * Appends part of an XML document. This parser will parse the given XML to * the extent possible and dispatch to the appropriate methods. * * @param xml a whole or partial snippet of XML * @throws SAXException if an error occurs during parsing */ /*package*/ void append(byte[] xml) throws SAXException { append(xml, 0, xml.length); }
@Override void endElement(String uri, String localName, String qName) throws SAXException { if (--depth > 0) { super.endElement(uri, localName, qName); } }
/** * Clones the current attributes so they can be used outside of * startElement(). */ /*package*/ Attributes cloneAttributes() { if (!inStartElement) { throw new IllegalStateException(OUTSIDE_START_ELEMENT); } if (attributeCount == 0) { return ClonedAttributes.EMPTY; } long clonePointer = cloneAttributes(this.attributePointer, this.attributeCount); return new ClonedAttributes(pointer, clonePointer, attributeCount); }
private static native int column(long pointer);
/** * Parses an XML Document from the given reader. */ /*package*/ void parseDocument(Reader in) throws IOException, SAXException { startDocument(); parseFragment(in); finish(); endDocument(); }
String encoding = pickEncoding(inputSource); long pointer = createEntityParser(this.pointer, context); try { EntityParser entityParser = new EntityParser(encoding, xmlReader, inputSource.getSystemId()); parseExternalEntity(entityParser, inputSource); } finally { releaseParser(pointer);
/** * Appends part of an XML document. This parser will parse the given XML to * the extent possible and dispatch to the appropriate methods. * * @param xml a whole or partial snippet of XML * @throws SAXException if an error occurs during parsing */ /*package*/ void append(String xml) throws SAXException { try { appendString(this.pointer, xml, false); } catch (ExpatException e) { throw new ParseException(e.getMessage(), this.locator); } }
/** * Appends part of an XML document. This parser will parse the given XML to * the extent possible and dispatch to the appropriate methods. * * @param xml a whole or partial snippet of XML * @param offset into the char[] * @param length of characters to use * @throws SAXException if an error occurs during parsing */ /*package*/ void append(char[] xml, int offset, int length) throws SAXException { try { appendChars(this.pointer, xml, offset, length); } catch (ExpatException e) { throw new ParseException(e.getMessage(), this.locator); } }
/** * Appends part of an XML document. This parser will parse the given XML to * the extent possible and dispatch to the appropriate methods. * * @param xml a whole or partial snippet of XML * @throws SAXException if an error occurs during parsing */ /*package*/ void append(byte[] xml) throws SAXException { append(xml, 0, xml.length); }
@Override void endElement(String uri, String localName, String qName) throws SAXException { if (--depth > 0) { super.endElement(uri, localName, qName); } }
/** * Clones the current attributes so they can be used outside of * startElement(). */ /*package*/ Attributes cloneAttributes() { if (!inStartElement) { throw new IllegalStateException(OUTSIDE_START_ELEMENT); } if (attributeCount == 0) { return ClonedAttributes.EMPTY; } long clonePointer = cloneAttributes(this.attributePointer, this.attributeCount); return new ClonedAttributes(pointer, clonePointer, attributeCount); }
private static native int column(long pointer);
/** * Parses an XML Document from the given reader. */ /*package*/ void parseDocument(Reader in) throws IOException, SAXException { startDocument(); parseFragment(in); finish(); endDocument(); }