| Method from org.apache.xerces.impl.XMLDocumentScannerImpl Detail: |
protected Dispatcher createContentDispatcher() {
return new ContentDispatcher();
}
Creates a content dispatcher. |
public void endEntity(String name,
Augmentations augs) throws XNIException {
super.endEntity(name, augs);
// call handler
if (fDocumentHandler != null && name.equals("[xml]")) {
fDocumentHandler.endDocument(null);
}
}
This method notifies the end of an entity. The DTD has the pseudo-name
of "[dtd]" parameter entity names start with '%'; and general entities
are just specified by their name. |
public Boolean getFeatureDefault(String featureId) {
for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
if (RECOGNIZED_FEATURES[i].equals(featureId)) {
return FEATURE_DEFAULTS[i];
}
}
return super.getFeatureDefault(featureId);
}
Returns the default state for a feature, or null if this
component does not want to report a default value for this
feature. |
public Object getPropertyDefault(String propertyId) {
for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {
return PROPERTY_DEFAULTS[i];
}
}
return super.getPropertyDefault(propertyId);
}
Returns the default state for a property, or null if this
component does not want to report a default value for this
property. |
public String[] getRecognizedFeatures() {
String[] featureIds = super.getRecognizedFeatures();
int length = featureIds != null ? featureIds.length : 0;
String[] combinedFeatureIds = new String[length + RECOGNIZED_FEATURES.length];
if (featureIds != null) {
System.arraycopy(featureIds, 0, combinedFeatureIds, 0, featureIds.length);
}
System.arraycopy(RECOGNIZED_FEATURES, 0, combinedFeatureIds, length, RECOGNIZED_FEATURES.length);
return combinedFeatureIds;
}
Returns a list of feature identifiers that are recognized by
this component. This method may return null if no features
are recognized by this component. |
public String[] getRecognizedProperties() {
String[] propertyIds = super.getRecognizedProperties();
int length = propertyIds != null ? propertyIds.length : 0;
String[] combinedPropertyIds = new String[length + RECOGNIZED_PROPERTIES.length];
if (propertyIds != null) {
System.arraycopy(propertyIds, 0, combinedPropertyIds, 0, propertyIds.length);
}
System.arraycopy(RECOGNIZED_PROPERTIES, 0, combinedPropertyIds, length, RECOGNIZED_PROPERTIES.length);
return combinedPropertyIds;
}
Returns a list of property identifiers that are recognized by
this component. This method may return null if no properties
are recognized by this component. |
protected String getScannerStateName(int state) {
switch (state) {
case SCANNER_STATE_XML_DECL: return "SCANNER_STATE_XML_DECL";
case SCANNER_STATE_PROLOG: return "SCANNER_STATE_PROLOG";
case SCANNER_STATE_TRAILING_MISC: return "SCANNER_STATE_TRAILING_MISC";
case SCANNER_STATE_DTD_INTERNAL_DECLS: return "SCANNER_STATE_DTD_INTERNAL_DECLS";
case SCANNER_STATE_DTD_EXTERNAL: return "SCANNER_STATE_DTD_EXTERNAL";
case SCANNER_STATE_DTD_EXTERNAL_DECLS: return "SCANNER_STATE_DTD_EXTERNAL_DECLS";
}
return super.getScannerStateName(state);
}
Returns the scanner state name. |
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
super.reset(componentManager);
// other settings
fDoctypeName = null;
fDoctypePublicId = null;
fDoctypeSystemId = null;
fSeenDoctypeDecl = false;
fScanningDTD = false;
fExternalSubsetSource = null;
if (!fParserSettings) {
// parser settings have not been changed
fNamespaceContext.reset();
// setup dispatcher
setScannerState(SCANNER_STATE_XML_DECL);
setDispatcher(fXMLDeclDispatcher);
return;
}
// xerces features
try {
fLoadExternalDTD = componentManager.getFeature(LOAD_EXTERNAL_DTD);
}
catch (XMLConfigurationException e) {
fLoadExternalDTD = true;
}
try {
fDisallowDoctype = componentManager.getFeature(DISALLOW_DOCTYPE_DECL_FEATURE);
}
catch (XMLConfigurationException e) {
fDisallowDoctype = false;
}
// xerces properties
fDTDScanner = (XMLDTDScanner)componentManager.getProperty(DTD_SCANNER);
try {
fValidationManager = (ValidationManager)componentManager.getProperty(VALIDATION_MANAGER);
}
catch (XMLConfigurationException e) {
fValidationManager = null;
}
try {
fNamespaceContext = (NamespaceContext)componentManager.getProperty(NAMESPACE_CONTEXT);
}
catch (XMLConfigurationException e) { }
if (fNamespaceContext == null) {
fNamespaceContext = new NamespaceSupport();
}
fNamespaceContext.reset();
// setup dispatcher
setScannerState(SCANNER_STATE_XML_DECL);
setDispatcher(fXMLDeclDispatcher);
}
Resets the component. The component can query the component manager
about any features and properties that affect the operation of the
component. |
protected boolean scanDoctypeDecl() throws IOException, XNIException {
// spaces
if (!fEntityScanner.skipSpaces()) {
reportFatalError("MSG_SPACE_REQUIRED_BEFORE_ROOT_ELEMENT_TYPE_IN_DOCTYPEDECL",
null);
}
// root element name
fDoctypeName = fEntityScanner.scanName();
if (fDoctypeName == null) {
reportFatalError("MSG_ROOT_ELEMENT_TYPE_REQUIRED", null);
}
// external id
if (fEntityScanner.skipSpaces()) {
scanExternalID(fStrings, false);
fDoctypeSystemId = fStrings[0];
fDoctypePublicId = fStrings[1];
fEntityScanner.skipSpaces();
}
fHasExternalDTD = fDoctypeSystemId != null;
// Attempt to locate an external subset with an external subset resolver.
if (!fHasExternalDTD && fExternalSubsetResolver != null) {
fDTDDescription.setValues(null, null, fEntityManager.getCurrentResourceIdentifier().getExpandedSystemId(), null);
fDTDDescription.setRootName(fDoctypeName);
fExternalSubsetSource = fExternalSubsetResolver.getExternalSubset(fDTDDescription);
fHasExternalDTD = fExternalSubsetSource != null;
}
// call handler
if (fDocumentHandler != null) {
// NOTE: I don't like calling the doctypeDecl callback until
// end of the *full* doctype line (including internal
// subset) is parsed correctly but SAX2 requires that
// it knows the root element name and public and system
// identifier for the startDTD call. -Ac
if (fExternalSubsetSource == null) {
fDocumentHandler.doctypeDecl(fDoctypeName, fDoctypePublicId, fDoctypeSystemId, null);
}
else {
fDocumentHandler.doctypeDecl(fDoctypeName, fExternalSubsetSource.getPublicId(), fExternalSubsetSource.getSystemId(), null);
}
}
// is there an internal subset?
boolean internalSubset = true;
if (!fEntityScanner.skipChar('[")) {
internalSubset = false;
fEntityScanner.skipSpaces();
if (!fEntityScanner.skipChar(' >")) {
reportFatalError("DoctypedeclUnterminated", new Object[]{fDoctypeName});
}
fMarkupDepth--;
}
return internalSubset;
}
Scans a doctype declaration. |
public void setFeature(String featureId,
boolean state) throws XMLConfigurationException {
super.setFeature(featureId, state);
// Xerces properties
if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();
if (suffixLength == Constants.LOAD_EXTERNAL_DTD_FEATURE.length() &&
featureId.endsWith(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
fLoadExternalDTD = state;
return;
}
else if (suffixLength == Constants.DISALLOW_DOCTYPE_DECL_FEATURE.length() &&
featureId.endsWith(Constants.DISALLOW_DOCTYPE_DECL_FEATURE)) {
fDisallowDoctype = state;
return;
}
}
}
|
public void setInputSource(XMLInputSource inputSource) throws IOException {
fEntityManager.setEntityHandler(this);
fEntityManager.startDocumentEntity(inputSource);
//fDocumentSystemId = fEntityManager.expandSystemId(inputSource.getSystemId());
}
|
public void setProperty(String propertyId,
Object value) throws XMLConfigurationException {
super.setProperty(propertyId, value);
// Xerces properties
if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
if (suffixLength == Constants.DTD_SCANNER_PROPERTY.length() &&
propertyId.endsWith(Constants.DTD_SCANNER_PROPERTY)) {
fDTDScanner = (XMLDTDScanner)value;
}
if (suffixLength == Constants.NAMESPACE_CONTEXT_PROPERTY.length() &&
propertyId.endsWith(Constants.NAMESPACE_CONTEXT_PROPERTY)) {
if (value != null) {
fNamespaceContext = (NamespaceContext)value;
}
}
return;
}
}
Sets the value of a property. This method is called by the component
manager any time after reset when a property changes value.
Note: Components should silently ignore properties
that do not affect the operation of the component. |
public void startEntity(String name,
XMLResourceIdentifier identifier,
String encoding,
Augmentations augs) throws XNIException {
super.startEntity(name, identifier, encoding, augs);
// prepare to look for a TextDecl if external general entity
if (!name.equals("[xml]") && fEntityScanner.isExternal()) {
setScannerState(SCANNER_STATE_TEXT_DECL);
}
// call handler
if (fDocumentHandler != null && name.equals("[xml]")) {
fDocumentHandler.startDocument(fEntityScanner, encoding, fNamespaceContext, null);
}
}
This method notifies of the start of an entity. The DTD has the
pseudo-name of "[dtd]" parameter entity names start with '%'; and
general entities are just specified by their name. |