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

This code example shows how to use the following methods: getInputSource, getXMLReader, setInputSource, setXMLReader
	 * @throws XmlMappingException if the given source cannot be mapped to an object 
	 * @throws IOException if an I/O Exception occurs 
	 * @see #unmarshalSaxReader(org.xml.sax.XMLReader, org.xml.sax.InputSource) 
	 */ 
	protected Object unmarshalSaxSource(SAXSource saxSource) throws XmlMappingException, IOException {
		if (saxSource.getXMLReader() == null) {
			try { 
				saxSource.setXMLReader(createXmlReader());
			} 
			catch (SAXException ex) {
				throw new UnmarshallingFailureException("Could not create XMLReader for SAXSource", ex);
			} 
		} 
		if (saxSource.getInputSource() == null) {
			saxSource.setInputSource(new InputSource());
		} 
		return unmarshalSaxReader(saxSource.getXMLReader(), saxSource.getInputSource());
	} 
 
	/** 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	} 
 
	@Test
	public void unmarshalSAXSource() throws Exception {
		XMLReader reader = XMLReaderFactory.createXMLReader();
		SAXSource source = new SAXSource(reader, new InputSource(new StringReader(INPUT_STRING)));
		Object flights = unmarshaller.unmarshal(source);
		testFlights(flights); 
	} 
 
	@Test
	public void unmarshalStaxSourceXmlStreamReader() throws Exception {
		XMLInputFactory inputFactory = XMLInputFactory.newInstance();
		XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(INPUT_STRING));
		Source source = StaxUtils.createStaxSource(streamReader);
		Object flights = unmarshaller.unmarshal(source);
		testFlights(flights); 
	} 
 
	@Test
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        } catch (JAXBException ex) {
            throw new ProcessingException(LocalizationMessages.ERROR_WADL_JAXB_CONTEXT(), ex);
        } 
 
        final SAXParser saxParser = saxParserFactory.newSAXParser();
        SAXSource source = new SAXSource(saxParser.getXMLReader(), new InputSource(inputStream));
        final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        final Object result = unmarshaller.unmarshal(source);
        return resultClass.cast(result);
    } 
 
    /** 
     * Return {@code true} if generation of full WADL with 
     * {@link org.glassfish.jersey.server.model.ExtendedResource extended resources} is requested. 
     * 
     * @param uriInfo URI info of the request. 
     * @return {@code true} if full detailed WADL should be generated; false otherwise. 
     */ 
    public static boolean isDetailedWadlRequested(UriInfo uriInfo) {
        final List<String> simple = uriInfo.getQueryParameters().get(DETAILED_WADL_QUERY_PARAM);
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
public class StaxUtilsTests { 
 
	@Test
	public void isStaxSourceInvalid() throws Exception {
		assertFalse("A StAX Source", StaxUtils.isStaxSource(new DOMSource()));
		assertFalse("A StAX Source", StaxUtils.isStaxSource(new SAXSource()));
		assertFalse("A StAX Source", StaxUtils.isStaxSource(new StreamSource()));
	} 
 
	@Test
	public void isStaxSource() throws Exception {
		XMLInputFactory inputFactory = XMLInputFactory.newInstance();
		String expected = "<element/>";
		XMLStreamReader streamReader = inputFactory.createXMLStreamReader(new StringReader(expected));
		Source source = StaxUtils.createCustomStaxSource(streamReader);
 
		assertTrue("Not a StAX Source", StaxUtils.isStaxSource(source));
	} 
 
	@Test
Full Snippet Info
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        }); 
 
        XMLFilter xmlFilter = new NoSourceAndNamespaceFilter(parser.getXMLReader());
        xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());
 
        SAXSource source = new SAXSource(xmlFilter, inputSource);
 
        return (Features)unmarshaller.unmarshal(source);
         
        } catch (ParserConfigurationException e) {
            throw new RuntimeException(e);
        } catch (JAXBException e) {
            throw new RuntimeException(e);
        } catch (SAXException e) {
            throw new RuntimeException(e);
        } 
    } 
 
    /** 
     * Provides an empty inputsource for the entity resolver. 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
This code example shows how to use the following methods:
                    StreamSource stream = (StreamSource) source;
                    InputSource inputStream = new InputSource(stream.getInputStream());
                    inputStream.setCharacterStream(inputStream.getCharacterStream());
                    inputStream.setPublicId(stream.getPublicId());
                    inputStream.setSystemId(source.getSystemId());
                    source = new SAXSource(saxParserFactory.provide().newSAXParser().getXMLReader(), inputStream);
                } 
 
                StreamResult sr = new StreamResult(entityStream);
                transformerFactory.provide().newTransformer().transform(source, sr);
 
            } catch (SAXException ex) {
                throw new InternalServerErrorException(ex);
            } catch (ParserConfigurationException ex) {
                throw new InternalServerErrorException(ex);
            } catch (TransformerException ex) {
                throw new InternalServerErrorException(ex);
            } 
        } 
    } 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        } catch (JAXBException ex) {
            throw new ProcessingException(LocalizationMessages.ERROR_WADL_JAXB_CONTEXT(), ex);
        } 
 
        final SAXParser saxParser = saxParserFactory.newSAXParser();
        SAXSource source = new SAXSource(saxParser.getXMLReader(), new InputSource(inputStream));
        final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        final Object result = unmarshaller.unmarshal(source);
        return resultClass.cast(result);
    } 
 
    /** 
     * Return {@code true} if generation of full WADL with 
     * {@link org.glassfish.jersey.server.model.ExtendedResource extended resources} is requested. 
     * 
     * @param uriInfo URI info of the request. 
     * @return {@code true} if full detailed WADL should be generated; false otherwise. 
     */ 
    public static boolean isDetailedWadlRequested(UriInfo uriInfo) {
        final List<String> simple = uriInfo.getQueryParameters().get(DETAILED_WADL_QUERY_PARAM);
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
                content.startsWith(prefix));
    } 
 
    private static SAXSource createSAXSource(String content) throws SAXException, ParserConfigurationException {
        SAXParserFactory saxFactory = SAXParserFactory.newInstance();
        return new SAXSource(saxFactory.newSAXParser().getXMLReader(), new InputSource(new ByteArrayInputStream(
                content.getBytes())));
    } 
 
    private static DOMSource createDOMSoruce(String content) throws SAXException, IOException, ParserConfigurationException {
        DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
        Document d = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(content.getBytes()));
        return new DOMSource(d);
    } 
 
    @Path("test") 
    public static class TestResource { 
 
        @PUT 
        @Consumes("text/xml") 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
         if (needsSecurity()) 
         { 
            SAXSource source = null;
            if (getCharset(mediaType) == null)
            { 
               source = new SAXSource(new InputSource(new InputStreamReader(entityStream, "UTF-8")));
            } 
            else 
            { 
               source = new SAXSource(new InputSource(entityStream));
            } 
            unmarshaller = new SecureUnmarshaller(unmarshaller, isDisableExternalEntities(), isEnableSecureProcessingFeature(), isDisableDTDs());
            obj = unmarshaller.unmarshal(source);
         } 
         else 
         { 
            if (getCharset(mediaType) == null)
            { 
               InputSource is = new InputSource(entityStream);
               is.setEncoding("UTF-8");
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 SAXSource Methods: