use of org.apache.xpath.objects.XNumber in project j2objc by google.
the class XPathParser method Number.
/**
* Number ::= [0-9]+('.'[0-9]+)? | '.'[0-9]+
*
* @throws javax.xml.transform.TransformerException
*/
protected void Number() throws javax.xml.transform.TransformerException {
if (null != m_token) {
// Mutate the token to remove the quotes and have the XNumber object
// already made.
double num;
try {
// XPath 1.0 does not support number in exp notation
if ((m_token.indexOf('e') > -1) || (m_token.indexOf('E') > -1))
throw new NumberFormatException();
num = Double.valueOf(m_token).doubleValue();
} catch (NumberFormatException nfe) {
// to shut up compiler.
num = 0.0;
error(XPATHErrorResources.ER_COULDNOT_BE_FORMATTED_TO_NUMBER, // m_token+" could not be formatted to a number!");
new Object[] { m_token });
}
m_ops.m_tokenQueue.setElementAt(new XNumber(num), m_queueMark - 1);
m_ops.setOp(m_ops.getOp(OpMap.MAPINDEX_LENGTH), m_queueMark - 1);
m_ops.setOp(OpMap.MAPINDEX_LENGTH, m_ops.getOp(OpMap.MAPINDEX_LENGTH) + 1);
nextToken();
}
}
use of org.apache.xpath.objects.XNumber in project j2objc by google.
the class FuncCount method execute.
/**
* Execute the function. The function must return
* a valid object.
* @param xctxt The current execution context.
* @return A valid XObject.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException {
// DTMIterator nl = m_arg0.asIterator(xctxt, xctxt.getCurrentNode());
// // We should probably make a function on the iterator for this,
// // as a given implementation could optimize.
// int i = 0;
//
// while (DTM.NULL != nl.nextNode())
// {
// i++;
// }
// nl.detach();
DTMIterator nl = m_arg0.asIterator(xctxt, xctxt.getCurrentNode());
int i = nl.getLength();
nl.detach();
return new XNumber((double) i);
}
Aggregations