org.apache.xerces.util
public class: ParserConfigurationSettings [javadoc |
source]
java.lang.Object
org.apache.xerces.util.ParserConfigurationSettings
All Implemented Interfaces:
XMLComponentManager
Direct Known Subclasses:
XPointerParserConfiguration, SoftReferenceSymbolTableConfiguration, StandardParserConfiguration, PSVIConfiguration, XIncludeAwareParserConfiguration, NonValidatingParserConfiguration, DTDConfiguration, DOMConfigurationImpl, XML11Configuration, XML11DTDConfiguration, XMLSchemaValidatorComponentManager, IntegratedParserConfiguration, XMLGrammarCachingConfiguration, SchemaParsingConfig, BasicParserConfiguration, XML11NonValidatingConfiguration, SecurityConfiguration, NonValidatingConfiguration, XIncludeParserConfiguration
This class implements the basic operations for managing parser
configuration features and properties. This utility class can
be used as a base class for parser configurations or separately
to encapsulate a number of parser settings as a component
manager.
This class can be constructed with a "parent" settings object
(in the form of an XMLComponentManager
) that allows
parser configuration settings to be "chained" together.
- author:
Andy
- Clark, IBM
- version:
$
- Id: ParserConfigurationSettings.java 447241 2006-09-18 05:12:57Z mrglavas $
Field Summary |
---|
protected static final String | PARSER_SETTINGS | |
protected ArrayList | fRecognizedProperties | Recognized properties. |
protected HashMap | fProperties | Properties. |
protected ArrayList | fRecognizedFeatures | Recognized features. |
protected HashMap | fFeatures | Features. |
protected XMLComponentManager | fParentSettings | Parent parser configuration settings. |
Method from org.apache.xerces.util.ParserConfigurationSettings Detail: |
public void addRecognizedFeatures(String[] featureIds) {
// add recognized features
int featureIdsCount = featureIds != null ? featureIds.length : 0;
for (int i = 0; i < featureIdsCount; i++) {
String featureId = featureIds[i];
if (!fRecognizedFeatures.contains(featureId)) {
fRecognizedFeatures.add(featureId);
}
}
}
Allows a parser to add parser specific features to be recognized
and managed by the parser configuration. |
public void addRecognizedProperties(String[] propertyIds) {
// add recognizedProperties
int propertyIdsCount = propertyIds != null ? propertyIds.length : 0;
for (int i = 0; i < propertyIdsCount; i++) {
String propertyId = propertyIds[i];
if (!fRecognizedProperties.contains(propertyId)) {
fRecognizedProperties.add(propertyId);
}
}
}
Allows a parser to add parser specific properties to be recognized
and managed by the parser configuration. |
protected void checkFeature(String featureId) throws XMLConfigurationException {
// check feature
if (!fRecognizedFeatures.contains(featureId)) {
if (fParentSettings != null) {
fParentSettings.getFeature(featureId);
}
else {
short type = XMLConfigurationException.NOT_RECOGNIZED;
throw new XMLConfigurationException(type, featureId);
}
}
}
Check a feature. If feature is known and supported, this method simply
returns. Otherwise, the appropriate exception is thrown. |
protected void checkProperty(String propertyId) throws XMLConfigurationException {
// check property
if (!fRecognizedProperties.contains(propertyId)) {
if (fParentSettings != null) {
fParentSettings.getProperty(propertyId);
}
else {
short type = XMLConfigurationException.NOT_RECOGNIZED;
throw new XMLConfigurationException(type, propertyId);
}
}
}
Check a property. If the property is known and supported, this method
simply returns. Otherwise, the appropriate exception is thrown. |
public boolean getFeature(String featureId) throws XMLConfigurationException {
Boolean state = (Boolean) fFeatures.get(featureId);
if (state == null) {
checkFeature(featureId);
return false;
}
return state.booleanValue();
}
Returns the state of a feature. |
public Object getProperty(String propertyId) throws XMLConfigurationException {
Object propertyValue = fProperties.get(propertyId);
if (propertyValue == null) {
checkProperty(propertyId);
}
return propertyValue;
}
Returns the value of a property. |
public void setFeature(String featureId,
boolean state) throws XMLConfigurationException {
// check and store
checkFeature(featureId);
fFeatures.put(featureId, state ? Boolean.TRUE : Boolean.FALSE);
}
Set the state of a feature.
Set the state of any feature in a SAX2 parser. The parser
might not recognize the feature, and if it does recognize
it, it might not be able to fulfill the request. |
public void setProperty(String propertyId,
Object value) throws XMLConfigurationException {
// check and store
checkProperty(propertyId);
fProperties.put(propertyId, value);
}
|