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

This code example shows how to use the following methods:setSystemId
 * @author Joni Freeman 
 */ 
public class SpecdoxTransformer { 
    public void transform(String filename, String specXmlDir, String outputDir, File xref) throws TransformerException {
        Source xmlSource = new StreamSource(new StringReader("<?xml version=\"1.0\" ?><foo></foo>"));
        Source xsltSource = new StreamSource(Specdox.class.getResourceAsStream("/specdox.xsl"));
        xsltSource.setSystemId("/specdox.xsl");
         
        TransformerFactory transFact = new TransformerFactoryImpl();
        Transformer trans = transFact.newTransformer(xsltSource);
        trans.setParameter("spec-file-dir", specXmlDir);
        trans.setParameter("xref", xref.getName());
        trans.setParameter("output-dir", outputDir);
        trans.setParameter("frameset-index-filename", filename);
        trans.transform(xmlSource, new StreamResult(System.out));
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setSystemId
        ep.publish("test");
        assertTrue("The endpoint was not published successfully", ep.isPublished());
         
        String wsdlLocation = "http://test.wsdl.com/Test.wsdl"; // Dummy URL
        List<Source> metadata = new ArrayList<Source>();
        Source source = new StreamSource(new ByteArrayInputStream(new byte[0])); // Dummy content  
        source.setSystemId(wsdlLocation);  
        metadata.add(source);
        ep.setMetadata(metadata);
         
        metadata = ep.getMetadata();
        assertNotNull(metadata);
        source = metadata.get(0);
        assertNotNull(source);
        assertEquals(source.getSystemId(), wsdlLocation);
         
        ep.stop();
    } 
 
    public void testCreateAndPublishOnAlternatePort() throws Exception {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSystemId
                if (source instanceof StreamSource) {
                    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);
            } 
        } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setSystemId
httpClient.executeMethod(get);
                    byte[] body = get.getResponseBody();
                    Element element = new Element(newUrl, body);
                    cache.put(element);
                    toReturn = new StreamSource(new BufferedInputStream(new ByteArrayInputStream(
                            body)));
                } 
                catch (HttpException e)
                { 
                    e.printStackTrace();
                    logger.error(e.getLocalizedMessage());
                    return null; 
                } 
                catch (IOException e)
                { 
                    e.printStackTrace();
                    logger.error(e.getLocalizedMessage());
                    return null; 
                } 

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getClass, getSystemId
    public static void doWithSource(Source source, SourceCallback callback) throws Exception {
        if (source instanceof DOMSource) {
            callback.domSource(((DOMSource) source).getNode());
            return; 
        } 
        else if (StaxUtils.isStaxSource(source)) {
            XMLStreamReader streamReader = StaxUtils.getXMLStreamReader(source);
            if (streamReader != null) {
                callback.staxSource(streamReader);
                return; 
            } 
            else { 
                XMLEventReader eventReader = StaxUtils.getXMLEventReader(source);
                if (eventReader != null) {
                    callback.staxSource(eventReader);
                    return; 
                } 
            } 
        } 
        else if (source instanceof SAXSource) {

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setSystemId
        fRootNode = null;
        fErrorHandler.reset();
    } 
     
    protected void validateDocument() throws Exception { 
        Source source = new DOMSource(fDocument);
        source.setSystemId(fDocumentURL.toExternalForm());
        Result result = new DOMResult(fDocument);
        fValidator.validate(source, result);
    } 
     
    protected void validateFragment() throws Exception { 
        Source source = new DOMSource((Node) fRootNode);
        source.setSystemId(fDocumentURL.toExternalForm());
        Result result = new DOMResult((Node) fRootNode);
        fValidator.validate(source, result);
    } 
     
    protected PSVIElementNSImpl getChild(int n) {
        int numFound = 0;
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setSystemId
     /** 
     * Returns the Inputstream related to this schema 
     */ 
    public Source getSchemaSource() {
        InputStream in = FileValidatorSchemaFactory.class.getResourceAsStream(fileXSDUrl);
        Source s = new StreamSource(in);
        s.setSystemId(FileValidatorSchemaFactory.class.getResource(fileXSDUrl).toString());
        return s;
    } 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getSystemId
     * @return The system identifier that was set with setSystemId, 
     *         or null if setSystemId was not called. 
     */ 
    public String getSystemId() {
	if (_source != null) {
	    return _source.getSystemId();
	} 
	else { 
	    return(_systemId);
	} 
    } 
     
    /** 
     * Internal interface which returns a DOM for a given DTMManager and translet. 
     */ 
    protected DOM getDOM(XSLTCDTMManager dtmManager, AbstractTranslet translet)
        throws SAXException 
    { 
        SAXImpl idom = (SAXImpl)_dom.get();
                 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getFeature, reset, setFeature
     
    public void testFeatureReset() throws Exception { 
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = makeSchema(factory, null);
        Validator validator = schema.newValidator();
        validator.setFeature(FEATURE_STRING_DEFAULT_TRUE, false);
        validator.setFeature(FEATURE_STRING_DEFAULT_FALSE, true);
        validator.reset();
        boolean value = validator.getFeature(FEATURE_STRING_DEFAULT_TRUE);
        assertTrue("After reset, value of feature on Validator should be true.", value);
        value = validator.getFeature(FEATURE_STRING_DEFAULT_FALSE);
        assertFalse("After reset, value of feature on Validator should be false.", value);        
    } 
     
    public void testSecureProcessingFeaturePropagationAndReset() throws Exception { 
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        boolean value;
        value = factory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING);
        assertFalse("Default value of feature on SchemaFactory should have been false.", value);
        factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:validate
    } 
 
    public void testValidatorBadXML() { 
        System.out.println("-- testValidatorBadXML");
        try { 
            validator.validate(getAsSource(BAD_XML));
            fail("MUST NOT be able to validate bad restlet.xml"); 
        } catch (SAXException x) {
            // the error must be a "cvc-complex-type.2.4.a" 
            assertTrue("MUST detect schema violation", x.getLocalizedMessage()
                    .startsWith("cvc-complex-type.2.4.a"));
            // ...and it has to refer to 'bad-element' 
            assertTrue("MUST detect schema violation related to 'bad-element'", 
                    x.getLocalizedMessage().indexOf("bad-element") > 0);
 
        } catch (IOException x) {
            fail("MUST throw a SAXException only"); 
        } 
    } 
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Java 8 Source Questions & Answers:

See Code Examples for Java 8 Source Methods: