Java 8 DefaultHandler - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DefaultHandler class.

This code example shows how to use the following methods:
 
    private DefaultHandler offline;
 
    protected void setUp() throws Exception { 
        parser = SAXParserFactory.newInstance().newSAXParser();
        offline = new OfflineContentHandler(new DefaultHandler());
    } 
 
    public void testExternalDTD() throws Exception { 
        String xml =
            "<!DOCTYPE foo SYSTEM \"http://127.234.172.38:7845/bar\"><foo/>"; 
        try { 
            parser.parse(new InputSource(new StringReader(xml)), offline);
        } catch (ConnectException e) {
            fail("Parser tried to access the external DTD:" + e);
        } 
    } 
 
    public void testExternalEntity() throws Exception { 
        String xml =
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:parse
        return new ByteArrayInputStream(mXmlBytes);
    } 
 
    private void runSax() throws IOException, SAXException { 
        long start = System.currentTimeMillis();
        Xml.parse(newInputStream(), Xml.Encoding.UTF_8, new DefaultHandler());
        long elapsed = System.currentTimeMillis() - start;
        Log.i(TAG, "expat SAX: " + elapsed + "ms");
    } 
 
    private void runExpatPullParser() throws XmlPullParserException, IOException { 
        long start = System.currentTimeMillis();
        XmlPullParser pullParser = Xml.newPullParser();
        pullParser.setInput(newInputStream(), "UTF-8");
        withPullParser(pullParser);
        long elapsed = System.currentTimeMillis() - start;
        Log.i(TAG, "expat pull: " + elapsed + "ms");
    } 
 
    private void runJavaPullParser() throws XmlPullParserException, IOException { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        System.out.println(saxParser.getClass().getName());
         
        XMLReader xmlReader = saxParser.getXMLReader();
        System.out.println(xmlReader.getClass().getName());
 
        DefaultHandler handler = new DefaultHandler();
        xmlReader.setContentHandler(handler);
        xmlReader.setErrorHandler(handler);
 
        try { 
            xmlReader.parse(args[0]);
            System.out.println("Everything is ok !");
        } catch (IOException e) {
            System.err.println("I/O error: " + e.getMessage());
        } catch (SAXException e) {
            System.err.println("Parsing error: " + e.getMessage());
        } 
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    				   " does not implement XMLReader", e4);
    	} 
    } 
	 
    XMLReader createParser() {
        DefaultHandler handler = new DefaultHandler();
        XMLReader parserInstance = null;
 
        try { 
            parserInstance = newInstance();
            	//XMLReaderFactory.createXMLReader(DEFAULT_SAX_PARSER_CLASS_NAME); 
        } catch (SAXException e) {
        	ModelPlugin.getPluginLog().logError("default parser failed: " + e.getMessage());        	
        	return null; 
        } 
 
        SAXValidator.setFeature(parserInstance, NAMESPACES_FEATURE_ID, false);
        SAXValidator.setFeature(parserInstance, NAMESPACE_PREFIXES_FEATURE_ID, false);
        SAXValidator.setFeature(parserInstance, VALIDATION_FEATURE_ID, false);
        SAXValidator.setFeature(parserInstance, VALIDATION_SCHEMA_FEATURE_ID, false);

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    private DefaultHandler offline;
 
    @Before 
    public void setUp() throws Exception {
        parser = SAXParserFactory.newInstance().newSAXParser();
        offline = new OfflineContentHandler(new DefaultHandler());
    } 
 
    @Test
    public void testExternalDTD() throws Exception {
        String xml =
            "<!DOCTYPE foo SYSTEM \"http://127.234.172.38:7845/bar\"><foo/>"; 
        try { 
            parser.parse(new InputSource(new StringReader(xml)), offline);
        } catch (ConnectException e) {
            fail("Parser tried to access the external DTD:" + e);
        } 
    } 
 
    @Test
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
            EmbeddedResourceHandler handler)
            throws IOException, TikaException {
        ParseContext context = new ParseContext();
        context.set(Parser.class, new RecursiveParser(recurseExtractor, handler));
        try { 
            parser.parse(stream, new DefaultHandler(), new Metadata(), context);
        } catch (SAXException e) {
            throw new TikaException("Unexpected SAX exception", e);
        } 
    } 
 
    private class RecursiveParser extends AbstractParser { 
 
        private final ContainerExtractor extractor;
 
        private final EmbeddedResourceHandler handler;
 
        private RecursiveParser( 
                ContainerExtractor extractor,
                EmbeddedResourceHandler handler) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    private SecureContentHandler handler;
 
    @Before 
    public void setUp() { 
        stream = TikaInputStream.get(new NullInputStream(MANY_BYTES));
        handler = new SecureContentHandler(new DefaultHandler(), stream);
    } 
 
    @Test
    public void testZeroCharactersPerByte() throws IOException {
        try { 
            char[] ch = new char[] { 'x' };
            for (int i = 0; i < MANY_BYTES; i++) {
                stream.read();
            } 
            handler.characters(ch, 0, 1);
        } catch (SAXException e) {
            fail("Unexpected SAXException"); 
        } 
    } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:endElement, startElement
	 * @param context 
	 * @throws SAXException 
	 */ 
	protected void endLayoutDefinition(TableRenderContext context)
			throws SAXException {
		this.documentHandler.endElement(FOElementMapping.URI, "region-body",
				"region-body"); 
 
		if (getShowHeader()) { 
			this.documentHandler.startElement(FOElementMapping.URI,
					"region-before", "region-before", 
					createRegionBeforeAttributes(context));
			this.documentHandler.endElement(FOElementMapping.URI,
					"region-before", "region-before"); 
		} 
 
		if (getShowFooter()) { 
			this.documentHandler.startElement(FOElementMapping.URI,
					"region-after", "region-after", 
					createRegionAfterAttributes(context));

5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
            "+http.connection=http://*.dtd -- gov.nasa.jpf.CachedROHttpConnection", 
            "+http.cache_dir=src/tests/gov/nasa/jpf/test/xerces", 
            "+log.info=http")){ 
      String pathName = "src/tests/gov/nasa/jpf/test/xerces/sun_checks.xml";
 
      DefaultHandler handler = new DefaultHandler();
 
      XMLReader mParser;
      SAXParserFactory factory = SAXParserFactory.newInstance();
      factory.setValidating(true);
      factory.setNamespaceAware(true);
      mParser = factory.newSAXParser().getXMLReader();
      mParser.setContentHandler(handler);
      mParser.setEntityResolver(handler);
      mParser.setErrorHandler(handler);
 
      mParser.parse(pathName);
    } 
  } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:characters
        } 
    } 
 
    @Override 
    public void characters(char[] ch, int start, int length) throws SAXException {
        this.handler.characters(ch, start, length);
    } 
 
    public void exceptionThrown(Exception exception) {
        throw new Error("unexpected exception", exception);
    } 
 
    private void print(char ch, String name) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < this.depth; i++) sb.append(' ');
        sb.append(ch).append(' ').append(name);
        System.out.println(sb.toString());
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 DefaultHandler Questions & Answers:

See Code Examples for Java 8 DefaultHandler Methods: