net.sf.jett.tag
Class BaseTag

java.lang.Object
  extended by net.sf.jett.tag.BaseTag
All Implemented Interfaces:
Tag
Direct Known Subclasses:
AggTag, BaseLoopTag, CommentTag, FormulaTag, GroupTag, HyperlinkTag, IfTag, NullTag, SpanTag, StyleTag, TotalTag

public abstract class BaseTag
extends java.lang.Object
implements Tag

The abstract class BaseTag provides common functionality to all Tags.


Attributes:

Author:
Randy Gettman

Field Summary
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 Summary
BaseTag()
           
 
Method Summary
 void checkAttributes()
          Checks the Tag's attributes to ensure that:
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.util.List<java.lang.String> getOptionalAttributes()
          Returns a List of optional attribute names.
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.
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 setWorkbookContext(WorkbookContext context)
          Sets the WorkbookContext to which the Tag is associated.
protected  void validateAttributes()
          Validates the attributes according to Tag-specific rules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jett.tag.Tag
getName
 

Field Detail

ATTR_ON_PROCESSED

public static final java.lang.String ATTR_ON_PROCESSED
Attribute for specifying a TagListener to listen for TagEvents.

See Also:
Constant Field Values

SPEC_SEP

public static final java.lang.String SPEC_SEP
Separates expressions in attributes that take multiple values. This was originally defined as the same value in multiple sub-classes, but was moved to BaseTag for 0.3.0.

Since:
0.3.0
See Also:
Constant Field Values
Constructor Detail

BaseTag

public BaseTag()
Method Detail

setAttributes

public 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.

Specified by:
setAttributes in interface Tag
Parameters:
attributes - A Map of attribute names and values.

getAttributes

public java.util.Map<java.lang.String,org.apache.poi.ss.usermodel.RichTextString> getAttributes()
Returns the Map of attribute names and attribute values.

Specified by:
getAttributes in interface Tag
Returns:
The Map of attribute names and attribute values.

setContext

public void setContext(TagContext context)
Sets the TagContext to which the Tag is associated.

Specified by:
setContext in interface Tag
Parameters:
context - A TagContext.

getWorkbookContext

public WorkbookContext getWorkbookContext()
Returns the WorkbookContext to which the Tag is associated.

Specified by:
getWorkbookContext in interface Tag
Returns:
The associated WorkbookContext.

setWorkbookContext

public void setWorkbookContext(WorkbookContext context)
Sets the WorkbookContext to which the Tag is associated.

Specified by:
setWorkbookContext in interface Tag
Parameters:
context - A WorkbookContext.

getContext

public TagContext getContext()
Returns the TagContext to which the Tag is associated.

Specified by:
getContext in interface Tag
Returns:
The associated TagContext.

setBodiless

public void setBodiless(boolean bodiless)
Sets whether this Tag is bodiless.

Specified by:
setBodiless in interface Tag
Parameters:
bodiless - true if this tag does not have a body, false if this tag does have a body.

isBodiless

public boolean isBodiless()
Returns whether this Tag is bodiless.

Specified by:
isBodiless in interface Tag
Returns:
true if this tag does not have a body, false if this tag does have a body.

checkAttributes

public void checkAttributes()

Checks the Tag's attributes to ensure that:

  1. All required attributes are present, and
  2. All attributes present are recognized.
  3. All attributes are validated through the method 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.

Throws:
TagParseException - If the above listed conditions are not met.
See Also:
validateAttributes()

processTag

public boolean processTag()

Validates all attributes and attribute values. Processes this Tag.

For 0.3.0, the methods "checkAttributes" and "process" were removed and replaced by this method, to allow for additional logic.

Specified by:
processTag in interface Tag
Returns:
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.
Throws:
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.
Since:
0.3.0

removeBlock

protected void removeBlock()
Removes the 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.


deleteBlock

protected void deleteBlock()
Removes the content from the 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.


clearBlock

protected void clearBlock()
Clears the content from the Block of Cells associated with this Tag. This can be called by subclasses if it determines that its Block needs its contents cleared.


getRequiredAttributes

protected java.util.List<java.lang.String> getRequiredAttributes()
Returns a 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.

Returns:
A List of required attribute names.

getOptionalAttributes

protected java.util.List<java.lang.String> getOptionalAttributes()
Returns a 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.

Returns:
A List of optional attribute names.

validateAttributes

protected void validateAttributes()
                           throws TagParseException
Validates the attributes according to 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.

Throws:
TagParseException - If the attribute values are illegal or unacceptable.

process

public abstract boolean process()
Process this Tag. The logic of the Tag is performed in this method.

Returns:
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.


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