net.windward.tags
Class FunctionTag

net.windward.tags.BaseTag
  |
  +--net.windward.tags.FunctionTag

public class FunctionTag
extends BaseTag

Performs a function on a collection of nodes. This tag represents a <wr:function ...> in the template. The simple usage is <wr:function select="./name"/ function="SUM"> which will replace that tag with the sum of the values in the referenced node collection in the final report. The full list of attributes are:

There are several attempts to parse the input string. For a number/currency/percent, it first attempts to parse the string using the appropiate NumberFormat.parse() method and using NumberFormat.applyPattern(). If this fails, it then tries Double.parseDouble(). If that fails it will then throw NodeFormatException.
For date/time/both it makes three passes when attempting to parse. First it will try DateFormat.parse() using DateFormat.applyPattern(input=). If that fails, it will try in order DateFormat.parse() using the patterns FULL, LONG, MEDIUM, and SHORT without using applyPattern(input=). If that fails it will assume nodeText is a long and try Date (Long.parseLong()). If it is not a long, it will throw a NumberFormatException.
It is an error to enter <wr:function select="./name"> ... </wr:out>
This tag follows the jstl examples of c:out, x:out, fmt:formatNumber, and fmt:formatDate.

Version:
2.0 November 1, 2003
See Also:
DateFormat, java.text.DecimalFormat, NumberFormat, SimpleDateFormat, ProcessReportAPI

Field Summary
static java.lang.String FUNC_AVERAGE
           
static java.lang.String FUNC_COUNT
           
static java.lang.String FUNC_MAX
           
static java.lang.String FUNC_MIN
           
static java.lang.String FUNC_SUM
           
static java.lang.String PROP_FUNCTION
           
 
Fields inherited from class net.windward.tags.BaseTag
CHART, COLUMN, DISPLAY_ALWAYS, DISPLAY_NOT_EMPTY, DISPLAY_NOT_NULL, ELSE, END_FOREACH, END_IF, END_LINK, END_MATRIX, ESCAPE, FOREACH, FUNCTION, HTML, IF, IMPORT, LINK, MATRIX, OUT, PROP_COMMENT, PROP_DATASOURCE, PROP_DEFAULT, PROP_DISPLAY, PROP_ENABLED, PROP_INPUT, PROP_PATTERN, PROP_TITLE, PROP_TYPE, PROP_VAR, PROP_WRAP, QUERY, ROW, SET, TAG_DISPLAY_DEFAULT, TAG_DISPLAY_SELECT, TAG_DISPLAY_TAG, TYPE_BITMAP, TYPE_BOTH, TYPE_CURRENCY, TYPE_DATE, TYPE_NUMBER, TYPE_PERCENT, TYPE_TIME, WRAP_BEHIND, WRAP_FRONT, WRAP_INLINE, WRAP_SQUARE
 
Constructor Summary
FunctionTag(java.util.Map map, boolean selfContained, boolean ignoreErrors)
          Create an import element using the passed in map values.
 
Method Summary
 net.windward.document.Element dup(boolean sameRefId)
          Makes a duplicate of this object.
 java.lang.String formatText(java.lang.String[] nodeText, java.util.Locale locale, boolean format)
          Returns the nodeText, converted as requested by the attributes.
 int getXmlType()
          Returns which type of xml element this is.
 java.lang.String toDisplay(int type)
          How this node is displayed on the page when in a field.
 java.lang.String toString()
          Returns this object as a string in the format "var:...".
 java.lang.String toText()
          Converts this node back in to it's string representation in the document
 
Methods inherited from class net.windward.tags.BaseTag
containsAttribute, factory, factory, getAttribute, getAttributes, getBean, getDatasource, getIntAttribute, getLevel, getMode, getNode, getType, setLevel, setNode, toTagText
 

Field Detail

PROP_FUNCTION

public static final java.lang.String PROP_FUNCTION

FUNC_AVERAGE

public static final java.lang.String FUNC_AVERAGE

FUNC_COUNT

public static final java.lang.String FUNC_COUNT

FUNC_MAX

public static final java.lang.String FUNC_MAX

FUNC_MIN

public static final java.lang.String FUNC_MIN

FUNC_SUM

public static final java.lang.String FUNC_SUM
Constructor Detail

FunctionTag

public FunctionTag(java.util.Map map,
                   boolean selfContained,
                   boolean ignoreErrors)
            throws TagException
Create an import element using the passed in map values.
Parameters:
map - Must have a select entry.
selfContained - Must be true.
ignoreErrors - true then build even if there are bad attributes.
Throws:
TagException - thrown if illegal parameters passed in.
Method Detail

toText

public java.lang.String toText()
                        throws TagException
Converts this node back in to it's string representation in the document
Overrides:
toText in class BaseTag
Returns:
<=:xpath> type string.

toDisplay

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

dup

public net.windward.document.Element dup(boolean sameRefId)
Makes a duplicate of this object. A deep clone is done so the new object shares nothing with the original object.
Parameters:
sameRefId -  
Returns:
The new duplicate of this object

getXmlType

public int getXmlType()
Returns which type of xml element this is.
Overrides:
getXmlType in class BaseTag
Returns:
OUT

formatText

public java.lang.String formatText(java.lang.String[] nodeText,
                                   java.util.Locale locale,
                                   boolean format)
Returns the nodeText, converted as requested by the attributes. The default operation is to return nodeText.
There are several attempts to parse the input string. For a number/currency/percent, it first attempts to parse the string using the appropiate NumberFormat.parse() method and using NumberFormat.applyPattern(). If this fails, it then tries Double.parseDouble(). If that fails it will then throw NodeFormatException.
For date/time/both it makes three passes when attempting to parse. First it will try DateFormat.parse() using DateFormat.applyPattern(). If that fails, it will try in order DateFormat.parse() using the patterns FULL, LONG, MEDIUM, and SHORT without using applyPattern(). If that fails it will assume nodeText is a long and try Date (Long.parseLong()). If it is not a long, it will throw a NumberFormatException.
Parameters:
nodeText - The text in the xml nodes.
locale - The local used for parsing and displaying the text.
format - Format according to tag settings.
Returns:
The passed in text converted as requested.
Throws:
java.lang.NumberFormatException - thrown if cannot parse the nodeText.

toString

public java.lang.String toString()
Returns this object as a string in the format "var:...".
Returns:
A String listing this element.


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