XML Parser for Java 1.1.16

com.ibm.xml.parser
Class ContentModel

java.lang.Object
  |
  +--com.ibm.xml.parser.ContentModel

public class ContentModel
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

ContentModel provides content model support for element declarations. Refer to ElementDecl for an overview of content models.

Version:
Revision: 93 1.12 src/com/ibm/xml/parser/ContentModel.java, xml4jsrc, xml4j-jtcsv, xml4j_1_1_16
See Also:
ElementDecl, Serialized Form

Constructor Summary
ContentModel(CMNode modelGroupNode)
          Constructor for content models of type MODEL_GROUP.
ContentModel(int type)
          Constructor for content models NOT of type MODEL_GROUP.
 
Method Summary
 java.lang.Object clone()
          Clone this content model using the appropriate factory.
 boolean equals(java.lang.Object obj)
           
 CMNode getContentModelNode()
          Returns the content model associated with this model group content model.
 TXDocument getFactory()
          Returns the factory used for creating this content model.
 java.lang.String getPseudoContentModel()
          Returns the pseudo content model being used in place of an actual content model.
 int hashCode()
           
 void setContentModelNode(CMNode modelGroupNode)
          Sets the content model associated with this model group content model.
 void setFactory(TXDocument factory)
          Sets the factory to be used in creating this content model.
 void setPseudoContentModel(java.lang.String literal)
          Sets the pseudo content model being used in place of an actual content model.
 java.lang.String toString()
          Returns this content model in XML format.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContentModel

public ContentModel(int type)
Constructor for content models NOT of type MODEL_GROUP.
Parameters:
type - The type for this 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.

ContentModel

public ContentModel(CMNode modelGroupNode)
Constructor for content models of type MODEL_GROUP.
Parameters:
modelGroupNode - The content model associated with the model group.
Method Detail

clone

public java.lang.Object clone()
Clone this content model using the appropriate factory.
Returns:
Cloned content model.
Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getFactory

public TXDocument getFactory()
Returns the factory used for creating this content model.
Returns:
The factory used for creating this content model, or null if no factory.
See Also:
setFactory(com.ibm.xml.parser.TXDocument)

setFactory

public void setFactory(TXDocument factory)
Sets the factory to be used in creating this content model.
Parameters:
factory - The factory to be used in creating this content model.
See Also:
getFactory()

getContentModelNode

public CMNode getContentModelNode()
Returns the content model associated with this model group content model.
Returns:
The content model associated with this model group, or null if this content model's type is anything other than MODEL_GROUP.
See Also:
setContentModelNode(com.ibm.xml.parser.CMNode)

setContentModelNode

public void setContentModelNode(CMNode modelGroupNode)
Sets the content model associated with this model group content model. This method has no meaning for content models NOT of type MODEL_GROUP.
Returns:
The content model associated with this model group.
See Also:
getContentModelNode()

toString

public java.lang.String toString()
Returns this content model in XML format. For example: "EMPTY", "ANY", and "(HEAD,BODY)".
Returns:
The string represenation of the content model or pseudo content model.
Overrides:
toString in class java.lang.Object
See Also:
setPseudoContentModel(java.lang.String)

getPseudoContentModel

public java.lang.String getPseudoContentModel()
Returns the pseudo content model being used in place of an actual content model.

Pseudo content models are useful when the application does not care about the validity of a document's structure, and wishes to quickly specify a literal string to represent the content model in use. For example, instead of specifying an element declaration as:


 CMNode model = new CM1op('*', new CM2op('|', new CM2op('|', new CMLeaf("#PCDATA"), new CMLeaf("FOO")), new CMLeaf("BAR")));
 ContentModel cm = factory.createContentModel(model);
 ElementDecl ed = fatory.createElementDecl("ROOT", cm); 
 

..the same element declaration could be more directly specified as:


 ContentModel cm = factory.createContentModel(ElementDecl.MODEL_GROUP);
 cm.setPseudoContentModel("(#PCDATA|FOO|BAR)*");
 ElementDecl ed = factory.createElementDecl("ROOT", cm); 

 
Returns:
A literal string representing this content model. Note that this value is not calculated from an actual content model specification; rather, it simply returns the value set by setPseudoContentModel.
See Also:
setPseudoContentModel(java.lang.String)

setPseudoContentModel

public void setPseudoContentModel(java.lang.String literal)
Sets the pseudo content model being used in place of an actual content model.

Refer to getPseudoContentModel for a descripion of pseudo content models.

Parameters:
literal - The literal string to be used in place of an actual content model.
See Also:
getPseudoContentModel()

XML Parser for Java 1.1.16