org.ccil.cowan.tagsoup

Class 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(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.
String
localName()
Returns the local name of this element type.
String
localName(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.
String
name()
Returns the name of this element type.
String
namespace()
Returns the namespace name of this element type.
String
namespace(String name, boolean attribute)
Return a namespace name from a Qname.
static String
normalize(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(String name, String type, String value)
Sets an attribute and its value into this element type.
void
setAttribute(AttributesImpl atts, String name, String type, String value)
Sets an attribute and its value into an AttributesImpl object.
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.

Constructor Details

ElementType

public ElementType(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 Details

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.

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

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

localName

public String localName()
Returns the local name of this element type.
Returns:
The local name of the element type

localName

public String localName(String name)
Return a local name from a Qname.
Parameters:
name - The Qname
Returns:
The local name

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

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

name

public String name()
Returns the name of this element type.
Returns:
The name of the element type

namespace

public String namespace()
Returns the namespace name of this element type.
Returns:
The namespace name of the element type

namespace

public String namespace(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

normalize

public static String normalize(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

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

setAttribute

public void setAttribute(String name,
                         String type,
                         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

setAttribute

public void setAttribute(AttributesImpl atts,
                         String name,
                         String type,
                         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

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

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

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

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