Method from xni.parser.AbstractConfiguration Detail: |
protected void addComponent(XMLComponent component) {
if (!fComponents.contains(component)) {
fComponents.addElement(component);
addRecognizedFeatures(component.getRecognizedFeatures());
addRecognizedProperties(component.getRecognizedProperties());
}
}
Adds a component to list of configurable components. If the
same component is added multiple times, the component is
added only the first time.
This method helps manage the components in the configuration.
Therefore, all subclasses should call this method to add the
components specific to the configuration. |
public void addRecognizedFeatures(String[] featureIds) {
//
// XMLParserConfiguration methods
//
int length = featureIds != null ? featureIds.length : 0;
for (int i = 0; i < length; i++) {
String featureId = featureIds[i];
if (!fRecognizedFeatures.contains(featureId)) {
fRecognizedFeatures.addElement(featureId);
}
}
}
Allows a parser to add parser specific features to be recognized
and managed by the parser configuration. |
public void addRecognizedProperties(String[] propertyIds) {
int length = propertyIds != null ? propertyIds.length : 0;
for (int i = 0; i < length; i++) {
String propertyId = propertyIds[i];
if (!fRecognizedProperties.contains(propertyId)) {
fRecognizedProperties.addElement(propertyId);
}
}
}
Allows a parser to add parser specific properties to be recognized
and managed by the parser configuration. |
public XMLDTDContentModelHandler getDTDContentModelHandler() {
return fDTDContentModelHandler;
}
Returns the registered DTD content model handler. |
public XMLDTDHandler getDTDHandler() {
return fDTDHandler;
}
Returns the registered DTD handler. |
public XMLDocumentHandler getDocumentHandler() {
return fDocumentHandler;
}
Returns the registered document handler. |
public XMLEntityResolver getEntityResolver() {
return fEntityResolver;
}
Returns the registered entity resolver. |
public XMLErrorHandler getErrorHandler() {
return fErrorHandler;
}
Returns the registered error handler. |
public boolean getFeature(String featureId) throws XMLConfigurationException {
if (!fRecognizedFeatures.contains(featureId)) {
short type = XMLConfigurationException.NOT_RECOGNIZED;
throw new XMLConfigurationException(type, featureId);
}
Boolean state = (Boolean)fFeatures.get(featureId);
return state != null ? state.booleanValue() : false;
}
Returns the state of a feature. |
public Locale getLocale() {
return fLocale;
}
|
public Object getProperty(String propertyId) throws XMLConfigurationException {
if (!fRecognizedProperties.contains(propertyId)) {
short type = XMLConfigurationException.NOT_RECOGNIZED;
throw new XMLConfigurationException(type, propertyId);
}
Object value = fProperties.get(propertyId);
return value;
}
Returns the value of a property. |
protected void openInputSourceStream(XMLInputSource source) throws IOException {
if (source.getCharacterStream() != null) {
return;
}
InputStream stream = source.getByteStream();
if (stream == null) {
String systemId = source.getSystemId();
try {
URL url = new URL(systemId);
stream = url.openStream();
}
catch (MalformedURLException e) {
stream = new FileInputStream(systemId);
}
source.setByteStream(stream);
}
}
This method tries to open the necessary stream for the given
XMLInputSource. If the input source already has a character
stream (java.io.Reader) or a byte stream (java.io.InputStream)
set, this method returns immediately. However, if no character
or byte stream is already open, this method attempts to open
an input stream using the source's system identifier. |
abstract public void parse(XMLInputSource inputSource) throws IOException, XNIException
Parse an XML document.
The parser can use this method to instruct this configuration
to begin parsing an XML document from any valid input source
(a character stream, a byte stream, or a URI).
Parsers may not invoke this method while a parse is in progress.
Once a parse is complete, the parser may then parse another XML
document.
This method is synchronous: it will not return until parsing
has ended. If a client application wants to terminate
parsing early, it should throw an exception.
Note: This method needs to be implemented
by the subclass. |
protected void resetComponents() throws XMLConfigurationException {
int length = fComponents.size();
for (int i = 0; i < length; i++) {
XMLComponent component = (XMLComponent)fComponents.elementAt(i);
component.reset(this);
}
}
Resets all of the registered components. Before the subclassed
configuration begins parsing, it should call this method to
reset the components. |
public void setDTDContentModelHandler(XMLDTDContentModelHandler handler) {
fDTDContentModelHandler = handler;
}
Sets the DTD content model handler. |
public void setDTDHandler(XMLDTDHandler handler) {
fDTDHandler = handler;
}
|
public void setDocumentHandler(XMLDocumentHandler handler) {
fDocumentHandler = handler;
}
Sets the document handler to receive information about the document. |
public void setEntityResolver(XMLEntityResolver resolver) {
fEntityResolver = resolver;
}
Sets the entity resolver. |
public void setErrorHandler(XMLErrorHandler handler) {
fErrorHandler = handler;
}
|
public void setFeature(String featureId,
boolean state) throws XMLConfigurationException {
if (!fRecognizedFeatures.contains(featureId)) {
short type = XMLConfigurationException.NOT_RECOGNIZED;
throw new XMLConfigurationException(type, featureId);
}
fFeatures.put(featureId, state ? Boolean.TRUE : Boolean.FALSE);
int length = fComponents.size();
for (int i = 0; i < length; i++) {
XMLComponent component = (XMLComponent)fComponents.elementAt(i);
component.setFeature(featureId, state);
}
}
Sets the state of a feature. This method is called by the parser
and gets propagated to components in this parser configuration. |
public void setLocale(Locale locale) {
fLocale = locale;
}
Set the locale to use for messages. |
public void setProperty(String propertyId,
Object value) throws XMLConfigurationException {
if (!fRecognizedProperties.contains(propertyId)) {
short type = XMLConfigurationException.NOT_RECOGNIZED;
throw new XMLConfigurationException(type, propertyId);
}
if (value != null) {
fProperties.put(propertyId, value);
}
else {
fProperties.remove(propertyId);
}
int length = fComponents.size();
for (int i = 0; i < length; i++) {
XMLComponent component = (XMLComponent)fComponents.elementAt(i);
component.setProperty(propertyId, value);
}
}
Sets the value of a property. This method is called by the parser
and gets propagated to components in this parser configuration. |