net.windward.tags
Class BaseTag

net.windward.tags.BaseTag
Direct Known Subclasses:
ChartTag, ColumnTag, ElseTag, EndForEachTag, EndIfTag, EndLinkTag, EndMatrixTag, EscapeTag, ForEachTag, FunctionTag, HtmlTag, IfTag, ImportTag, LinkTag, MatrixTag, OutTag, QueryTag, RowTag, SetTag

public abstract class BaseTag

This is the base class for all tag's that handle tag elements in the document. It exists mainly because there should be a single base for all tags - but it doesn't do much. This class also contains the factory that will create a tag based on the template string.

Version:
2.0 November 1, 2003

Field Summary
static int CHART
          This is a node of the type <wr:chart>.
static int COLUMN
          This is a node of the type <wr:column>.
static java.lang.String DISPLAY_ALWAYS
           
static java.lang.String DISPLAY_NOT_EMPTY
           
static java.lang.String DISPLAY_NOT_NULL
           
static int ELSE
          This is a node of the type </wr:else>.
static int END_FOREACH
          This is a node of the type </wr:forEach>.
static int END_IF
          This is a node of the type </wr:if>.
static int END_LINK
          This is a node of the type </wr:link>.
static int END_MATRIX
          This is a virtual tag for the end of a matrix table.
static int ESCAPE
          This is a node of the type <wr:escape>.
static int FOREACH
          This is a node of the type <wr:forEach>.
static int FUNCTION
          This is a node of the type <wr:function>.
static int HTML
          This is a node of the type <wr:html>.
static int IF
          This is a node of the type <wr:if>.
static int IMPORT
          This is a node of the type <wr:import>.
static int LINK
          This is a node of the type <wr:link>.
static int MATRIX
          This is a node of the type <wr:matrix>.
static int OUT
          This is a node of the type <wr:out>.
static java.lang.String PROP_COMMENT
           
static java.lang.String PROP_DATASOURCE
           
static java.lang.String PROP_DEFAULT
           
static java.lang.String PROP_DISPLAY
           
static java.lang.String PROP_ENABLED
           
static java.lang.String PROP_INPUT
           
static java.lang.String PROP_PATTERN
           
static java.lang.String PROP_TITLE
           
static java.lang.String PROP_TYPE
           
static java.lang.String PROP_VAR
           
static java.lang.String PROP_WRAP
           
static int QUERY
          This is a node of the type <wr:query>.
static int ROW
          This is a node of the type <wr:row>.
static int SET
          This is a node of the type <wr:set>.
static int TAG_DISPLAY_DEFAULT
           
static int TAG_DISPLAY_SELECT
           
static int TAG_DISPLAY_TAG
           
static java.lang.String TYPE_BITMAP
           
static java.lang.String TYPE_BOTH
           
static java.lang.String TYPE_CURRENCY
           
static java.lang.String TYPE_DATE
           
static java.lang.String TYPE_NUMBER
           
static java.lang.String TYPE_PERCENT
           
static java.lang.String TYPE_TIME
           
static java.lang.String WRAP_BEHIND
           
static java.lang.String WRAP_FRONT
           
static java.lang.String WRAP_INLINE
           
static java.lang.String WRAP_SQUARE
           
 
Method Summary
 boolean containsAttribute(java.lang.String key)
          Returns true if this attribute is held by the tag.
static BaseTag factory(int typ, java.util.Map map, int nestLevel, boolean ignoreErrors)
          Generate a tag for the passed in command.
static BaseTag factory(java.lang.String text, int nestLevel, boolean ignoreErrors)
          Generate a tag for the passed in command.
 java.lang.String getAttribute(java.lang.String key)
          Return the requested attribute.
 java.util.Map getAttributes()
          Get the property map of this node.
 java.lang.String getBean()
          Get the bean name of this node.
 java.lang.String getDatasource()
          Get the datasource of this node.
 int getIntAttribute(java.lang.String key)
          Return the requested attribute.
 int getLevel()
          Returns the level of this If (a matching end will have the same level)
 int getMode()
          The select mode.
 java.lang.String getNode()
          Get the select for this tag.
 int getType()
          This is inherited from Element.
abstract  int getXmlType()
          Returns which type of xml element this is.
 void setLevel(int level)
          Sets the level of this If (a matching end will have the same level)
 void setNode(java.lang.String name)
          Get the select for this tag.
abstract  java.lang.String toDisplay(int type)
          How this node is displayed on the page when in a field.
 java.lang.String toTagText(java.lang.String tag, int tagType, boolean selfContained)
          Adds the datasource and bean attributes to a tag, and then the closing bracket.
abstract  java.lang.String toText()
          Converts this node back in to it's string representation in the document
 

Field Detail

PROP_DATASOURCE

public static final java.lang.String PROP_DATASOURCE

PROP_DEFAULT

public static final java.lang.String PROP_DEFAULT

PROP_DISPLAY

public static final java.lang.String PROP_DISPLAY

PROP_TYPE

public static final java.lang.String PROP_TYPE

PROP_VAR

public static final java.lang.String PROP_VAR

PROP_INPUT

public static final java.lang.String PROP_INPUT

PROP_PATTERN

public static final java.lang.String PROP_PATTERN

PROP_WRAP

public static final java.lang.String PROP_WRAP

PROP_ENABLED

public static final java.lang.String PROP_ENABLED

PROP_TITLE

public static final java.lang.String PROP_TITLE

PROP_COMMENT

public static final java.lang.String PROP_COMMENT

DISPLAY_NOT_EMPTY

public static final java.lang.String DISPLAY_NOT_EMPTY

DISPLAY_NOT_NULL

public static final java.lang.String DISPLAY_NOT_NULL

DISPLAY_ALWAYS

public static final java.lang.String DISPLAY_ALWAYS

TYPE_NUMBER

public static final java.lang.String TYPE_NUMBER

TYPE_CURRENCY

public static final java.lang.String TYPE_CURRENCY

TYPE_PERCENT

public static final java.lang.String TYPE_PERCENT

TYPE_DATE

public static final java.lang.String TYPE_DATE

TYPE_TIME

public static final java.lang.String TYPE_TIME

TYPE_BOTH

public static final java.lang.String TYPE_BOTH

TYPE_BITMAP

public static final java.lang.String TYPE_BITMAP

WRAP_BEHIND

public static final java.lang.String WRAP_BEHIND

WRAP_FRONT

public static final java.lang.String WRAP_FRONT

WRAP_INLINE

public static final java.lang.String WRAP_INLINE

WRAP_SQUARE

public static final java.lang.String WRAP_SQUARE

TAG_DISPLAY_DEFAULT

public static final int TAG_DISPLAY_DEFAULT

TAG_DISPLAY_TAG

public static final int TAG_DISPLAY_TAG

TAG_DISPLAY_SELECT

public static final int TAG_DISPLAY_SELECT

ELSE

public static final int ELSE
This is a node of the type </wr:else>.

END_FOREACH

public static final int END_FOREACH
This is a node of the type </wr:forEach>.

END_IF

public static final int END_IF
This is a node of the type </wr:if>.

END_LINK

public static final int END_LINK
This is a node of the type </wr:link>.

ESCAPE

public static final int ESCAPE
This is a node of the type <wr:escape>.

FOREACH

public static final int FOREACH
This is a node of the type <wr:forEach>.

HTML

public static final int HTML
This is a node of the type <wr:html>.

IF

public static final int IF
This is a node of the type <wr:if>.

IMPORT

public static final int IMPORT
This is a node of the type <wr:import>.

LINK

public static final int LINK
This is a node of the type <wr:link>.

QUERY

public static final int QUERY
This is a node of the type <wr:query>.

OUT

public static final int OUT
This is a node of the type <wr:out>.

FUNCTION

public static final int FUNCTION
This is a node of the type <wr:function>.

SET

public static final int SET
This is a node of the type <wr:set>.

CHART

public static final int CHART
This is a node of the type <wr:chart>.

MATRIX

public static final int MATRIX
This is a node of the type <wr:matrix>.

ROW

public static final int ROW
This is a node of the type <wr:row>.

COLUMN

public static final int COLUMN
This is a node of the type <wr:column>.

END_MATRIX

public static final int END_MATRIX
This is a virtual tag for the end of a matrix table.
Method Detail

getXmlType

public abstract int getXmlType()
Returns which type of xml element this is.
Returns:
One of the NODE_* values

toText

public abstract java.lang.String toText()
                                 throws TagException
Converts this node back in to it's string representation in the document
Returns:
<wr:cmd...> type string.

toDisplay

public abstract java.lang.String toDisplay(int type)
How this node is displayed on the page when in a field.
Parameters:
type - One of the DISPLAY_* constants
Returns:
title, end of select, or <cmd> type string.

getNode

public java.lang.String getNode()
Get the select for this tag. This can be any SQL/xpath statement.
Returns:
the SQL/xpath statement used to select the requested data.

setNode

public void setNode(java.lang.String name)
Get the select for this tag. This can be any SQL/xpath statement.
Parameters:
name - The SQL/xpath statement used to select the requested data.

getMode

public int getMode()
The select mode. The values are tag specific but 0 is usually a select on the datasource, 1 the value entered, and 2 evaluate the value entered. -1 means this tag has no select.

getDatasource

public java.lang.String getDatasource()
Get the datasource of this node.
Returns:
the datasource of this node. "" (not null) for the default datasource.

getBean

public java.lang.String getBean()
Get the bean name of this node.
Returns:
the bean name of this node. null for no bean.

containsAttribute

public boolean containsAttribute(java.lang.String key)
Returns true if this attribute is held by the tag.
Parameters:
key - The key to search for.
Returns:
true if the attribute is stored.

getAttribute

public java.lang.String getAttribute(java.lang.String key)
Return the requested attribute. Returns null if it does not exist.
Parameters:
key - The attribute requested.
Returns:
The attribute's value. If no attribute returns the empty string (not null).

getIntAttribute

public int getIntAttribute(java.lang.String key)
Return the requested attribute. Returns null if it does not exist.
Parameters:
key - The attribute requested.
Returns:
The attribute's value. Returns -1 if the attribute does not exist.

getAttributes

public java.util.Map getAttributes()
Get the property map of this node.
Returns:
the property map of this node.

getLevel

public int getLevel()
Returns the level of this If (a matching end will have the same level)
Returns:
the level for this If, will be 1+.

setLevel

public void setLevel(int level)
Sets the level of this If (a matching end will have the same level)
Parameters:
level - the level for this If/while, will be 1+.

getType

public int getType()
This is inherited from Element. All elements of this type must be of type TYPE_EXT because they are not known by the rtf package.
Returns:
Always returns TYPE_EXT.

toTagText

public java.lang.String toTagText(java.lang.String tag,
                                  int tagType,
                                  boolean selfContained)
                           throws TagException
Adds the datasource and bean attributes to a tag, and then the closing bracket.
Parameters:
tag - The tag string missing the closing bracket.
tagType - The tag type.
selfContained - true if a self contained tag.
Returns:
The full tag.

factory

public static BaseTag factory(java.lang.String text,
                              int nestLevel,
                              boolean ignoreErrors)
                       throws TagException
Generate a tag for the passed in command. The passed in command must be from < to >. If the passed in text is not a tag this will return null. If it is a tag but has errors in the tag text, it will throw an exception. The text is assumed to be a tag if the "<cmd" part matches one of our commands.
Parameters:
text - The template text. For example: <wr:out value="./name"/>
nestLevel - The nesting level for link/while/if
ignoreErrors - Build even if some attributes are wrong or missing.
Returns:
The tag if a command. Null if not a tag (like x < y).
Throws:
TagException - The tag could not be parsed or is missing required attributes.

factory

public static BaseTag factory(int typ,
                              java.util.Map map,
                              int nestLevel,
                              boolean ignoreErrors)
                       throws TagException
Generate a tag for the passed in command. The passed in command must be from < to >. If the passed in text is not a tag this will return null. If it is a tag but has errors in the tag text, it will throw an exception. The text is assumed to be a tag if the "<cmd" part matches one of our commands.
Parameters:
typ - The BaseTag.**TYPE** type
map - - the tag properties including the select and datasource.
nestLevel - The nesting level for link/while/if
ignoreErrors - Create the tag even if some attributes are missing or wrong.
Returns:
The tag if a command. Null if not a tag (like x < y).
Throws:
TagException - The tag could not be parsed or is missing required attributes.


Copyright © 2002 - 2008 Windward Reports - All Rights Reserved. java reporting software