java.lang.Object
org.apache.wicket.markup.parser.XmlTag
A subclass of MarkupElement which represents a tag including namespace and its optional
attributes. XmlTags are returned by the XML parser.
- Author:
- Jonathan Locke
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enumerated type for different kinds of component tags. -
Constructor Summary
ConstructorDescriptionXmlTag()
Construct.XmlTag
(org.apache.wicket.markup.parser.XmlTag.TextSegment text, XmlTag.TagType type) Construct. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Gets whether this tag closes the provided open tag.final boolean
getAttribute
(String key) Get a string attribute.Gets a hashmap of this tag's attributes.int
Get the column number.int
Gets the length of the tag in characters.int
Get the line number.getName()
Gets the name of the tag, for example the tag<b>
's name would be 'b'.Namespace of the tag, if available.final XmlTag
Assuming this is a close tag, return the corresponding open tagint
getPos()
Gets the location of the tag in the input string.getType()
Get the tag type.boolean
boolean
isClose()
Gets whether this is a close tag.final boolean
boolean
isOpen()
Gets whether this is an open tag.boolean
Gets whether this tag is an open/ close tag.Makes this tag object immutable by making the attribute map unmodifiable.mutable()
Gets this tag if it is already mutable, or a mutable copy of this tag if it is immutable.Puts a boolean attribute.Puts an int attribute.put
(String key, CharSequence value) Puts a string attribute.put
(String key, StringValue value) Puts aStringValue
attribute.void
Puts all attributes in mapvoid
Removes an attribute.void
Sets the tag name.void
setNamespace
(String namespace) Sets the tag namespace.void
setOpenTag
(XmlTag tag) Assuming this is a close tag, assign it's corresponding open tag.void
setType
(XmlTag.TagType type) Sets type of this tag if it is not immutable.Converts this object to a string representation.toString()
Converts this object to a string representation.String representation with line and column numberAssuming some attributes have been changed, toXmlString() rebuilds the String on based on the tags information.
-
Constructor Details
-
XmlTag
public XmlTag()Construct. -
XmlTag
Construct.- Parameters:
text
-type
-
-
-
Method Details
-
closes
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
- 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
- Returns:
- true if there 1 or more attributes.
-
getColumnNumber
Get the column number.- Returns:
- Returns the columnNumber.
-
getLength
Gets the length of the tag in characters.- Returns:
- The tag's length
-
getLineNumber
Get the line number.- Returns:
- Returns the lineNumber.
-
getName
Gets the name of the tag, for example the tag<b>
's name would be 'b'.- Returns:
- The tag's name
-
getNamespace
Namespace of the tag, if available. For example, <wicket:link>.- Returns:
- The tag's namespace
-
getOpenTag
Assuming this is a close tag, return the corresponding open tag- Returns:
- The open tag. Null, if no open tag available
-
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
Gets whether this is a close tag.- Returns:
- True if this tag is a close tag
-
isMutable
- Returns:
- True, if tag is mutable
-
isOpen
Gets whether this is an open tag.- Returns:
- True if this tag is an open tag
-
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
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
Puts a boolean attribute.- Parameters:
key
- The keyvalue
- 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
Puts an int attribute.- Parameters:
key
- The keyvalue
- 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
Puts a string attribute.- Parameters:
key
- The keyvalue
- 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
Puts aStringValue
attribute.- Parameters:
key
- The keyvalue
- 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
Puts all attributes in map- Parameters:
map
- A key/value map
-
remove
Removes an attribute.- Parameters:
key
- The key to remove
-
setName
Sets the tag name.- Parameters:
name
- New tag name
-
setNamespace
Sets the tag namespace.- Parameters:
namespace
- New tag name
-
setOpenTag
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
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
Converts this object to a string representation. -
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
-