Contents | Package | Class | Tree | Deprecated | Index | Help | XML for Java
PREV | NEXT | SHOW LISTS | HIDE LISTS |

# Class com.ibm.xml.parser.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:
  1.1
See Also:
  ElementDecl

Constructor Summary
ContentModel(int type) Constructor for content models NOT of type MODEL_GROUP.
ContentModel(CMNode modelGroupNode) Constructor for content models of type `MODEL_GROUP`.

Method Summary
java.lang.Object | clone() Clone this content model using the appropriate factory.
CMNode | getContentModelNode() Returns the content model associated with this model group content model.
ElementFactory | 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.
void | setContentModelNode(CMNode modelGroupNode) Sets the content model associated with this model group content model.
void | setFactory(ElementFactory 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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

### getFactory

    public ElementFactory 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

### setFactory

    public void setFactory(ElementFactory 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

### 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

### 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

### 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

Contents | Package | Class | Tree | Deprecated | Index | Help |
PREV | NEXT | SHOW LISTS | HIDE LISTS |