org.ccil.cowan.tagsoup
Class ElementType
java.lang.Object
org.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.
ElementType(String name, int model, int memberOf, int flags, Schema schema) - Construct an ElementType:
but it's better to use Schema.element() instead.
|
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.
|
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.
name
- The element type namemodel
- ORed-together bits representing the content models
allowed in the content of this element typememberOf
- ORed-together bits representing the content models
to which this element type belongsflags
- ORed-together bits representing the flags associated
with this element typeschema
- The schema with which this element type will be
associated
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.
other
- The other element type
flags
public int flags()
Returns the flags associated with this element type.
- The flags associated with this element type as a vector of bits
localName
public String localName()
Returns the local name of this element type.
- The local name of the element type
localName
public String localName(String name)
Return a local name from a Qname.
memberOf
public int memberOf()
Returns the content models to which this element type belongs.
- 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.
- The content models of this element type as a vector of bits
name
public String name()
Returns the name of this element type.
- The name of the element type
namespace
public String namespace()
Returns the namespace name of this element type.
- 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.
name
- The Qnameattribute
- True if name is an attribute name
normalize
public static String normalize(String value)
Normalize an attribute value (ID-style).
CDATA-style attribute normalization is already done.
value
- The value to normalize
parent
public ElementType parent()
Returns the parent element type of this element type.
schema
public Schema schema()
Returns the schema which this element type is associated with.
setAttribute
public void setAttribute(String name,
String type,
String value)
Sets an attribute and its value into this element type.
name
- The name of the attributetype
- The type of the attributevalue
- 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.
atts
- The AttributesImpl objectname
- The name (Qname) of the attributetype
- The type of the attributevalue
- The value of the attribute
setFlags
public void setFlags(int flags)
Sets the flags of this element type.
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.
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.
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.
parent
- The parent element type
Licence: Academic Free License 3.0 and/or GPL 2.0