Class ElementType

java.lang.Object
org.ccil.cowan.tagsoup.ElementType

public class ElementType extends 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:
  • 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

    • 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
    • localName

      public String localName(String name)
      Return a local name from a Qname.
      Parameters:
      name - The Qname
      Returns:
      The local name
    • 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
    • localName

      public 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, 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
    • 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
    • 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
    • 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