org.apache.xalan.xsltc.dom
Class NodeCounter

java.lang.Object
  extended by org.apache.xalan.xsltc.dom.NodeCounter
Direct Known Subclasses:
AnyNodeCounter, MultipleNodeCounter, SingleNodeCounter

public abstract class NodeCounter
extends java.lang.Object


Field Summary
 DOM _document
           
protected  java.lang.String _format
           
private  java.util.Vector _formatToks
           
protected  java.lang.String _groupSep
           
protected  int _groupSize
           
 DTMAxisIterator _iterator
           
protected  java.lang.String _lang
           
protected  java.lang.String _letterValue
           
private  int _nFormats
           
protected  int _node
           
protected  int _nodeType
           
private  int _nSepars
           
private  boolean _separFirst
           
private  boolean _separLast
           
private  java.util.Vector _separToks
           
private  java.lang.StringBuffer _tempBuffer
           
 Translet _translet
           
protected  double _value
           
static int END
           
private static java.lang.String[] Hundreds
           
private static java.lang.String[] Ones
           
private static java.lang.String[] Tens
           
private static java.lang.String[] Thousands
           
 
Constructor Summary
protected NodeCounter(Translet translet, DOM document, DTMAxisIterator iterator)
           
 
Method Summary
private  java.lang.String alphaValue(int value, int min, int max)
           
protected  java.lang.String formatNumbers(int value)
          Format a single value according to the format parameters.
protected  java.lang.String formatNumbers(int[] values)
          Format a sequence of values according to the format paramaters set by calling setFormatting().
private  void formatValue(int value, java.lang.String format, java.lang.StringBuffer buffer)
          Format a single value based on the appropriate formatting token.
abstract  java.lang.String getCounter()
          Returns the position of node according to the level and the from and count patterns.
 java.lang.String getCounter(java.lang.String format, java.lang.String lang, java.lang.String letterValue, java.lang.String groupSep, java.lang.String groupSize)
          Returns the position of node according to the level and the from and count patterns.
 boolean matchesCount(int node)
          Returns true if node matches the count pattern.
 boolean matchesFrom(int node)
          Returns true if node matches the from pattern.
private  java.lang.String romanValue(int n)
           
 NodeCounter setDefaultFormatting()
          Sets formatting fields to their default values.
protected  void setFormatting(java.lang.String format, java.lang.String lang, java.lang.String letterValue, java.lang.String groupSep, java.lang.String groupSize)
          Sets formatting fields before calling formatNumbers().
abstract  NodeCounter setStartNode(int node)
          Set the start node for this counter.
private  void setTokens(java.lang.String format)
           
 NodeCounter setValue(double value)
          If the user specified a value attribute, use this instead of counting nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

END

public static final int END
See Also:
Constant Field Values

_node

protected int _node

_nodeType

protected int _nodeType

_value

protected double _value

_document

public final DOM _document

_iterator

public final DTMAxisIterator _iterator

_translet

public final Translet _translet

_format

protected java.lang.String _format

_lang

protected java.lang.String _lang

_letterValue

protected java.lang.String _letterValue

_groupSep

protected java.lang.String _groupSep

_groupSize

protected int _groupSize

_separFirst

private boolean _separFirst

_separLast

private boolean _separLast

_separToks

private java.util.Vector _separToks

_formatToks

private java.util.Vector _formatToks

_nSepars

private int _nSepars

_nFormats

private int _nFormats

Thousands

private static final java.lang.String[] Thousands

Hundreds

private static final java.lang.String[] Hundreds

Tens

private static final java.lang.String[] Tens

Ones

private static final java.lang.String[] Ones

_tempBuffer

private java.lang.StringBuffer _tempBuffer
Constructor Detail

NodeCounter

protected NodeCounter(Translet translet,
                      DOM document,
                      DTMAxisIterator iterator)
Method Detail

setStartNode

public abstract NodeCounter setStartNode(int node)
Set the start node for this counter. The same NodeCounter object can be used multiple times by resetting the starting node.


setValue

public NodeCounter setValue(double value)
If the user specified a value attribute, use this instead of counting nodes.


setFormatting

protected void setFormatting(java.lang.String format,
                             java.lang.String lang,
                             java.lang.String letterValue,
                             java.lang.String groupSep,
                             java.lang.String groupSize)
Sets formatting fields before calling formatNumbers().


setTokens

private final void setTokens(java.lang.String format)

setDefaultFormatting

public NodeCounter setDefaultFormatting()
Sets formatting fields to their default values.


getCounter

public abstract java.lang.String getCounter()
Returns the position of node according to the level and the from and count patterns.


getCounter

public java.lang.String getCounter(java.lang.String format,
                                   java.lang.String lang,
                                   java.lang.String letterValue,
                                   java.lang.String groupSep,
                                   java.lang.String groupSize)
Returns the position of node according to the level and the from and count patterns. This position is converted into a string based on the arguments passed.


matchesCount

public boolean matchesCount(int node)
Returns true if node matches the count pattern. By default a node matches the count patterns if it is of the same type as the starting node.


matchesFrom

public boolean matchesFrom(int node)
Returns true if node matches the from pattern. By default, no node matches the from pattern.


formatNumbers

protected java.lang.String formatNumbers(int value)
Format a single value according to the format parameters.


formatNumbers

protected java.lang.String formatNumbers(int[] values)
Format a sequence of values according to the format paramaters set by calling setFormatting().


formatValue

private void formatValue(int value,
                         java.lang.String format,
                         java.lang.StringBuffer buffer)
Format a single value based on the appropriate formatting token. This method is based on saxon (Michael Kay) and only implements lang="en".


alphaValue

private java.lang.String alphaValue(int value,
                                    int min,
                                    int max)

romanValue

private java.lang.String romanValue(int n)