net.sf.jett.parser
Class TagParser

java.lang.Object
  extended by net.sf.jett.parser.TagParser

public class TagParser
extends java.lang.Object

A TagParser parses one JETT XML tag, either a begin tag or an end tag, including the tag namespace (if any), the tag name, and any attributes.

Author:
Randy Gettman

Field Summary
static java.lang.String BEGIN_END_TAG
          Determines the beginning of an XML end tag.
static java.lang.String BEGIN_START_TAG
          Determines the beginning of an XML start tag.
static java.lang.String END_BODILESS_TAG
          Determines the ending of an XML start tag that is bodiless.
static java.lang.String END_TAG
          Determines the ending of an XML start tag with a body.
 
Constructor Summary
TagParser(org.apache.poi.ss.usermodel.Cell cell)
          Create a TagParser object that will parse the given tag text.
TagParser(org.apache.poi.ss.usermodel.Cell cell, int startIdx)
          Create a TagParser object that will parse the given tag text, starting at the given position in the string..
 
Method Summary
 int getAfterTagIdx()
          Returns the 0-based index into the cell text that is after the tag.
 java.util.Map<java.lang.String,org.apache.poi.ss.usermodel.RichTextString> getAttributes()
          Returns a Map of attribute names mapped to attribute values, possibly empty.
 org.apache.poi.ss.usermodel.Cell getCell()
          Returns the Cell whose tag text is being parsed.
 java.lang.String getNamespace()
          Returns the namespace found, if any.
 java.lang.String getNamespaceAndTagName()
          Returns a formatted string containing the namespace, followed by a colon (if the namespace exists), followed by the tag name, e.g.
 java.lang.String getTagName()
          Returns the tag name found, if any.
 java.lang.String getTagText()
          Returns the portion of the cell text that is the tag text.
 boolean isBodiless()
          Returns whether this tag is bodiless.
 boolean isEndTag()
          Returns whether this tag is the end of the tag or not.
 boolean isTag()
          Returns whether the given tag text is in fact a tag.
 void parse()
          Parses the tag text.
 void setCellText(java.lang.String tagText)
          Sets the tag text to the given tag text and resets the parser.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEGIN_START_TAG

public static final java.lang.String BEGIN_START_TAG
Determines the beginning of an XML start tag.

See Also:
Constant Field Values

BEGIN_END_TAG

public static final java.lang.String BEGIN_END_TAG
Determines the beginning of an XML end tag.

See Also:
Constant Field Values

END_TAG

public static final java.lang.String END_TAG
Determines the ending of an XML start tag with a body.

See Also:
Constant Field Values

END_BODILESS_TAG

public static final java.lang.String END_BODILESS_TAG
Determines the ending of an XML start tag that is bodiless.

See Also:
Constant Field Values
Constructor Detail

TagParser

public TagParser(org.apache.poi.ss.usermodel.Cell cell)
Create a TagParser object that will parse the given tag text.

Parameters:
cell - The Cell that contains text of the tag.

TagParser

public TagParser(org.apache.poi.ss.usermodel.Cell cell,
                 int startIdx)
Create a TagParser object that will parse the given tag text, starting at the given position in the string..

Parameters:
cell - The Cell that contains text of the tag.
startIdx - The 0-based index into the string.
Method Detail

setCellText

public void setCellText(java.lang.String tagText)
Sets the tag text to the given tag text and resets the parser.

Parameters:
tagText - The new tag text.

parse

public void parse()
Parses the tag text.


isTag

public boolean isTag()
Returns whether the given tag text is in fact a tag. That is, if the tag text starts with BEGIN_START_TAG or BEGIN_END_TAG and ends with END_TAG.

Returns:
true if the tag text represents a tag, false otherwise.
See Also:
BEGIN_START_TAG, BEGIN_END_TAG, END_TAG

isEndTag

public boolean isEndTag()
Returns whether this tag is the end of the tag or not. That is, if the tag text starts with BEGIN_END_TAG.

Returns:
true if the tag text represents an end tag, false if the tag text represents a start tag.
See Also:
BEGIN_START_TAG, BEGIN_END_TAG

isBodiless

public boolean isBodiless()
Returns whether this tag is bodiless. That is, if the tag text ends with END_BODILESS_TAG.

Returns:
true if the tag text represents an end tag, false if the tag text represents a start tag.
See Also:
END_TAG, END_BODILESS_TAG

getNamespace

public java.lang.String getNamespace()
Returns the namespace found, if any. That is, the text before the colon in the tag name. E.g. <namespace:tagname ...>

Returns:
The namespace, or null if missing.

getTagName

public java.lang.String getTagName()
Returns the tag name found, if any. That is, the text after the colon in the tag name, or the whole tag name if no colon is found. E.g. <namespace:tagname ...> or <tagname ...>.

Returns:
The tag name.

getNamespaceAndTagName

public java.lang.String getNamespaceAndTagName()
Returns a formatted string containing the namespace, followed by a colon (if the namespace exists), followed by the tag name, e.g. getNamespace() + ":" + getTagName().

Returns:
A formatted string.

getAttributes

public java.util.Map<java.lang.String,org.apache.poi.ss.usermodel.RichTextString> getAttributes()
Returns a Map of attribute names mapped to attribute values, possibly empty. E.g.<namespace:tagname attr1="value1" attr2="value2"> is returned as ["attr1"=>"value1", "attr2"=>"value2"].

Returns:
A Map of attribute names and attribute values.

getCell

public org.apache.poi.ss.usermodel.Cell getCell()
Returns the Cell whose tag text is being parsed.

Returns:
The Cell.

getTagText

public java.lang.String getTagText()
Returns the portion of the cell text that is the tag text.

Returns:
The portion of the cell text that is the tag text.

getAfterTagIdx

public int getAfterTagIdx()
Returns the 0-based index into the cell text that is after the tag.

Returns:
The 0-based index into the cell text that is after the tag.


Copyright © 2012-2013 Jett Team. All Rights Reserved.