Tag
AggTag
, AnaTag
, BaseHideTag
, BaseLoopTag
, CommentTag
, FormulaTag
, GroupTag
, HyperlinkTag
, IfTag
, ImageTag
, NameTag
, NullTag
, PageBreakTag
, SetTag
, SpanTag
, StyleTag
, TotalTag
public abstract class BaseTag extends java.lang.Object implements Tag
The abstract class BaseTag
provides common functionality to
all Tags
. This includes storage for tag attributes, whether
the tag is bodiless, the TagContext
, the
WorkbookContext
, and the parent Tag
(if any).
TagListener
Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
ATTR_ON_PROCESSED |
Attribute for specifying a
TagListener to listen for
TagEvents . |
static java.lang.String |
SPEC_SEP |
Separates expressions in attributes that take multiple values.
|
Constructor | Description |
---|---|
BaseTag() |
Modifier and Type | Method | Description |
---|---|---|
void |
checkAttributes() |
Checks the
Tag's attributes to ensure that certain
requirements are met: |
protected void |
clearBlock() |
Clears the content from the
Block of Cells
associated with this Tag . |
protected void |
deleteBlock() |
Removes the content from the
Block of Cells
associated with this Tag . |
java.util.Map<java.lang.String,org.apache.poi.ss.usermodel.RichTextString> |
getAttributes() |
Returns the
Map of attribute names and attribute values. |
TagContext |
getContext() |
Returns the
TagContext to which the Tag is
associated. |
protected java.lang.String |
getLocation() |
Returns the location of this tag, in the format
" at " + cellReference ,
e.g. |
protected java.util.List<java.lang.String> |
getOptionalAttributes() |
Returns a
List of optional attribute names. |
Tag |
getParentTag() |
Returns the parent
Tag . |
protected java.util.List<java.lang.String> |
getRequiredAttributes() |
Returns a
List of required attribute names. |
WorkbookContext |
getWorkbookContext() |
Returns the
WorkbookContext to which the Tag is
associated. |
boolean |
isBodiless() |
Returns whether this
Tag is bodiless. |
abstract boolean |
process() |
Process this
Tag . |
boolean |
processTag() |
Validates all attributes and attribute values and processes this
Tag . |
protected void |
removeBlock() |
Removes the
Block of Cells associated with this
Tag . |
void |
setAttributes(java.util.Map<java.lang.String,org.apache.poi.ss.usermodel.RichTextString> attributes) |
When a
Tag is created, the attributes are passed in via a
(possibly empty) Map of attribute names and values. |
void |
setBodiless(boolean bodiless) |
Sets whether this
Tag is bodiless. |
void |
setContext(TagContext context) |
Sets the
TagContext to which the Tag is
associated. |
void |
setParentTag(Tag parent) |
Sets the parent
Tag . |
void |
setWorkbookContext(WorkbookContext context) |
Sets the
WorkbookContext to which the Tag is
associated. |
protected void |
validateAttributes() |
Validates the attributes according to
Tag -specific rules. |
public static final java.lang.String ATTR_ON_PROCESSED
TagListener
to listen for
TagEvents
.public static final java.lang.String SPEC_SEP
public void setAttributes(java.util.Map<java.lang.String,org.apache.poi.ss.usermodel.RichTextString> attributes)
Tag
is created, the attributes are passed in via a
(possibly empty) Map
of attribute names and values.setAttributes
in interface Tag
attributes
- A Map
of attribute names and values.public java.util.Map<java.lang.String,org.apache.poi.ss.usermodel.RichTextString> getAttributes()
Map
of attribute names and attribute values.getAttributes
in interface Tag
Map
of attribute names and attribute values.public TagContext getContext()
TagContext
to which the Tag
is
associated.getContext
in interface Tag
TagContext
.public void setContext(TagContext context)
TagContext
to which the Tag
is
associated.setContext
in interface Tag
context
- A TagContext
.public WorkbookContext getWorkbookContext()
WorkbookContext
to which the Tag
is
associated.getWorkbookContext
in interface Tag
WorkbookContext
.public void setWorkbookContext(WorkbookContext context)
WorkbookContext
to which the Tag
is
associated.setWorkbookContext
in interface Tag
context
- A WorkbookContext
.public Tag getParentTag()
Tag
.getParentTag
in interface Tag
Tag
, or null
if none.public void setParentTag(Tag parent)
Tag
.setParentTag
in interface Tag
parent
- The parent Tag
, or null
if none.public void setBodiless(boolean bodiless)
Tag
is bodiless.setBodiless
in interface Tag
bodiless
- true
if this tag does not have a body,
false
if this tag does have a body.public boolean isBodiless()
Tag
is bodiless.isBodiless
in interface Tag
true
if this tag does not have a body,
false
if this tag does have a body.public void checkAttributes()
Checks the Tag's
attributes to ensure that certain
requirements are met:
validateAttributes
(i.e. that method doesn't throw an
Exception
).
A TagParseException
is thrown if not all conditions above
are not met.
This calls validateAttributes
if all conditions are met.
TagParseException
- If the above listed conditions are not met.validateAttributes()
public boolean processTag()
Validates all attributes and attribute values and processes this
Tag
.
For 0.3.0, the methods "checkAttributes" and "process" were removed and replaced by this method, to allow for additional logic.
processTag
in interface Tag
true
if the Cell
containing this
Tag
was transformed, false
if it needs to be
transformed again. This may happen if the Block
associated with the Tag
was removed.TagParseException
- If all required
attributes are not present, if there is an unrecognized attribute or
attribute value, or if any tag data is unacceptable in any other way.protected void removeBlock()
Block
of Cells
associated with this
Tag
. This can be called by subclasses if it determines that
its Block
needs to be removed and not processed.protected void deleteBlock()
Block
of Cells
associated with this Tag
. This can be called by subclasses
if it determines that its Block
needs to have its content
removed.protected void clearBlock()
Block
of Cells
associated with this Tag
. This can be called by subclasses
if it determines that its Block
needs its contents cleared.protected java.util.List<java.lang.String> getRequiredAttributes()
List
of required attribute names. Subclasses that
want to add to this list must override this method, call
super.getRequiredAttributes
, and add their own required
attributes.List
of required attribute names.protected java.util.List<java.lang.String> getOptionalAttributes()
List
of optional attribute names. Subclasses that
want to add to this list must override this method, call
super.getOptionalAttributes
, and add their own optional
attributes.List
of optional attribute names.protected void validateAttributes() throws TagParseException
Tag
-specific rules.
Subclasses that want to add to validate their own attributes, as well as
these attributes, must override this method, call
super.validateAttributes
, and then validate their own
attributes.TagParseException
- If the attribute values are illegal or
unacceptable.public abstract boolean process()
Tag
. The logic of the Tag
is
performed in this method.true
if the Cell
containing this
Tag
was transformed, false
if it needs to be
transformed again. This may happen if the Block
associated with the Tag
was removed.protected java.lang.String getLocation()
" at " + cellReference
,
e.g. " at Sheet2!C3"
.Copyright © 2012–2018 Jett Team. All rights reserved.