Interface com.ibm.xml.parser.ElementFactory
- Implementing Classes:
- DefaultElementFactory
- public interface ElementFactory
An interface for receiving control when the various components of the Document Object
Model (DOM) and XML4J need to be created and initialized by the XML4J parser.
This interface is primarily for use by the XML4J parser, but may be implemented
by applications which wish to override the DefaultElementFactory
in its
entirety.
A factory provides a generalized constructor for the XML4J parser. In order to
direct the XML4J parser to call the constructor for the new subclass, the application-defined
factory is registered to the parser instance, prior to parsing the input stream, by using
the setElementFactory
method. The registered element factory calls the
appropriate constructor as required.
If only a small number of customized DOM or XML4J components are required, the following
design pattern should be used in preference to reimplementing the entire ElementFactory
interface. The following example illustrates the use of the ElementFactory interface in order
to subclass the TXElement Node in favor of a MyElement Node:
class MyElement extends TXElement {
// Customized MyElement logic
}
class MyElementFactory extends DefaultElementFactory { // Extend default factory rather
// than reimplement ElementFactory.
public TXElement createElement(String name) {
MyElement el = new MyElement(name);
el.setFactory(this);
return el;
}
... // Additional constructors for other customized DOM or XML4J components.
}
public static void main(String[] argv) {
...
Parser p = new Parser(...);
p.setElementFactory(new MyElementFactory()); // register customized constructor(s)
TXDocument doc = p.readStream(is);
// doc instance now contains MyElement instances instead of TXElement instances.
...
}
- Version:
- Revision: 97 1.5 src/com/ibm/xml/parser/ElementFactory.java, xml4jsrc, xml4j-jtcsv, xml4j_1_0_4
- See Also:
- setElementFactory
Method Summary
|
AttDef
|
createAttDef(java.lang.String name)
Interface to be implemented for receiving control when the XML4J parser requires
that a StylesheetPI instance be created and initialized.
|
Attlist
|
createAttlist(java.lang.String name)
Interface to be implemented for receiving control when the XML4J parser requires
that an Attlist instance be created and initialized.
|
TXAttribute
|
createAttribute(java.lang.String name,
java.lang.String value)
Interface to be implemented for receiving control when the XML4J parser requires
that a TXAttribute instance be created and initialized.
|
TXAttributeList
|
createAttributeList()
Interface to be implemented for receiving control when the XML4J parser requires
that a TXAttributeList instance be created and initialized.
|
TXCDATASection
|
createCDATA(java.lang.String data)
Interface to be implemented for receiving control when the XML4J parser requires
that a TXCDATASection instance be created and initialized.
|
TXComment
|
createComment(java.lang.String data)
Interface to be implemented for receiving control when the XML4J parser requires
that a TXComment instance be created and initialized.
|
ContentModel
|
createContentModel(int type)
Interface to be implemented for receiving control when the XML4J parser requires
that a content model instance be created and initialized of a type other than
MODEL_GROUP.
|
ContentModel
|
createContentModel(CMNode modelGroupNode)
Interface to be implemented for receiving control when the XML4J parser requires
that a content model instance be created and initialized of type MODEL_GROUP.
|
TXDocument
|
createDocument()
Interface to be implemented for receiving control when the XML4J parser requires
that a TXDocument instance be created and initialized.
|
DTD
|
createDTD()
Interface to be implemented for receiving control when the XML4J parser requires
that a DTD instance be created and initialized.
|
DTD
|
createDTD(java.lang.String name,
ExternalID externalID)
Interface to be implemented for receiving control when the XML4J parser requires
that a DTD instance be created and initialized.
|
TXElement
|
createElement(java.lang.String name)
Interface to be implemented for receiving control when the XML4J parser requires
that a TXElement instance be created and initialized.
|
ElementDecl
|
createElementDecl(java.lang.String name,
ContentModel contentModel)
Interface to be implemented for receiving control when the XML4J parser requires
that an ElementDecl instance be created and initialized.
|
Entity
|
createEntity(java.lang.String name,
java.lang.String value,
boolean isParameter)
Interface to be implemented for receiving control when the XML4J parser requires
that an internal Entity instance be created and initialized.
|
Entity
|
createEntity(java.lang.String name,
ExternalID externalID,
boolean isParameter,
java.lang.String ndata)
Interface to be implemented for receiving control when the XML4J parser requires
that an external Entity instance be created and initialized.
|
GeneralReference
|
createGeneralReference(java.lang.String name)
Interface to be implemented for receiving control when the XML4J parser requires
that a general reference instance be created and initialized.
|
java.security.MessageDigest
|
createMessageDigest()
Interface to be implemented for receiving control when the XML4J parser requires
that a MessageDigest instance be created and initialized.
|
NamespacePI
|
createNamespacePI(java.lang.String name,
java.lang.String data,
java.lang.String nsURI,
java.lang.String prefixName,
java.lang.String srcURI)
Interface to be implemented for receiving control when the XML4J parser requires
that a NamespacePI instance be created and initialized.
|
TXNotation
|
createNotation(java.lang.String name,
ExternalID externalID)
Interface to be implemented for receiving control when the XML4J parser requires
that a TXNotation instance be created and initialized.
|
TXPI
|
createPI(java.lang.String name,
java.lang.String data)
Interface to be implemented for receiving control when the XML4J parser requires
that a TXPI instance be created and initialized.
|
StylesheetPI
|
createStylesheetPI(java.lang.String name,
java.lang.String data,
java.lang.String type,
java.lang.String hrefURI,
java.lang.String title)
Interface to be implemented for receiving control when the XML4J parser requires
that a StylesheetPI instance be created and initialized.
|
TXText
|
createText(java.lang.String data)
Interface to be implemented for receiving control when the XML4J parser requires
that a TXText instance be created and initialized with a default ignorable
whitespace setting.
|
TXText
|
createText(java.lang.String data,
boolean isIgnorableWhitespace)
Interface to be implemented for receiving control when the XML4J parser requires
that a TXText instance be created and initialized with a specified ignorable
whitespace setting.
|
TXText
|
createText(char[] chararray,
int offset,
int length,
boolean isIgnorableWhitespace)
Interface to be implemented for receiving control when the XML4J parser requires
that a TXText instance be created and initialized with a specified ignorable
whitespace setting.
|
createElement
public TXElement createElement(java.lang.String name)
- Interface to be implemented for receiving control when the XML4J parser requires
that a TXElement instance be created and initialized.
Control is transferred after the parsing the Element's start tag, but prior to parsing any children.
- Parameters:
name
- The name of the Element.
- Returns:
- The newly initialized Element Node.
- See Also:
- TXElement, createElement
createAttributeList
public TXAttributeList createAttributeList()
- Interface to be implemented for receiving control when the XML4J parser requires
that a TXAttributeList instance be created and initialized.
Control is transferred after the initial Attribute of an Element.
- Returns:
- The newly initialized Attribute list.
- See Also:
- TXAttributeList, createAttributeList
createAttribute
public TXAttribute createAttribute(java.lang.String name,
java.lang.String value)
- Interface to be implemented for receiving control when the XML4J parser requires
that a TXAttribute instance be created and initialized.
- Parameters:
name
- The name of the Attribute.
value
- The value of the Attribute.
- Returns:
- The newly initialized Attribute Node.
- See Also:
- TXAttribute, createAttribute
createText
public TXText createText(java.lang.String data)
- Interface to be implemented for receiving control when the XML4J parser requires
that a TXText instance be created and initialized with a default ignorable
whitespace setting.
- Parameters:
data
- The actual content of the Text Node.
- Returns:
- The newly initialized Text Node.
- See Also:
- TXText, createText
createText
public TXText createText(java.lang.String data,
boolean isIgnorableWhitespace)
- Interface to be implemented for receiving control when the XML4J parser requires
that a TXText instance be created and initialized with a specified ignorable
whitespace setting.
This method is never called by the parser.
- Parameters:
data
- The actual content of the Text Node.
isIgnorableWhitespace
- =true indicates whitespace is ignored; =false indicates whitespace is significant.
- Returns:
- The newly initialized Text Node.
- See Also:
- setIsIgnorableWhitespace, createText
createText
public TXText createText(char[] chararray,
int offset,
int length,
boolean isIgnorableWhitespace)
- Interface to be implemented for receiving control when the XML4J parser requires
that a TXText instance be created and initialized with a specified ignorable
whitespace setting.
- Parameters:
chararray
- an array of chracter including the actual content of the Text Node.
offset
- a position of starting content.
length
- a length of content
isIgnorableWhitespace
- =true indicates whitespace is ignored; =false indicates whitespace is significant.
- Returns:
- The newly initialized Text Node.
- See Also:
- setIsIgnorableWhitespace, createText
createCDATA
public TXCDATASection createCDATA(java.lang.String data)
- Interface to be implemented for receiving control when the XML4J parser requires
that a TXCDATASection instance be created and initialized.
- Parameters:
data
- The actual content of the CDATASection Node.
- Returns:
- The newly initialized CDATASection Node.
- See Also:
- TXCDATASection, createCDATA
createComment
public TXComment createComment(java.lang.String data)
- Interface to be implemented for receiving control when the XML4J parser requires
that a TXComment instance be created and initialized.
- Parameters:
data
- The actual content of the Comment Node.
- Returns:
- The newly initialized Comment Node.
- See Also:
- TXComment, createComment
createPI
public TXPI createPI(java.lang.String name,
java.lang.String data)
- Interface to be implemented for receiving control when the XML4J parser requires
that a TXPI instance be created and initialized.
- Parameters:
name
- The first token following the markup.
data
- From the character immediately after name to the
character immediately preceding the ?>
.
- Returns:
- The newly initialized PI Node.
- See Also:
- createNamespacePI, createStylesheetPI, TXPI, createPI
createNamespacePI
public NamespacePI createNamespacePI(java.lang.String name,
java.lang.String data,
java.lang.String nsURI,
java.lang.String prefixName,
java.lang.String srcURI)
- Interface to be implemented for receiving control when the XML4J parser requires
that a NamespacePI instance be created and initialized.
- Parameters:
name
- The first token following the markup (i.e. "xml:namespace").
data
- From the character immediately after the name to the character immediately preceding the ?>
.
nsURI
- The value of the ns=
attribute.
prefixName
- The value of the prefix=
attribute.
srcURI
- The value of the src=
attribute, or null.
- Returns:
- The newly initialized namespace PI Node.
- See Also:
- createPI, createStylesheetPI, NamespacePI, createNamespacePI
createStylesheetPI
public StylesheetPI createStylesheetPI(java.lang.String name,
java.lang.String data,
java.lang.String type,
java.lang.String hrefURI,
java.lang.String title)
- Interface to be implemented for receiving control when the XML4J parser requires
that a StylesheetPI instance be created and initialized.
- Parameters:
name
- The first token following the markup (e.g. "xml:stylesheet"
).
data
- From the character immediately after name to the character immediately preceding the ?>
.
type
- The value of the type=
attribute.
hrefURI
- The value of the href=
attribute.
title
- The value of the title=
attribute, or null.
- Returns:
- The newly initialized stylesheet PI Node.
- See Also:
- createPI, createNamespacePI, StylesheetPI, createStylesheetPI
createDocument
public TXDocument createDocument()
- Interface to be implemented for receiving control when the XML4J parser requires
that a TXDocument instance be created and initialized.
Control is transferred before parsing any PIs, comments, DTDs, and the root Document Element.
- Returns:
- The newly initialized Document Node.
- See Also:
- TXDocument, createDocument
createNotation
public TXNotation createNotation(java.lang.String name,
ExternalID externalID)
- Interface to be implemented for receiving control when the XML4J parser requires
that a TXNotation instance be created and initialized.
- Parameters:
name
- The name of the Notation.
externalID
- The public or system identifier which defines the DTD's notation.
- Returns:
- The newly initialized Notation Node.
- See Also:
- TXNotation, createNotation
createDTD
public DTD createDTD()
- Interface to be implemented for receiving control when the XML4J parser requires
that a DTD instance be created and initialized.
Control is transferred after parsing the DOCTYPE tag, but prior to parsing any
constituent objects of the internal or external DTD subset.
- Returns:
- The newly initialized DTD.
- See Also:
- DTD, createDTD
createDTD
public DTD createDTD(java.lang.String name,
ExternalID externalID)
- Interface to be implemented for receiving control when the XML4J parser requires
that a DTD instance be created and initialized.
Control is transferred after parsing the DOCTYPE tag, but prior to parsing any
constituent objects of the internal or external DTD subset.
- Parameters:
name
- The name of the DTD. This value is also known as the DOCTYPE
and the root Element Name.
externalID
- The external ID associated with this DTD.
- Returns:
- The newly initialized DTD.
- See Also:
- DTD, createDTD
createElementDecl
public ElementDecl createElementDecl(java.lang.String name,
ContentModel contentModel)
- Interface to be implemented for receiving control when the XML4J parser requires
that an ElementDecl instance be created and initialized.
Control is transferred after parsing the entire element declaration.
- Parameters:
name
- The element definition's name.
contentModel
- The content model to associate with this element definition.
- Returns:
- The newly initialized element definition.
- See Also:
- ElementDecl, createElementDecl
createContentModel
public ContentModel createContentModel(int type)
- Interface to be implemented for receiving control when the XML4J parser requires
that a content model instance be created and initialized of a type other than
MODEL_GROUP.
Control is transferred after parsing the entire content model.
- Parameters:
type
- The type of the content model.
Must be one of org.w3c.dom.ElementDefinition#ContentType.
Note that the XML4J parser will never set #PCDATA
as the
content type; MODEL_GROUP
will be set instead.
- Returns:
- The newly initialized content model.
- See Also:
- ElementDefinition, ElementDecl, createContentModel
createContentModel
public ContentModel createContentModel(CMNode modelGroupNode)
- Interface to be implemented for receiving control when the XML4J parser requires
that a content model instance be created and initialized of type MODEL_GROUP.
Control is transferred after parsing the entire content model.
- Parameters:
modelGroupNode
- The content model associated with the model group.
- Returns:
- The newly initialized content model.
- See Also:
- ElementDefinition, ElementDecl, createContentModel
createAttlist
public Attlist createAttlist(java.lang.String name)
- Interface to be implemented for receiving control when the XML4J parser requires
that an Attlist instance be created and initialized.
Control is transferred after parsing the attribute list name, but prior to parsing
any constituent attribute definitions.
- Parameters:
name
- The attribute list name; this value is also known as the Element type.
- Returns:
- The newly initialized attribute list definition.
- See Also:
- Attlist, createAttlist
createAttDef
public AttDef createAttDef(java.lang.String name)
- Interface to be implemented for receiving control when the XML4J parser requires
that a StylesheetPI instance be created and initialized.
- Parameters:
name
- The name of this attribute.
- Returns:
- The newly initialized attribute definition.
- See Also:
- AttDef, createAttDef
createEntity
public Entity createEntity(java.lang.String name,
java.lang.String value,
boolean isParameter)
- Interface to be implemented for receiving control when the XML4J parser requires
that an internal Entity instance be created and initialized.
- Parameters:
name
- Name of this Entity.
value
- The XML-encoded value that was directly assigned to the Entity.
isParameter
- =true if a parameter Entity; otherwise =false.
- Returns:
- The newly initialized Entity.
- See Also:
- Entity, createEntity
createEntity
public Entity createEntity(java.lang.String name,
ExternalID externalID,
boolean isParameter,
java.lang.String ndata)
- Interface to be implemented for receiving control when the XML4J parser requires
that an external Entity instance be created and initialized.
- Parameters:
name
- Name of the Entity.
externalID
- The reference(s) to the external entity to retrieve.
isParameter
- =true if a parameter Entity; otherwise =false.
ndata
- The notation associated with the binary Entity.
- Returns:
- The newly initialized Entity.
- See Also:
- Entity, createEntity, ExternalID
createGeneralReference
public GeneralReference createGeneralReference(java.lang.String name)
- Interface to be implemented for receiving control when the XML4J parser requires
that a general reference instance be created and initialized.
Control is transferred after parsing the general reference, but prior to parsing
the entity referred to by the reference.
- Parameters:
name
- The name of the Entity.
- Returns:
- The newly initialized general reference.
- See Also:
- GeneralReference, createGeneralReference
createMessageDigest
public java.security.MessageDigest createMessageDigest() throws java.security.NoSuchAlgorithmException
- Interface to be implemented for receiving control when the XML4J parser requires
that a MessageDigest instance be created and initialized.
- Returns:
- The newly initialized message digest.
- Throws:
- java.security.NoSuchAlgorithmException - Thrown if the message digest algorithm is not locally available
- See Also:
- getInstance, createMessageDigest, setDigestAlgorithm