java.lang.Object
org.apache.wicket.markup.parser.XmlTag

public class XmlTag extends Object
A subclass of MarkupElement which represents a tag including namespace and its optional attributes. XmlTags are returned by the XML parser.
Author:
Jonathan Locke
  • Constructor Details

    • XmlTag

      public XmlTag()
      Construct.
    • XmlTag

      public XmlTag(org.apache.wicket.markup.parser.XmlTag.TextSegment text, XmlTag.TagType type)
      Construct.
      Parameters:
      text -
      type -
  • Method Details

    • closes

      public final boolean closes(XmlTag open)
      Gets whether this tag closes the provided open tag.
      Parameters:
      open - The open tag
      Returns:
      True if this tag closes the given open tag
    • equalTo

      public final boolean equalTo(XmlTag element)
      Parameters:
      element -
      Returns:
      true, if namespace, name and attributes are the same
    • getAttributes

      Gets a hashmap of this tag's attributes.
      Returns:
      The tag's attributes
    • hasAttributes

      public boolean hasAttributes()
      Returns:
      true if there 1 or more attributes.
    • getColumnNumber

      public int getColumnNumber()
      Get the column number.
      Returns:
      Returns the columnNumber.
    • getLength

      public int getLength()
      Gets the length of the tag in characters.
      Returns:
      The tag's length
    • getLineNumber

      public int getLineNumber()
      Get the line number.
      Returns:
      Returns the lineNumber.
    • getName

      public String getName()
      Gets the name of the tag, for example the tag <b>'s name would be 'b'.
      Returns:
      The tag's name
    • getNamespace

      public String getNamespace()
      Namespace of the tag, if available. For example, <wicket:link>.
      Returns:
      The tag's namespace
    • getOpenTag

      public final XmlTag getOpenTag()
      Assuming this is a close tag, return the corresponding open tag
      Returns:
      The open tag. Null, if no open tag available
    • getPos

      public int getPos()
      Gets the location of the tag in the input string.
      Returns:
      Tag location (index in input string)
    • getAttribute

      Get a string attribute.
      Parameters:
      key - The key
      Returns:
      The string value
    • getType

      Get the tag type.
      Returns:
      the tag type (OPEN, CLOSE or OPEN_CLOSE).
    • isClose

      public boolean isClose()
      Gets whether this is a close tag.
      Returns:
      True if this tag is a close tag
    • isMutable

      public final boolean isMutable()
      Returns:
      True, if tag is mutable
    • isOpen

      public boolean isOpen()
      Gets whether this is an open tag.
      Returns:
      True if this tag is an open tag
    • isOpenClose

      public boolean isOpenClose()
      Gets whether this tag is an open/ close tag.
      Returns:
      True if this tag is an open and a close tag
    • makeImmutable

      Makes this tag object immutable by making the attribute map unmodifiable. Immutable tags cannot be made mutable again. They can only be copied into new mutable tag objects.
      Returns:
      this
    • mutable

      public XmlTag mutable()
      Gets this tag if it is already mutable, or a mutable copy of this tag if it is immutable.
      Returns:
      This tag if it is already mutable, or a mutable copy of this tag if it is immutable.
    • put

      public Object put(String key, boolean value)
      Puts a boolean attribute.
      Parameters:
      key - The key
      value - The value
      Returns:
      previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values.
    • put

      public Object put(String key, int value)
      Puts an int attribute.
      Parameters:
      key - The key
      value - The value
      Returns:
      previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values.
    • put

      public Object put(String key, CharSequence value)
      Puts a string attribute.
      Parameters:
      key - The key
      value - The value
      Returns:
      previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values.
    • put

      public Object put(String key, StringValue value)
      Puts a StringValueattribute.
      Parameters:
      key - The key
      value - The value
      Returns:
      previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values.
    • putAll

      public void putAll(Map<String,Object> map)
      Puts all attributes in map
      Parameters:
      map - A key/value map
    • remove

      public void remove(String key)
      Removes an attribute.
      Parameters:
      key - The key to remove
    • setName

      public void setName(String name)
      Sets the tag name.
      Parameters:
      name - New tag name
    • setNamespace

      public void setNamespace(String namespace)
      Sets the tag namespace.
      Parameters:
      namespace - New tag name
    • setOpenTag

      public void setOpenTag(XmlTag tag)
      Assuming this is a close tag, assign it's corresponding open tag.
      Parameters:
      tag - the open-tag
      Throws:
      RuntimeException - if 'this' is not a close tag
    • setType

      public void setType(XmlTag.TagType type)
      Sets type of this tag if it is not immutable.
      Parameters:
      type - The new type
    • toDebugString

      Converts this object to a string representation.
      Returns:
      String version of this object
    • toString

      public String toString()
      Converts this object to a string representation.
      Overrides:
      toString in class Object
      Returns:
      String version of this object
    • toCharSequence

      Returns:
      The string representation of the tag
    • toUserDebugString

      String representation with line and column number
      Returns:
      String version of this object
    • toXmlString

      Assuming some attributes have been changed, toXmlString() rebuilds the String on based on the tags information.
      Returns:
      A xml string matching the tag