Java 8 ParserAdapter - 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 ParserAdapter class.

This code example shows how to use the following methods:parse, setContentHandler
 
        // read in XML file and parse to content handler 
        try { 
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser parser = factory.newSAXParser();
            ParserAdapter adapter = new ParserAdapter(parser.getParser());
 
            adapter.setContentHandler(documentFilter);
            adapter.parse(requestSource);
            LOGGER.fine("just parsed: " + requestSource);
        } catch (SAXException e) {
            throw new ServiceException(e, "XML getFeature request SAX parsing error",
                    XmlRequestReader.class.getName());
        } catch (IOException e) {
            throw new ServiceException(e, "XML get feature request input error",
                    XmlRequestReader.class.getName());
        } catch (ParserConfigurationException e) {
            throw new ServiceException(e, "Some sort of issue creating parser",
                    XmlRequestReader.class.getName());
        } 
7
CodeRank
This code example shows how to use the following methods:parse, setContentHandler
 
        // read in XML file and parse to content handler 
        try { 
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser parser = factory.newSAXParser();
            ParserAdapter adapter = new ParserAdapter(parser.getParser());
 
            adapter.setContentHandler(documentFilter);
            adapter.parse(requestSource);
            LOGGER.fine("just parsed: " + requestSource);
        } catch (SAXException e) {
            throw new ServiceException(e, "XML getFeature request SAX parsing error",
                XmlRequestReader.class.getName());
        } catch (IOException e) {
            throw new ServiceException(e, "XML get feature request input error",
                XmlRequestReader.class.getName());
        } catch (ParserConfigurationException e) {
            throw new ServiceException(e, "Some sort of issue creating parser",
                XmlRequestReader.class.getName());
        } 
7
CodeRank
This code example shows how to use the following methods:parse, setContentHandler
 
        // read in XML file and parse to content handler 
        try { 
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser parser = factory.newSAXParser();
            ParserAdapter adapter = new ParserAdapter(parser.getParser());
 
            adapter.setContentHandler(documentFilter);
            adapter.parse(requestSource);
            LOGGER.fine("just parsed: " + requestSource);
        } catch (SAXException e) {
            //SAXException does not sets initCause(). Instead, it holds its own "exception" field. 
            if(e.getException() != null && e.getCause() == null){
                e.initCause(e.getException());
            } 
            throw new ServiceException(e, "XML getFeature request SAX parsing error",
                XmlRequestReader.class.getName());
        } catch (IOException e) {
            throw new ServiceException(e, "XML get feature request input error",
                XmlRequestReader.class.getName());
7
CodeRank
This code example shows how to use the following methods:parse, setContentHandler
 
        // read in XML file and parse to content handler 
        try { 
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser parser = factory.newSAXParser();
            ParserAdapter adapter = new ParserAdapter(parser.getParser());
 
            adapter.setContentHandler(documentFilter);
            adapter.parse(requestSource);
            LOGGER.fine("just parsed: " + requestSource);
        } catch (SAXException e) {
            throw new ServiceException(e, "XML getFeature request SAX parsing error",
                    XmlRequestReader.class.getName());
        } catch (IOException e) {
            throw new ServiceException(e, "XML get feature request input error",
                    XmlRequestReader.class.getName());
        } catch (ParserConfigurationException e) {
            throw new ServiceException(e, "Some sort of issue creating parser",
                    XmlRequestReader.class.getName());
        } 
6
CodeRank
This code example shows how to use the following methods:parse, setContentHandler
 
        // read in XML file and parse to content handler 
        try { 
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser parser = factory.newSAXParser();
            ParserAdapter adapter = new ParserAdapter(parser.getParser());
 
            adapter.setContentHandler(documentFilter);
            adapter.parse(requestSource);
            LOGGER.fine("just parsed: " + requestSource);
        } catch (SAXException e) {
            throw new ServiceException(e, "XML getFeature request SAX parsing error",
                XmlRequestReader.class.getName());
        } catch (IOException e) {
            throw new ServiceException(e, "XML get feature request input error",
                XmlRequestReader.class.getName());
        } catch (ParserConfigurationException e) {
            throw new ServiceException(e, "Some sort of issue creating parser",
                XmlRequestReader.class.getName());
        } 
6
CodeRank
This code example shows how to use the following methods:parse, setContentHandler, setErrorHandler
    public WeightedDirectedMultigraph<String> readWeightedDirectedMultigraph(
            File f, Indexer<String> vertexLabels) throws IOException {        
        try { 
            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();
            ParserAdapter pa = new ParserAdapter(sp.getParser());
             
            GraphMLParser parser = new GraphMLParser(vertexLabels);
             
            pa.setContentHandler(parser);
            pa.setErrorHandler(parser);
            pa.parse(new InputSource(new BufferedInputStream(new FileInputStream(f))));
            return parser.g;
        } catch (SAXException saxe) {
            throw new IOException(saxe);
        } catch (ParserConfigurationException saxe) {
            throw new IOException(saxe);
        } 
    } 
 
6
CodeRank
This code example shows how to use the following methods:parse, setContentHandler
        //parser.setContentHandler(documentFilter); 
        //parser.parse(uri); 
        SAXParserFactory fac = SAXParserFactory.newInstance();
        SAXParser parser = fac.newSAXParser();
 
        ParserAdapter p = new ParserAdapter(parser.getParser());
        p.setContentHandler(documentFilter);
        LOGGER.fine("just made parser, " + uri);
        p.parse(TestData.getResource(this, uri).toExternalForm());
        LOGGER.finest("just parsed: " + uri);
 
        return filterHandler.getFilter();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:parse, setContentHandler, setErrorHandler
	public void run(final TaskMonitor taskMonitor) throws Exception {
		this.taskMonitor = taskMonitor;
		try { 
			final SAXParserFactory spf = SAXParserFactory.newInstance();
			final SAXParser sp = spf.newSAXParser();
			final ParserAdapter pa = new ParserAdapter(sp.getParser());
			 
			parser = new GraphMLParser(taskMonitor, cyNetworkFactory, cyRootNetworkFactory);
 
			pa.setContentHandler(parser);
			pa.setErrorHandler(parser);
			pa.parse(new InputSource(inputStream));
 
		} finally { 
			if (inputStream != null) {
				inputStream.close();
				inputStream = null;
			} 
		} 
	} 
6
CodeRank
This code example shows how to use the following methods:parse, setContentHandler
        //parser.setContentHandler(documentFilter); 
        //parser.parse(uri); 
        SAXParserFactory fac = SAXParserFactory.newInstance();
        SAXParser parser = fac.newSAXParser();
 
        ParserAdapter p = new ParserAdapter(parser.getParser());
        p.setContentHandler(documentFilter);
        LOGGER.fine("just made parser, " + uri);
        p.parse(TestData.getResource(this, uri).toExternalForm());
        LOGGER.finest("just parsed: " + uri);
 
        return filterHandler.getFilter();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:parse, setContentHandler
 
        // read in XML file and parse to content handler 
        try { 
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser parser = factory.newSAXParser();
            ParserAdapter adapter = new ParserAdapter(parser.getParser());
 
            adapter.setContentHandler(documentFilter);
            adapter.parse(requestSource);
            LOGGER.fine("just parsed: " + requestSource);
        } catch (SAXException e) {
            //SAXException does not sets initCause(). Instead, it holds its own "exception" field. 
            if(e.getException() != null && e.getCause() == null){
                e.initCause(e.getException());
            } 
            throw new ServiceException(e, "XML getFeature request SAX parsing error",
                XmlRequestReader.class.getName());
        } catch (IOException e) {
            throw new ServiceException(e, "XML get feature request input error",
                XmlRequestReader.class.getName());
6
CodeRank
See Code Examples for Java 8 ParserAdapter Methods: