Search in sources :

Example 1 with ExpatReader

use of org.apache.harmony.xml.ExpatReader in project android_frameworks_base by ParanoidAndroid.

the class Xml method parse.

/**
     * Parses xml from the given input stream and fires events on the given SAX
     * handler.
     */
public static void parse(InputStream in, Encoding encoding, ContentHandler contentHandler) throws IOException, SAXException {
    XMLReader reader = new ExpatReader();
    reader.setContentHandler(contentHandler);
    InputSource source = new InputSource(in);
    source.setEncoding(encoding.expatName);
    reader.parse(source);
}
Also used : InputSource(org.xml.sax.InputSource) ExpatReader(org.apache.harmony.xml.ExpatReader) XMLReader(org.xml.sax.XMLReader)

Example 2 with ExpatReader

use of org.apache.harmony.xml.ExpatReader in project android_frameworks_base by ParanoidAndroid.

the class Xml method parse.

/**
     * Parses the given xml string and fires events on the given SAX handler.
     */
public static void parse(String xml, ContentHandler contentHandler) throws SAXException {
    try {
        XMLReader reader = new ExpatReader();
        reader.setContentHandler(contentHandler);
        reader.parse(new InputSource(new StringReader(xml)));
    } catch (IOException e) {
        throw new AssertionError(e);
    }
}
Also used : InputSource(org.xml.sax.InputSource) ExpatReader(org.apache.harmony.xml.ExpatReader) StringReader(java.io.StringReader) IOException(java.io.IOException) XMLReader(org.xml.sax.XMLReader)

Example 3 with ExpatReader

use of org.apache.harmony.xml.ExpatReader in project robovm by robovm.

the class ExpatSaxParserTest method parse.

/**
     * Parses xml from the given input stream and fires events on the given SAX
     * handler.
     */
private static void parse(InputStream in, Encoding encoding, ContentHandler contentHandler) throws IOException, SAXException {
    try {
        XMLReader reader = new ExpatReader();
        reader.setContentHandler(contentHandler);
        InputSource source = new InputSource(in);
        source.setEncoding(encoding.expatName);
        reader.parse(source);
    } catch (IOException e) {
        throw new AssertionError(e);
    }
}
Also used : InputSource(org.xml.sax.InputSource) ExpatReader(org.apache.harmony.xml.ExpatReader) IOException(java.io.IOException) XMLReader(org.xml.sax.XMLReader)

Example 4 with ExpatReader

use of org.apache.harmony.xml.ExpatReader in project robovm by robovm.

the class ExpatSaxParserTest method parse.

/**
     * Parses the given xml string and fires events on the given SAX handler.
     */
private static void parse(String xml, ContentHandler contentHandler) throws SAXException {
    try {
        XMLReader reader = new ExpatReader();
        reader.setContentHandler(contentHandler);
        reader.parse(new InputSource(new StringReader(xml)));
    } catch (IOException e) {
        throw new AssertionError(e);
    }
}
Also used : InputSource(org.xml.sax.InputSource) ExpatReader(org.apache.harmony.xml.ExpatReader) StringReader(java.io.StringReader) IOException(java.io.IOException) XMLReader(org.xml.sax.XMLReader)

Example 5 with ExpatReader

use of org.apache.harmony.xml.ExpatReader in project robovm by robovm.

the class ExpatSaxParserTest method testProcessingInstructions.

public void testProcessingInstructions() throws IOException, SAXException {
    Reader in = new StringReader("<?bob lee?><a></a>");
    ExpatReader reader = new ExpatReader();
    TestProcessingInstrutionHandler handler = new TestProcessingInstrutionHandler();
    reader.setContentHandler(handler);
    reader.parse(new InputSource(in));
    assertEquals("bob", handler.target);
    assertEquals("lee", handler.data);
}
Also used : InputSource(org.xml.sax.InputSource) ExpatReader(org.apache.harmony.xml.ExpatReader) StringReader(java.io.StringReader) ExpatReader(org.apache.harmony.xml.ExpatReader) Reader(java.io.Reader) XMLReader(org.xml.sax.XMLReader) StringReader(java.io.StringReader)

Aggregations

ExpatReader (org.apache.harmony.xml.ExpatReader)29 InputSource (org.xml.sax.InputSource)29 XMLReader (org.xml.sax.XMLReader)29 StringReader (java.io.StringReader)13 IOException (java.io.IOException)9 Reader (java.io.Reader)5 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Attributes (org.xml.sax.Attributes)2 ContentHandler (org.xml.sax.ContentHandler)2 DefaultHandler (org.xml.sax.helpers.DefaultHandler)2 MockResponse (com.google.mockwebserver.MockResponse)1 MockWebServer (com.google.mockwebserver.MockWebServer)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1