Example usage for javax.xml.transform.stream StreamSource FEATURE

List of usage examples for javax.xml.transform.stream StreamSource FEATURE

Introduction

In this page you can find the example usage for javax.xml.transform.stream StreamSource FEATURE.

Prototype

String FEATURE

To view the source code for javax.xml.transform.stream StreamSource FEATURE.

Click Source Link

Document

If javax.xml.transform.TransformerFactory#getFeature returns true when passed this value as an argument, the Transformer supports Source input of this type.

Usage

From source file:net.sf.joost.trax.TransformerFactoryImpl.java

/**
 * Supplied features./*from  ww w. ja va  2 s.  co m*/
 * @param name Name of the feature.
 * @return true if feature is supported.
 */
public boolean getFeature(String name) {

    if (name.equals(SAXSource.FEATURE)) {
        return true;
    }
    if (name.equals(SAXResult.FEATURE)) {
        return true;
    }
    if (name.equals(DOMSource.FEATURE)) {
        return true;
    }
    if (name.equals(DOMResult.FEATURE)) {
        return true;
    }
    if (name.equals(StreamSource.FEATURE)) {
        return true;
    }
    if (name.equals(StreamResult.FEATURE)) {
        return true;
    }
    if (name.equals(SAXTransformerFactory.FEATURE)) {
        return true;
    }
    if (name.equals(SAXTransformerFactory.FEATURE_XMLFILTER)) {
        return true;
    }

    String errMsg = "Unknown feature " + name;
    TransformerConfigurationException tE = new TransformerConfigurationException(errMsg);

    try {
        defaultErrorListener.error(tE);
        return false;
    } catch (TransformerException e) {
        throw new IllegalArgumentException(errMsg);
    }
}

From source file:nl.nn.adapterframework.validation.xerces_2_11.XMLSchemaFactory.java

public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException(JAXPValidationMessageFormatter
                .formatMessage(fXMLSchemaLoader.getLocale(), "FeatureNameNull", null));
    }//from   ww  w .  j  a va 2s .co m
    if (name.startsWith(JAXP_SOURCE_FEATURE_PREFIX)) {
        // Indicates to the caller that this SchemaFactory supports a specific JAXP Source.
        if (name.equals(StreamSource.FEATURE) || name.equals(SAXSource.FEATURE)
                || name.equals(DOMSource.FEATURE) || name.equals(StAXSource.FEATURE)) {
            return true;
        }
    }
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        return (fSecurityManager != null);
    } else if (name.equals(USE_GRAMMAR_POOL_ONLY)) {
        return fUseGrammarPoolOnly;
    }
    try {
        return fXMLSchemaLoader.getFeature(name);
    } catch (XMLConfigurationException e) {
        String identifier = e.getIdentifier();
        if (e.getType() == XMLConfigurationException.NOT_RECOGNIZED) {
            throw new SAXNotRecognizedException(SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
                    "feature-not-recognized", new Object[] { identifier }));
        } else {
            throw new SAXNotSupportedException(SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
                    "feature-not-supported", new Object[] { identifier }));
        }
    }
}

From source file:nl.nn.adapterframework.validation.xerces_2_11.XMLSchemaFactory.java

public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException(JAXPValidationMessageFormatter
                .formatMessage(fXMLSchemaLoader.getLocale(), "FeatureNameNull", null));
    }//from  ww  w.j a v a2  s  .  c  o  m
    if (name.startsWith(JAXP_SOURCE_FEATURE_PREFIX)) {
        if (name.equals(StreamSource.FEATURE) || name.equals(SAXSource.FEATURE)
                || name.equals(DOMSource.FEATURE) || name.equals(StAXSource.FEATURE)) {
            throw new SAXNotSupportedException(SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
                    "feature-read-only", new Object[] { name }));
        }
    }
    if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
        fSecurityManager = value ? new SecurityManager() : null;
        fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
        return;
    } else if (name.equals(USE_GRAMMAR_POOL_ONLY)) {
        fUseGrammarPoolOnly = value;
        return;
    }
    try {
        fXMLSchemaLoader.setFeature(name, value);
    } catch (XMLConfigurationException e) {
        String identifier = e.getIdentifier();
        if (e.getType() == XMLConfigurationException.NOT_RECOGNIZED) {
            throw new SAXNotRecognizedException(SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
                    "feature-not-recognized", new Object[] { identifier }));
        } else {
            throw new SAXNotSupportedException(SAXMessageFormatter.formatMessage(fXMLSchemaLoader.getLocale(),
                    "feature-not-supported", new Object[] { identifier }));
        }
    }
}