info.bliki.wiki.tags.util
Class WikiTagNode

java.lang.Object
  extended by info.bliki.wiki.tags.util.AbstractNode
      extended by info.bliki.wiki.tags.util.WikiTagNode
All Implemented Interfaces:
java.io.Serializable

public class WikiTagNode
extends AbstractNode

WikiTagNode represents a generic tag. If no scanner is registered for a given tag name, this is what you get. This is also the base class for all tags created by the parser.

See Also:
Serialized Form

Field Summary
protected  java.util.List<NodeAttribute> mAttributes
          The tag attributes.
 
Fields inherited from class info.bliki.wiki.tags.util.AbstractNode
nodeBegin, nodeEnd
 
Constructor Summary
WikiTagNode()
          Create an empty tag.
WikiTagNode(int start, int end, java.util.ArrayList<NodeAttribute> attributes)
          Create a tag with the location and attributes provided
 
Method Summary
 java.lang.String getAttribute(java.lang.String name)
          Returns the value of an attribute.
 NodeAttribute getAttributeEx(java.lang.String name)
          Returns the attribute with the given name.
 java.util.List<NodeAttribute> getAttributesEx()
          Gets the attributes in the tag.
 java.lang.String[] getEnders()
          Return the set of tag names that cause this tag to finish.
 java.lang.String[] getEndTagEnders()
          Return the set of end tag names that cause this tag to finish.
 java.lang.String[] getIds()
          Return the set of names handled by this tag.
 java.lang.String getRawTagName()
          Return the name of this tag.
 int getTagBegin()
          Gets the nodeBegin.
 int getTagEnd()
          Gets the nodeEnd.
 java.lang.String getTagName()
          Return the name of this tag.
 java.lang.String getText()
          Return the text contained in this tag.
 boolean isEmptyXmlTag()
          Is this an empty xml tag of the form <tag/>.
 boolean isEndTag()
          Predicate to determine if this tag is an end tag (i.e.
 void removeAttribute(java.lang.String key)
          Remove the attribute with the given key, if it exists.
 void setAttribute(NodeAttribute attribute)
          Set an attribute.
 void setAttribute(java.lang.String key, java.lang.String value)
          Set attribute with given key, value pair.
 void setAttribute(java.lang.String key, java.lang.String value, char quote)
          Set attribute with given key, value pair where the value is quoted by quote.
 void setAttributeEx(NodeAttribute attribute)
          Set an attribute.
 void setAttributesEx(java.util.List<NodeAttribute> attribs)
          Sets the attributes.
 void setEmptyXmlTag(boolean emptyXmlTag)
          Set this tag to be an empty xml node, or not.
 void setTagBegin(int tagBegin)
          Sets the nodeBegin.
 void setTagEnd(int tagEnd)
          Sets the nodeEnd.
 void setTagName(java.lang.String name)
          Set the name of this tag.
 java.lang.String toHtml(boolean verbatim)
          Render the tag as HTML.
 java.lang.String toPlainTextString()
          Get the plain text from this node.
 
Methods inherited from class info.bliki.wiki.tags.util.AbstractNode
clone, getEndPosition, getStartPosition, setEndPosition, setStartPosition, setText, toHtml
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mAttributes

protected java.util.List<NodeAttribute> mAttributes
The tag attributes. Objects of type Attribute. The first element is the tag name, subsequent elements being either whitespace or real attributes.

Constructor Detail

WikiTagNode

public WikiTagNode()
Create an empty tag.


WikiTagNode

public WikiTagNode(int start,
                   int end,
                   java.util.ArrayList<NodeAttribute> attributes)
Create a tag with the location and attributes provided

Parameters:
page - The page this tag was read from.
start - The starting offset of this node within the page.
end - The ending offset of this node within the page.
attributes - The list of attributes that were parsed in this tag.
See Also:
Attribute
Method Detail

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Returns the value of an attribute.

Parameters:
name - Name of attribute, case insensitive.
Returns:
The value associated with the attribute or null if it does not exist, or is a stand-alone or

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.String value)
Set attribute with given key, value pair. Figures out a quote character to use if necessary.

Parameters:
key - The name of the attribute.
value - The value of the attribute.

removeAttribute

public void removeAttribute(java.lang.String key)
Remove the attribute with the given key, if it exists.

Parameters:
key - The name of the attribute.

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.String value,
                         char quote)
Set attribute with given key, value pair where the value is quoted by quote.

Parameters:
key - The name of the attribute.
value - The value of the attribute.
quote - The quote character to be used around value. If zero, it is an unquoted value.

getAttributeEx

public NodeAttribute getAttributeEx(java.lang.String name)
Returns the attribute with the given name.

Parameters:
name - Name of attribute, case insensitive.
Returns:
The attribute or null if it does not exist.

setAttributeEx

public void setAttributeEx(NodeAttribute attribute)
Set an attribute.

Parameters:
attribute - The attribute to set.
See Also:
#setAttribute(Attribute)

setAttribute

public void setAttribute(NodeAttribute attribute)
Set an attribute. This replaces an attribute of the same name. To set the zeroth attribute (the tag name), use setTagName().

Parameters:
attribute - The attribute to set.

getAttributesEx

public java.util.List<NodeAttribute> getAttributesEx()
Gets the attributes in the tag.

Returns:
Returns the list of Attributes in the tag. The first element is the tag name, subsequent elements being either whitespace or real attributes.

getTagName

public java.lang.String getTagName()
Return the name of this tag.

Note: This value is converted to uppercase and does not begin with "/" if it is an end tag. Nor does it end with a slash in the case of an XML type tag. To get at the original text of the tag name use getRawTagName(). The conversion to uppercase is performed with an ENGLISH locale.

Returns:
The tag name.

getRawTagName

public java.lang.String getRawTagName()
Return the name of this tag.

Returns:
The tag name or null if this tag contains nothing or only whitespace.

setTagName

public void setTagName(java.lang.String name)
Set the name of this tag. This creates or replaces the first attribute of the tag (the zeroth element of the attribute vector).

Parameters:
name - The tag name.

getText

public java.lang.String getText()
Return the text contained in this tag.

Overrides:
getText in class AbstractNode
Returns:
The complete contents of the tag (within the angle brackets).

setAttributesEx

public void setAttributesEx(java.util.List<NodeAttribute> attribs)
Sets the attributes. NOTE: Values of the extended hashtable are two element arrays of String, with the first element being the original name (not uppercased), and the second element being the value.

Parameters:
attribs - The attribute collection to set.

setTagBegin

public void setTagBegin(int tagBegin)
Sets the nodeBegin.

Parameters:
tagBegin - The nodeBegin to set

getTagBegin

public int getTagBegin()
Gets the nodeBegin.

Returns:
The nodeBegin value.

setTagEnd

public void setTagEnd(int tagEnd)
Sets the nodeEnd.

Parameters:
tagEnd - The nodeEnd to set

getTagEnd

public int getTagEnd()
Gets the nodeEnd.

Returns:
The nodeEnd value.

toPlainTextString

public java.lang.String toPlainTextString()
Get the plain text from this node.

Specified by:
toPlainTextString in class AbstractNode
Returns:
An empty string (tag contents do not display in a browser). If you want this tags HTML equivalent, use toHtml().

toHtml

public java.lang.String toHtml(boolean verbatim)
Render the tag as HTML. A call to a tag's toHtml() method will render it in HTML.

Specified by:
toHtml in class AbstractNode
Parameters:
verbatim - If true return as close to the original page text as possible.
Returns:
The tag as an HTML fragment.
See Also:
org.htmlparser.Node#toHtml()

isEmptyXmlTag

public boolean isEmptyXmlTag()
Is this an empty xml tag of the form <tag/>.

Returns:
true if the last character of the last attribute is a '/'.

setEmptyXmlTag

public void setEmptyXmlTag(boolean emptyXmlTag)
Set this tag to be an empty xml node, or not. Adds or removes an ending slash on the tag.

Parameters:
emptyXmlTag - If true, ensures there is an ending slash in the node, i.e. <tag/>, otherwise removes it.

isEndTag

public boolean isEndTag()
Predicate to determine if this tag is an end tag (i.e. </HTML>).

Returns:
true if this tag is an end tag.

getIds

public java.lang.String[] getIds()
Return the set of names handled by this tag. Since this a a generic tag, it has no ids.

Returns:
The names to be matched that create tags of this type.

getEnders

public java.lang.String[] getEnders()
Return the set of tag names that cause this tag to finish. These are the normal (non end tags) that if encountered while scanning (a composite tag) will cause the generation of a virtual tag. Since this a a non-composite tag, the default is no enders.

Returns:
The names of following tags that stop further scanning.

getEndTagEnders

public java.lang.String[] getEndTagEnders()
Return the set of end tag names that cause this tag to finish. These are the end tags that if encountered while scanning (a composite tag) will cause the generation of a virtual tag. Since this a a non-composite tag, it has no end tag enders.

Returns:
The names of following end tags that stop further scanning.


Copyright © 2012 Java Wikipedia API (Bliki engine). All Rights Reserved.