| Contents | Package | Class | Tree | Deprecated | Index | Help | XML for Java | ||
| PREV | NEXT | SHOW LISTS | HIDE LISTS | ||
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.
...
}
| Method Summary | |
| AttDef | createAttDef(java.lang.String name)
|
| Attlist | createAttlist(java.lang.String name)
|
| TXAttribute | createAttribute(java.lang.String name,
java.lang.String value)
|
| TXAttributeList | createAttributeList()
|
| TXCDATASection | createCDATA(java.lang.String data)
|
| TXComment | createComment(java.lang.String data)
|
| ContentModel | createContentModel(int type)
|
| ContentModel | createContentModel(CMNode modelGroupNode)
|
| TXDocument | createDocument()
|
| DTD | createDTD()
|
| DTD | createDTD(java.lang.String name,
ExternalID externalID)
|
| TXElement | createElement(java.lang.String name)
|
| ElementDecl | createElementDecl(java.lang.String name,
ContentModel contentModel)
|
| Entity | createEntity(java.lang.String name,
java.lang.String value,
boolean isParameter)
|
| Entity | createEntity(java.lang.String name,
ExternalID externalID,
boolean isParameter,
java.lang.String ndata)
|
| GeneralReference | createGeneralReference(java.lang.String name)
|
| java.security.MessageDigest | createMessageDigest()
|
| NamespacePI | createNamespacePI(java.lang.String name,
java.lang.String data,
java.lang.String nsURI,
java.lang.String prefixName,
java.lang.String srcURI)
|
| TXNotation | createNotation(java.lang.String name,
ExternalID externalID)
|
| TXPI | createPI(java.lang.String name,
java.lang.String data)
|
| StylesheetPI | createStylesheetPI(java.lang.String name,
java.lang.String data,
java.lang.String type,
java.lang.String hrefURI,
java.lang.String title)
|
| TXText | createText(java.lang.String data)
|
| TXText | createText(java.lang.String data,
boolean isIgnorableWhitespace)
|
| TXText | createText(char[] chararray,
int offset,
int length,
boolean isIgnorableWhitespace)
|
| byte[] | makeDigest(Child child)
|
| void | print(Child child,
java.io.PrintWriter pw,
java.lang.String enc)
|
| java.lang.String | toString(Child child,
java.lang.String enc)
|
| Method Detail |
public TXElement createElement(java.lang.String name)
name
- The name of the Element.
public TXAttributeList createAttributeList()
public TXAttribute createAttribute(java.lang.String name,
java.lang.String value)
name
- The name of the Attribute.
value
- The value of the Attribute.
public TXText createText(java.lang.String data)
data
- The actual content of the Text Node.
public TXText createText(java.lang.String data,
boolean isIgnorableWhitespace)
This method is never called by the parser.
data
- The actual content of the Text Node.
isIgnorableWhitespace
- =true indicates whitespace is ignored; =false indicates whitespace is significant.
public TXText createText(char[] chararray,
int offset,
int length,
boolean isIgnorableWhitespace)
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.
public TXCDATASection createCDATA(java.lang.String data)
data
- The actual content of the CDATASection Node.
public TXComment createComment(java.lang.String data)
data
- The actual content of the Comment Node.
public TXPI createPI(java.lang.String name,
java.lang.String data)
name
- The first token following the markup.
data
- From the character immediately after name to the
character immediately preceding the ?>.
public NamespacePI createNamespacePI(java.lang.String name,
java.lang.String data,
java.lang.String nsURI,
java.lang.String prefixName,
java.lang.String srcURI)
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.
public StylesheetPI createStylesheetPI(java.lang.String name,
java.lang.String data,
java.lang.String type,
java.lang.String hrefURI,
java.lang.String title)
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.
public TXDocument createDocument()
public TXNotation createNotation(java.lang.String name,
ExternalID externalID)
name
- The name of the Notation.
externalID
- The public or system identifier which defines the DTD's notation.
public DTD createDTD()
public DTD createDTD(java.lang.String name,
ExternalID externalID)
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.
public ElementDecl createElementDecl(java.lang.String name,
ContentModel contentModel)
name
- The element definition's name.
contentModel
- The content model to associate with this element definition.
public ContentModel createContentModel(int type)
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.
public ContentModel createContentModel(CMNode modelGroupNode)
modelGroupNode
- The content model associated with the model group.
public Attlist createAttlist(java.lang.String name)
name
- The attribute list name; this value is also known as the Element type.
public AttDef createAttDef(java.lang.String name)
name
- The name of this attribute.
public Entity createEntity(java.lang.String name,
java.lang.String value,
boolean isParameter)
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.
public Entity createEntity(java.lang.String name,
ExternalID externalID,
boolean isParameter,
java.lang.String ndata)
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.
public GeneralReference createGeneralReference(java.lang.String name)
name
- The name of the Entity.
public java.security.MessageDigest createMessageDigest() throws java.security.NoSuchAlgorithmException
public java.lang.String toString(Child child,
java.lang.String enc)
<, >, &, ', and "
should be represented as <, >, &, ', " .
child
- Child node to return in XML format.
enc
- Java character encoding to use.
public void print(Child child,
java.io.PrintWriter pw,
java.lang.String enc)
<, >, &, ', and "
should be represented as <, >, &, ', " .
child
- Child node to print in XML format.
pw
- The character output stream to use.
enc
- Java character encoding in use by pw.
public byte[] makeDigest(Child child)
Message digests are secure one-way hash functions that take arbitrary-sized data and output a fixed-length hash value.
child
- Child node for which to generate a message digest.
| Contents | Package | Class | Tree | Deprecated | Index | Help | |||
| PREV | NEXT | SHOW LISTS | HIDE LISTS | ||