com.sun.org.apache.xerces.internal.util.FeatureState Java Examples

The following examples show how to use com.sun.org.apache.xerces.internal.util.FeatureState. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BasicParserConfiguration.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId)
    throws XMLConfigurationException {

    //
    // Xerces Features
    //
    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // special performance feature: no one by component manager is allowed to set it
        //
        if (suffixLength == Constants.PARSER_SETTINGS.length() &&
            featureId.endsWith(Constants.PARSER_SETTINGS)) {
            return FeatureState.NOT_SUPPORTED;
        }
    }

    return super.checkFeature(featureId);
 }
 
Example #2
Source File: XMLSchemaValidatorComponentManager.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the state of a feature.
 *
 * @param featureId The feature identifier.
 * @return true if the feature is supported
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
public FeatureState getFeatureState(String featureId)
        throws XMLConfigurationException {
    if (PARSER_SETTINGS.equals(featureId)) {
        return FeatureState.is(fConfigUpdated);
    }
    else if (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId)) {
        return FeatureState.is(true);
    }
    else if (USE_GRAMMAR_POOL_ONLY.equals(featureId)) {
        return FeatureState.is(fUseGrammarPoolOnly);
    }
    else if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) {
        return FeatureState.is(fInitSecurityManager.isSecureProcessing());
    }
    else if (SCHEMA_ELEMENT_DEFAULT.equals(featureId)) {
        return FeatureState.is(true); //pre-condition: VALIDATION and SCHEMA_VALIDATION are always true
    }
    return super.getFeatureState(featureId);
}
 
Example #3
Source File: XMLSchemaValidatorComponentManager.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the state of a feature.
 *
 * @param featureId The feature identifier.
 * @return true if the feature is supported
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
public FeatureState getFeatureState(String featureId)
        throws XMLConfigurationException {
    if (PARSER_SETTINGS.equals(featureId)) {
        return FeatureState.is(fConfigUpdated);
    }
    else if (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId)) {
        return FeatureState.is(true);
    }
    else if (USE_GRAMMAR_POOL_ONLY.equals(featureId)) {
        return FeatureState.is(fUseGrammarPoolOnly);
    }
    else if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) {
        return FeatureState.is(fInitSecurityManager.isSecureProcessing());
    }
    else if (SCHEMA_ELEMENT_DEFAULT.equals(featureId)) {
        return FeatureState.is(true); //pre-condition: VALIDATION and SCHEMA_VALIDATION are always true
    }
    return super.getFeatureState(featureId);
}
 
Example #4
Source File: BasicParserConfiguration.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId)
    throws XMLConfigurationException {

    //
    // Xerces Features
    //
    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // special performance feature: no one by component manager is allowed to set it
        //
        if (suffixLength == Constants.PARSER_SETTINGS.length() &&
            featureId.endsWith(Constants.PARSER_SETTINGS)) {
            return FeatureState.NOT_SUPPORTED;
        }
    }

    return super.checkFeature(featureId);
 }
 
Example #5
Source File: BasicParserConfiguration.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId)
    throws XMLConfigurationException {

    //
    // Xerces Features
    //
    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // special performance feature: no one by component manager is allowed to set it
        //
        if (suffixLength == Constants.PARSER_SETTINGS.length() &&
            featureId.endsWith(Constants.PARSER_SETTINGS)) {
            return FeatureState.NOT_SUPPORTED;
        }
    }

    return super.checkFeature(featureId);
 }
 
Example #6
Source File: BasicParserConfiguration.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId)
    throws XMLConfigurationException {

    //
    // Xerces Features
    //
    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // special performance feature: no one by component manager is allowed to set it
        //
        if (suffixLength == Constants.PARSER_SETTINGS.length() &&
            featureId.endsWith(Constants.PARSER_SETTINGS)) {
            return FeatureState.NOT_SUPPORTED;
        }
    }

    return super.checkFeature(featureId);
 }
 
Example #7
Source File: BasicParserConfiguration.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId)
    throws XMLConfigurationException {

    //
    // Xerces Features
    //
    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // special performance feature: no one by component manager is allowed to set it
        //
        if (suffixLength == Constants.PARSER_SETTINGS.length() &&
            featureId.endsWith(Constants.PARSER_SETTINGS)) {
            return FeatureState.NOT_SUPPORTED;
        }
    }

    return super.checkFeature(featureId);
 }
 
Example #8
Source File: XMLSchemaValidatorComponentManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the state of a feature.
 *
 * @param featureId The feature identifier.
 * @return true if the feature is supported
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
public FeatureState getFeatureState(String featureId)
        throws XMLConfigurationException {
    if (PARSER_SETTINGS.equals(featureId)) {
        return FeatureState.is(fConfigUpdated);
    }
    else if (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId)) {
        return FeatureState.is(true);
    }
    else if (USE_GRAMMAR_POOL_ONLY.equals(featureId)) {
        return FeatureState.is(fUseGrammarPoolOnly);
    }
    else if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) {
        return FeatureState.is(fInitSecurityManager.isSecureProcessing());
    }
    else if (SCHEMA_ELEMENT_DEFAULT.equals(featureId)) {
        return FeatureState.is(true); //pre-condition: VALIDATION and SCHEMA_VALIDATION are always true
    }
    return super.getFeatureState(featureId);
}
 
Example #9
Source File: XMLSchemaValidatorComponentManager.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the state of a feature.
 *
 * @param featureId The feature identifier.
 * @return true if the feature is supported
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
public FeatureState getFeatureState(String featureId)
        throws XMLConfigurationException {
    if (PARSER_SETTINGS.equals(featureId)) {
        return FeatureState.is(fConfigUpdated);
    }
    else if (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId)) {
        return FeatureState.is(true);
    }
    else if (USE_GRAMMAR_POOL_ONLY.equals(featureId)) {
        return FeatureState.is(fUseGrammarPoolOnly);
    }
    else if (XMLConstants.FEATURE_SECURE_PROCESSING.equals(featureId)) {
        return FeatureState.is(fInitSecurityManager.isSecureProcessing());
    }
    else if (SCHEMA_ELEMENT_DEFAULT.equals(featureId)) {
        return FeatureState.is(true); //pre-condition: VALIDATION and SCHEMA_VALIDATION are always true
    }
    return super.getFeatureState(featureId);
}
 
Example #10
Source File: SchemaValidatorConfiguration.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public boolean getFeature(String featureId, boolean defaultValue) {
    FeatureState state = getFeatureState(featureId);
    if (state.isExceptional()) {
        return defaultValue;
    }
    return state.state;
}
 
Example #11
Source File: SchemaValidatorConfiguration.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public boolean getFeature(String featureId, boolean defaultValue) {
    FeatureState state = getFeatureState(featureId);
    if (state.isExceptional()) {
        return defaultValue;
    }
    return state.state;
}
 
Example #12
Source File: SchemaValidatorConfiguration.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public FeatureState getFeatureState(String featureId) {
    if (PARSER_SETTINGS.equals(featureId)) {
        return fParentComponentManager.getFeatureState(featureId);
    }
    else if (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId)) {
        return FeatureState.is(true);
    }
    else if (USE_GRAMMAR_POOL_ONLY.equals(featureId)) {
        return FeatureState.is(fUseGrammarPoolOnly);
    }
    return fParentComponentManager.getFeatureState(featureId);
}
 
Example #13
Source File: NonValidatingConfiguration.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public FeatureState getFeatureState(String featureId)
        throws XMLConfigurationException {
                // make this feature special
        if (featureId.equals(PARSER_SETTINGS)){
                return FeatureState.is(fConfigUpdated);
        }
        return super.getFeatureState(featureId);

}
 
Example #14
Source File: NonValidatingConfiguration.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public FeatureState getFeatureState(String featureId)
        throws XMLConfigurationException {
                // make this feature special
        if (featureId.equals(PARSER_SETTINGS)){
                return FeatureState.is(fConfigUpdated);
        }
        return super.getFeatureState(featureId);

}
 
Example #15
Source File: SchemaValidatorConfiguration.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public boolean getFeature(String featureId, boolean defaultValue) {
    FeatureState state = getFeatureState(featureId);
    if (state.isExceptional()) {
        return defaultValue;
    }
    return state.state;
}
 
Example #16
Source File: NonValidatingConfiguration.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public FeatureState getFeatureState(String featureId)
        throws XMLConfigurationException {
                // make this feature special
        if (featureId.equals(PARSER_SETTINGS)){
                return FeatureState.is(fConfigUpdated);
        }
        return super.getFeatureState(featureId);

}
 
Example #17
Source File: XIncludeAwareParserConfiguration.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public FeatureState getFeatureState(String featureId)
    throws XMLConfigurationException {
    if (featureId.equals(PARSER_SETTINGS)) {
        return FeatureState.is(fConfigUpdated);
    }
    else if (featureId.equals(XINCLUDE_FEATURE)) {
        return FeatureState.is(fXIncludeEnabled);
    }
    return super.getFeatureState0(featureId);

}
 
Example #18
Source File: NonValidatingConfiguration.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public FeatureState getFeatureState(String featureId)
        throws XMLConfigurationException {
                // make this feature special
        if (featureId.equals(PARSER_SETTINGS)){
                return FeatureState.is(fConfigUpdated);
        }
        return super.getFeatureState(featureId);

}
 
Example #19
Source File: XIncludeAwareParserConfiguration.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public FeatureState getFeatureState(String featureId)
    throws XMLConfigurationException {
    if (featureId.equals(PARSER_SETTINGS)) {
        return FeatureState.is(fConfigUpdated);
    }
    else if (featureId.equals(XINCLUDE_FEATURE)) {
        return FeatureState.is(fXIncludeEnabled);
    }
    return super.getFeatureState0(featureId);

}
 
Example #20
Source File: SchemaValidatorConfiguration.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public boolean getFeature(String featureId, boolean defaultValue) {
    FeatureState state = getFeatureState(featureId);
    if (state.isExceptional()) {
        return defaultValue;
    }
    return state.state;
}
 
Example #21
Source File: SchemaValidatorConfiguration.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public FeatureState getFeatureState(String featureId) {
    if (PARSER_SETTINGS.equals(featureId)) {
        return fParentComponentManager.getFeatureState(featureId);
    }
    else if (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId)) {
        return FeatureState.is(true);
    }
    else if (USE_GRAMMAR_POOL_ONLY.equals(featureId)) {
        return FeatureState.is(fUseGrammarPoolOnly);
    }
    return fParentComponentManager.getFeatureState(featureId);
}
 
Example #22
Source File: XIncludeAwareParserConfiguration.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public FeatureState getFeatureState(String featureId)
    throws XMLConfigurationException {
    if (featureId.equals(PARSER_SETTINGS)) {
        return FeatureState.is(fConfigUpdated);
    }
    else if (featureId.equals(XINCLUDE_FEATURE)) {
        return FeatureState.is(fXIncludeEnabled);
    }
    return super.getFeatureState0(featureId);

}
 
Example #23
Source File: SchemaValidatorConfiguration.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public FeatureState getFeatureState(String featureId) {
    if (PARSER_SETTINGS.equals(featureId)) {
        return fParentComponentManager.getFeatureState(featureId);
    }
    else if (VALIDATION.equals(featureId) || SCHEMA_VALIDATION.equals(featureId)) {
        return FeatureState.is(true);
    }
    else if (USE_GRAMMAR_POOL_ONLY.equals(featureId)) {
        return FeatureState.is(fUseGrammarPoolOnly);
    }
    return fParentComponentManager.getFeatureState(featureId);
}
 
Example #24
Source File: XML11DTDConfiguration.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId) throws XMLConfigurationException {

    //
    // Xerces Features
    //

    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // http://apache.org/xml/features/validation/dynamic
        //   Allows the parser to validate a document only when it
        //   contains a grammar. Validation is turned on/off based
        //   on each document instance, automatically.
        //
        if (suffixLength == Constants.DYNAMIC_VALIDATION_FEATURE.length() &&
            featureId.endsWith(Constants.DYNAMIC_VALIDATION_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }

        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE.length() &&
            featureId.endsWith(Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE)) {
            // REVISIT
            return FeatureState.NOT_SUPPORTED;
        }
        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.VALIDATE_CONTENT_MODELS_FEATURE.length() &&
            featureId.endsWith(Constants.VALIDATE_CONTENT_MODELS_FEATURE)) {
            // REVISIT
            return FeatureState.NOT_SUPPORTED;
        }
        //
        // http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar
        //
        if (suffixLength == Constants.LOAD_DTD_GRAMMAR_FEATURE.length() &&
            featureId.endsWith(Constants.LOAD_DTD_GRAMMAR_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }
        //
        // http://apache.org/xml/features/validation/nonvalidating/load-external-dtd
        //
        if (suffixLength == Constants.LOAD_EXTERNAL_DTD_FEATURE.length() &&
            featureId.endsWith(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }

        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.VALIDATE_DATATYPES_FEATURE.length() &&
            featureId.endsWith(Constants.VALIDATE_DATATYPES_FEATURE)) {
            return FeatureState.NOT_SUPPORTED;
        }

        // special performance feature: only component manager is allowed to set it.
        if (suffixLength == Constants.PARSER_SETTINGS.length() &&
            featureId.endsWith(Constants.PARSER_SETTINGS)) {
            return FeatureState.NOT_SUPPORTED;
        }
    }

    //
    // Not recognized
    //

    return super.checkFeature(featureId);

}
 
Example #25
Source File: XML11NonValidatingConfiguration.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId) throws XMLConfigurationException {

    //
    // Xerces Features
    //

    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // http://apache.org/xml/features/validation/dynamic
        //   Allows the parser to validate a document only when it
        //   contains a grammar. Validation is turned on/off based
        //   on each document instance, automatically.
        //
        if (suffixLength == Constants.DYNAMIC_VALIDATION_FEATURE.length() &&
            featureId.endsWith(Constants.DYNAMIC_VALIDATION_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }

        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE.length() &&
            featureId.endsWith(Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE)) {
            // REVISIT
            return FeatureState.NOT_SUPPORTED;
        }
        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.VALIDATE_CONTENT_MODELS_FEATURE.length() &&
            featureId.endsWith(Constants.VALIDATE_CONTENT_MODELS_FEATURE)) {
            // REVISIT
            return FeatureState.NOT_SUPPORTED;
        }
        //
        // http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar
        //
        if (suffixLength == Constants.LOAD_DTD_GRAMMAR_FEATURE.length() &&
            featureId.endsWith(Constants.LOAD_DTD_GRAMMAR_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }
        //
        // http://apache.org/xml/features/validation/nonvalidating/load-external-dtd
        //
        if (suffixLength == Constants.LOAD_EXTERNAL_DTD_FEATURE.length() &&
            featureId.endsWith(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }

        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.VALIDATE_DATATYPES_FEATURE.length() &&
            featureId.endsWith(Constants.VALIDATE_DATATYPES_FEATURE)) {
            return FeatureState.NOT_SUPPORTED;
        }

        // special performance feature: only component manager is allowed to set it.
        if (suffixLength == Constants.PARSER_SETTINGS.length() &&
            featureId.endsWith(Constants.PARSER_SETTINGS)) {
            return FeatureState.NOT_SUPPORTED;
        }
    }

    //
    // Not recognized
    //

    return super.checkFeature(featureId);

}
 
Example #26
Source File: StandardParserConfiguration.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId)
    throws XMLConfigurationException {

    //
    // Xerces Features
    //

    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // http://apache.org/xml/features/validation/schema
        //   Lets the user turn Schema validation support on/off.
        //
        if (suffixLength == Constants.SCHEMA_VALIDATION_FEATURE.length() &&
            featureId.endsWith(Constants.SCHEMA_VALIDATION_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }
        // activate full schema checking
        if (suffixLength == Constants.SCHEMA_FULL_CHECKING.length() &&
            featureId.endsWith(Constants.SCHEMA_FULL_CHECKING)) {
            return FeatureState.RECOGNIZED;
        }
        // Feature identifier: expose schema normalized value
        //  http://apache.org/xml/features/validation/schema/normalized-value
        if (suffixLength == Constants.SCHEMA_NORMALIZED_VALUE.length() &&
            featureId.endsWith(Constants.SCHEMA_NORMALIZED_VALUE)) {
            return FeatureState.RECOGNIZED;
        }
        // Feature identifier: send element default value via characters()
        // http://apache.org/xml/features/validation/schema/element-default
        if (suffixLength == Constants.SCHEMA_ELEMENT_DEFAULT.length() &&
            featureId.endsWith(Constants.SCHEMA_ELEMENT_DEFAULT)) {
            return FeatureState.RECOGNIZED;
        }
    }

    //
    // Not recognized
    //

    return super.checkFeature(featureId);

}
 
Example #27
Source File: NonValidatingConfiguration.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId)
    throws XMLConfigurationException {

    //
    // Xerces Features
    //

    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // http://apache.org/xml/features/validation/dynamic
        //   Allows the parser to validate a document only when it
        //   contains a grammar. Validation is turned on/off based
        //   on each document instance, automatically.
        //
        if (suffixLength == Constants.DYNAMIC_VALIDATION_FEATURE.length() &&
            featureId.endsWith(Constants.DYNAMIC_VALIDATION_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }
        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE.length() &&
            featureId.endsWith(Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE)) {
            // REVISIT
            return FeatureState.NOT_SUPPORTED;
        }
        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.VALIDATE_CONTENT_MODELS_FEATURE.length() &&
            featureId.endsWith(Constants.VALIDATE_CONTENT_MODELS_FEATURE)) {
            // REVISIT
            return FeatureState.NOT_SUPPORTED;
        }
        //
        // http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar
        //
        if (suffixLength == Constants.LOAD_DTD_GRAMMAR_FEATURE.length() &&
            featureId.endsWith(Constants.LOAD_DTD_GRAMMAR_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }
        //
        // http://apache.org/xml/features/validation/nonvalidating/load-external-dtd
        //
        if (suffixLength == Constants.LOAD_EXTERNAL_DTD_FEATURE.length() &&
            featureId.endsWith(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }

        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.VALIDATE_DATATYPES_FEATURE.length() &&
            featureId.endsWith(Constants.VALIDATE_DATATYPES_FEATURE)) {
            return FeatureState.NOT_SUPPORTED;
        }
    }

    //
    // Not recognized
    //

    return super.checkFeature(featureId);

}
 
Example #28
Source File: DTDConfiguration.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId)
    throws XMLConfigurationException {

    //
    // Xerces Features
    //

    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // http://apache.org/xml/features/validation/dynamic
        //   Allows the parser to validate a document only when it
        //   contains a grammar. Validation is turned on/off based
        //   on each document instance, automatically.
        //
        if (suffixLength == Constants.DYNAMIC_VALIDATION_FEATURE.length() &&
            featureId.endsWith(Constants.DYNAMIC_VALIDATION_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }

        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE.length() &&
            featureId.endsWith(Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE)) {
            // REVISIT
            return FeatureState.NOT_SUPPORTED;
        }
        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.VALIDATE_CONTENT_MODELS_FEATURE.length() &&
            featureId.endsWith(Constants.VALIDATE_CONTENT_MODELS_FEATURE)) {
            // REVISIT
            return FeatureState.NOT_SUPPORTED;
        }
        //
        // http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar
        //
        if (suffixLength == Constants.LOAD_DTD_GRAMMAR_FEATURE.length() &&
            featureId.endsWith(Constants.LOAD_DTD_GRAMMAR_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }
        //
        // http://apache.org/xml/features/validation/nonvalidating/load-external-dtd
        //
        if (suffixLength == Constants.LOAD_EXTERNAL_DTD_FEATURE.length() &&
            featureId.endsWith(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }

        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.VALIDATE_DATATYPES_FEATURE.length() &&
            featureId.endsWith(Constants.VALIDATE_DATATYPES_FEATURE)) {
            return FeatureState.NOT_SUPPORTED;
        }
    }

    //
    // Not recognized
    //

    return super.checkFeature(featureId);

}
 
Example #29
Source File: XML11NonValidatingConfiguration.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId) throws XMLConfigurationException {

    //
    // Xerces Features
    //

    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // http://apache.org/xml/features/validation/dynamic
        //   Allows the parser to validate a document only when it
        //   contains a grammar. Validation is turned on/off based
        //   on each document instance, automatically.
        //
        if (suffixLength == Constants.DYNAMIC_VALIDATION_FEATURE.length() &&
            featureId.endsWith(Constants.DYNAMIC_VALIDATION_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }

        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE.length() &&
            featureId.endsWith(Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE)) {
            // REVISIT
            return FeatureState.NOT_SUPPORTED;
        }
        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.VALIDATE_CONTENT_MODELS_FEATURE.length() &&
            featureId.endsWith(Constants.VALIDATE_CONTENT_MODELS_FEATURE)) {
            // REVISIT
            return FeatureState.NOT_SUPPORTED;
        }
        //
        // http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar
        //
        if (suffixLength == Constants.LOAD_DTD_GRAMMAR_FEATURE.length() &&
            featureId.endsWith(Constants.LOAD_DTD_GRAMMAR_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }
        //
        // http://apache.org/xml/features/validation/nonvalidating/load-external-dtd
        //
        if (suffixLength == Constants.LOAD_EXTERNAL_DTD_FEATURE.length() &&
            featureId.endsWith(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }

        //
        // http://apache.org/xml/features/validation/default-attribute-values
        //
        if (suffixLength == Constants.VALIDATE_DATATYPES_FEATURE.length() &&
            featureId.endsWith(Constants.VALIDATE_DATATYPES_FEATURE)) {
            return FeatureState.NOT_SUPPORTED;
        }

        // special performance feature: only component manager is allowed to set it.
        if (suffixLength == Constants.PARSER_SETTINGS.length() &&
            featureId.endsWith(Constants.PARSER_SETTINGS)) {
            return FeatureState.NOT_SUPPORTED;
        }
    }

    //
    // Not recognized
    //

    return super.checkFeature(featureId);

}
 
Example #30
Source File: StandardParserConfiguration.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check a feature. If feature is know and supported, this method simply
 * returns. Otherwise, the appropriate exception is thrown.
 *
 * @param featureId The unique identifier (URI) of the feature.
 *
 * @throws XMLConfigurationException Thrown for configuration error.
 *                                   In general, components should
 *                                   only throw this exception if
 *                                   it is <strong>really</strong>
 *                                   a critical error.
 */
protected FeatureState checkFeature(String featureId)
    throws XMLConfigurationException {

    //
    // Xerces Features
    //

    if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
        final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();

        //
        // http://apache.org/xml/features/validation/schema
        //   Lets the user turn Schema validation support on/off.
        //
        if (suffixLength == Constants.SCHEMA_VALIDATION_FEATURE.length() &&
            featureId.endsWith(Constants.SCHEMA_VALIDATION_FEATURE)) {
            return FeatureState.RECOGNIZED;
        }
        // activate full schema checking
        if (suffixLength == Constants.SCHEMA_FULL_CHECKING.length() &&
            featureId.endsWith(Constants.SCHEMA_FULL_CHECKING)) {
            return FeatureState.RECOGNIZED;
        }
        // Feature identifier: expose schema normalized value
        //  http://apache.org/xml/features/validation/schema/normalized-value
        if (suffixLength == Constants.SCHEMA_NORMALIZED_VALUE.length() &&
            featureId.endsWith(Constants.SCHEMA_NORMALIZED_VALUE)) {
            return FeatureState.RECOGNIZED;
        }
        // Feature identifier: send element default value via characters()
        // http://apache.org/xml/features/validation/schema/element-default
        if (suffixLength == Constants.SCHEMA_ELEMENT_DEFAULT.length() &&
            featureId.endsWith(Constants.SCHEMA_ELEMENT_DEFAULT)) {
            return FeatureState.RECOGNIZED;
        }
    }

    //
    // Not recognized
    //

    return super.checkFeature(featureId);

}