Methods Summary |
---|
public boolean | bool()Cast result object to a boolean.
return (Double.isNaN(m_val) || (m_val == 0.0)) ? false : true;
|
public void | callVisitors(com.sun.org.apache.xpath.internal.ExpressionOwner owner, com.sun.org.apache.xpath.internal.XPathVisitor visitor)
visitor.visitNumberLiteral(owner, this);
|
public boolean | equals(com.sun.org.apache.xpath.internal.objects.XObject obj2)Tell if two objects are functionally equal.
// In order to handle the 'all' semantics of
// nodeset comparisons, we always call the
// nodeset function.
int t = obj2.getType();
try
{
if (t == XObject.CLASS_NODESET)
return obj2.equals(this);
else if(t == XObject.CLASS_BOOLEAN)
return obj2.bool() == bool();
else
return m_val == obj2.num();
}
catch(javax.xml.transform.TransformerException te)
{
throw new com.sun.org.apache.xml.internal.utils.WrappedRuntimeException(te);
}
|
public int | getType()Tell that this is a CLASS_NUMBER.
return CLASS_NUMBER;
|
public java.lang.String | getTypeString()Given a request type, return the equivalent string.
For diagnostic purposes.
return "#NUMBER";
|
public boolean | isStableNumber()Tell if this expression returns a stable number that will not change during
iterations within the expression. This is used to determine if a proximity
position predicate can indicate that no more searching has to occur.
return true;
|
public double | num()Cast result object to a number.
return m_val;
|
public double | num(com.sun.org.apache.xpath.internal.XPathContext xctxt)Evaluate expression to a number.
return m_val;
|
public java.lang.Object | object()Return a java object that's closest to the representation
that should be handed to an extension.
if(null == m_obj)
m_obj = new Double(m_val);
return m_obj;
|
public java.lang.String | str()Cast result object to a string.
if (Double.isNaN(m_val))
{
return "NaN";
}
else if (Double.isInfinite(m_val))
{
if (m_val > 0)
return "Infinity";
else
return "-Infinity";
}
double num = m_val;
String s = Double.toString(num);
int len = s.length();
if (s.charAt(len - 2) == '." && s.charAt(len - 1) == '0")
{
s = s.substring(0, len - 2);
if (s.equals("-0"))
return "0";
return s;
}
int e = s.indexOf('E");
if (e < 0)
{
if (s.charAt(len - 1) == '0")
return s.substring(0, len - 1);
else
return s;
}
int exp = Integer.parseInt(s.substring(e + 1));
String sign;
if (s.charAt(0) == '-")
{
sign = "-";
s = s.substring(1);
--e;
}
else
sign = "";
int nDigits = e - 2;
if (exp >= nDigits)
return sign + s.substring(0, 1) + s.substring(2, e)
+ zeros(exp - nDigits);
// Eliminate trailing 0's - bugzilla 14241
while (s.charAt(e-1) == '0")
e--;
if (exp > 0)
return sign + s.substring(0, 1) + s.substring(2, 2 + exp) + "."
+ s.substring(2 + exp, e);
return sign + "0." + zeros(-1 - exp) + s.substring(0, 1)
+ s.substring(2, e);
|
private static java.lang.String | zeros(int n)Return a string of '0' of the given length
if (n < 1)
return "";
char[] buf = new char[n];
for (int i = 0; i < n; i++)
{
buf[i] = '0";
}
return new String(buf);
|