FileDocCategorySizeDatePackage
SingleNodeCounter.javaAPI DocJava SE 6 API3927Tue Jun 10 00:22:32 BST 2008com.sun.org.apache.xalan.internal.xsltc.dom

SingleNodeCounter

public abstract class SingleNodeCounter extends NodeCounter
author
Jacek Ambroziak
author
Santiago Pericas-Geertsen

Fields Summary
private static final int[]
EmptyArray
DTMAxisIterator
_countSiblings
Constructors Summary
public SingleNodeCounter(Translet translet, DOM document, DTMAxisIterator iterator)


      
			      
			       
	super(translet, document, iterator);
    
Methods Summary
public java.lang.StringgetCounter()

	int result;
	if (_value != Integer.MIN_VALUE) {
                //See Errata E24
                if (_value == 0) return "0";
                else if (Double.isNaN(_value)) return "NaN";
                else if (_value < 0 && Double.isInfinite(_value)) return "-Infinity";
                else if (Double.isInfinite(_value)) return "Infinity";
                else result = (int) _value;
	}
	else {
	    int next = _node;
	    result = 0;
	    if (!matchesCount(next)) {
		while ((next = _document.getParent(next)) > END) {
		    if (matchesCount(next)) {
			break;		// found target
		    }
		    if (matchesFrom(next)) {
			next = END;
			break;		// no target found
		    }
		}
	    }

	    if (next != END) {
		_countSiblings.setStartNode(next);
		do {
		    if (matchesCount(next)) result++;
		} while ((next = _countSiblings.next()) != END);
	    }
	    else {
		// If no target found then pass the empty list
		return formatNumbers(EmptyArray);
	    }
	}
	return formatNumbers(result);
    
public static com.sun.org.apache.xalan.internal.xsltc.dom.NodeCountergetDefaultNodeCounter(com.sun.org.apache.xalan.internal.xsltc.Translet translet, com.sun.org.apache.xalan.internal.xsltc.DOM document, com.sun.org.apache.xml.internal.dtm.DTMAxisIterator iterator)

	return new DefaultSingleNodeCounter(translet, document, iterator);
    
public com.sun.org.apache.xalan.internal.xsltc.dom.NodeCountersetStartNode(int node)

	_node = node;
	_nodeType = _document.getExpandedTypeID(node);
    _countSiblings = _document.getAxisIterator(Axis.PRECEDINGSIBLING);
	return this;