org.ccil.cowan.tagsoup
Class ElementType

java.lang.Object
  extended byorg.ccil.cowan.tagsoup.ElementType

public class ElementType
extends java.lang.Object

This class represents an element type in the schema. An element type has a name, a content model vector, a member-of vector, a flags vector, default attributes, and a schema to which it belongs.

See Also:
Schema

Constructor Summary
ElementType(java.lang.String name, int model, int memberOf, int flags, Schema schema)
          Construct an ElementType: but it's better to use Schema.element() instead.
 
Method Summary
 AttributesImpl atts()
          Returns the default attributes associated with this element type.
 boolean canContain(ElementType other)
          Returns true if this element type can contain another element type.
 int flags()
          Returns the flags associated with this element type.
 java.lang.String localName()
          Returns the local name of this element type.
 java.lang.String localName(java.lang.String name)
          Return a local name from a Qname.
 int memberOf()
          Returns the content models to which this element type belongs.
 int model()
          Returns the content models of this element type.
 java.lang.String name()
          Returns the name of this element type.
 java.lang.String namespace()
          Returns the namespace name of this element type.
 java.lang.String namespace(java.lang.String name, boolean attribute)
          Return a namespace name from a Qname.
static java.lang.String normalize(java.lang.String value)
          Normalize an attribute value (ID-style).
 ElementType parent()
          Returns the parent element type of this element type.
 Schema schema()
          Returns the schema which this element type is associated with.
 void setAttribute(AttributesImpl atts, java.lang.String name, java.lang.String type, java.lang.String value)
          Sets an attribute and its value into an AttributesImpl object.
 void setAttribute(java.lang.String name, java.lang.String type, java.lang.String value)
          Sets an attribute and its value into this element type.
 void setFlags(int flags)
          Sets the flags of this element type.
 void setMemberOf(int memberOf)
          Sets the content models to which this element type belongs.
 void setModel(int model)
          Sets the models of this element type.
 void setParent(ElementType parent)
          Sets the parent element type of this element type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ElementType

public ElementType(java.lang.String name,
                   int model,
                   int memberOf,
                   int flags,
                   Schema schema)
Construct an ElementType: but it's better to use Schema.element() instead. The content model, member-of, and flags vectors are specified as ints.

Parameters:
name - The element type name
model - ORed-together bits representing the content models allowed in the content of this element type
memberOf - ORed-together bits representing the content models to which this element type belongs
flags - ORed-together bits representing the flags associated with this element type
schema - The schema with which this element type will be associated
Method Detail

namespace

public java.lang.String namespace(java.lang.String name,
                                  boolean attribute)
Return a namespace name from a Qname. The attribute flag tells us whether to return an empty namespace name if there is no prefix, or use the schema default instead.

Parameters:
name - The Qname
attribute - True if name is an attribute name
Returns:
The namespace name

localName

public java.lang.String localName(java.lang.String name)
Return a local name from a Qname.

Parameters:
name - The Qname
Returns:
The local name

name

public java.lang.String name()
Returns the name of this element type.

Returns:
The name of the element type

namespace

public java.lang.String namespace()
Returns the namespace name of this element type.

Returns:
The namespace name of the element type

localName

public java.lang.String localName()
Returns the local name of this element type.

Returns:
The local name of the element type

model

public int model()
Returns the content models of this element type.

Returns:
The content models of this element type as a vector of bits

memberOf

public int memberOf()
Returns the content models to which this element type belongs.

Returns:
The content models to which this element type belongs as a vector of bits

flags

public int flags()
Returns the flags associated with this element type.

Returns:
The flags associated with this element type as a vector of bits

atts

public AttributesImpl atts()
Returns the default attributes associated with this element type. Attributes of type CDATA that don't have default values are typically not included. Other attributes without default values have an internal value of null. The return value is an AttributesImpl to allow the caller to mutate the attributes.


parent

public ElementType parent()
Returns the parent element type of this element type.

Returns:
The parent element type

schema

public Schema schema()
Returns the schema which this element type is associated with.

Returns:
The schema

canContain

public boolean canContain(ElementType other)
Returns true if this element type can contain another element type. That is, if any of the models in this element's model vector match any of the models in the other element type's member-of vector.

Parameters:
other - The other element type

setAttribute

public void setAttribute(AttributesImpl atts,
                         java.lang.String name,
                         java.lang.String type,
                         java.lang.String value)
Sets an attribute and its value into an AttributesImpl object. Attempts to set a namespace declaration are ignored.

Parameters:
atts - The AttributesImpl object
name - The name (Qname) of the attribute
type - The type of the attribute
value - The value of the attribute

normalize

public static java.lang.String normalize(java.lang.String value)
Normalize an attribute value (ID-style). CDATA-style attribute normalization is already done.

Parameters:
value - The value to normalize
Returns:
The normalized value

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String type,
                         java.lang.String value)
Sets an attribute and its value into this element type.

Parameters:
name - The name of the attribute
type - The type of the attribute
value - The value of the attribute

setModel

public void setModel(int model)
Sets the models of this element type.

Parameters:
model - The content models of this element type as a vector of bits

setMemberOf

public void setMemberOf(int memberOf)
Sets the content models to which this element type belongs.

Parameters:
memberOf - The content models to which this element type belongs as a vector of bits

setFlags

public void setFlags(int flags)
Sets the flags of this element type.

Parameters:
flags - associated with this element type The flags as a vector of bits

setParent

public void setParent(ElementType parent)
Sets the parent element type of this element type.

Parameters:
parent - The parent element type


Licence: Academic Free License 3.0 and/or GPL 2.0