Java Code Examples for com.sun.org.apache.xml.internal.utils.XMLString#toDouble()

The following examples show how to use com.sun.org.apache.xml.internal.utils.XMLString#toDouble() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FunctionDef1Arg.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Execute the first argument expression that is expected to return a
 * number.  If the argument is null, then get the number value from the
 * current context node.
 *
 * @param xctxt Runtime XPath context.
 *
 * @return The number value of the first argument, or the number value of the
 *         current context node if the first argument is null.
 *
 * @throws javax.xml.transform.TransformerException if an error occurs while
 *                                   executing the argument expression.
 */
protected double getArg0AsNumber(XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{

  if(null == m_arg0)
  {
    int currentNode = xctxt.getCurrentNode();
    if(DTM.NULL == currentNode)
      return 0;
    else
    {
      DTM dtm = xctxt.getDTM(currentNode);
      XMLString str = dtm.getStringValue(currentNode);
      return str.toDouble();
    }

  }
  else
    return m_arg0.execute(xctxt).num();
}
 
Example 2
Source File: FuncSum.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 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 nodes = m_arg0.asIterator(xctxt, xctxt.getCurrentNode());
  double sum = 0.0;
  int pos;

  while (DTM.NULL != (pos = nodes.nextNode()))
  {
    DTM dtm = nodes.getDTM(pos);
    XMLString s = dtm.getStringValue(pos);

    if (null != s)
      sum += s.toDouble();
  }
  nodes.detach();

  return new XNumber(sum);
}
 
Example 3
Source File: FunctionDef1Arg.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Execute the first argument expression that is expected to return a
 * number.  If the argument is null, then get the number value from the
 * current context node.
 *
 * @param xctxt Runtime XPath context.
 *
 * @return The number value of the first argument, or the number value of the
 *         current context node if the first argument is null.
 *
 * @throws javax.xml.transform.TransformerException if an error occurs while
 *                                   executing the argument expression.
 */
protected double getArg0AsNumber(XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{

  if(null == m_arg0)
  {
    int currentNode = xctxt.getCurrentNode();
    if(DTM.NULL == currentNode)
      return 0;
    else
    {
      DTM dtm = xctxt.getDTM(currentNode);
      XMLString str = dtm.getStringValue(currentNode);
      return str.toDouble();
    }

  }
  else
    return m_arg0.execute(xctxt).num();
}
 
Example 4
Source File: FunctionDef1Arg.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Execute the first argument expression that is expected to return a
 * number.  If the argument is null, then get the number value from the
 * current context node.
 *
 * @param xctxt Runtime XPath context.
 *
 * @return The number value of the first argument, or the number value of the
 *         current context node if the first argument is null.
 *
 * @throws javax.xml.transform.TransformerException if an error occurs while
 *                                   executing the argument expression.
 */
protected double getArg0AsNumber(XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{

  if(null == m_arg0)
  {
    int currentNode = xctxt.getCurrentNode();
    if(DTM.NULL == currentNode)
      return 0;
    else
    {
      DTM dtm = xctxt.getDTM(currentNode);
      XMLString str = dtm.getStringValue(currentNode);
      return str.toDouble();
    }

  }
  else
    return m_arg0.execute(xctxt).num();
}
 
Example 5
Source File: FuncSum.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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 nodes = m_arg0.asIterator(xctxt, xctxt.getCurrentNode());
  double sum = 0.0;
  int pos;

  while (DTM.NULL != (pos = nodes.nextNode()))
  {
    DTM dtm = nodes.getDTM(pos);
    XMLString s = dtm.getStringValue(pos);

    if (null != s)
      sum += s.toDouble();
  }
  nodes.detach();

  return new XNumber(sum);
}
 
Example 6
Source File: FunctionDef1Arg.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Execute the first argument expression that is expected to return a
 * number.  If the argument is null, then get the number value from the
 * current context node.
 *
 * @param xctxt Runtime XPath context.
 *
 * @return The number value of the first argument, or the number value of the
 *         current context node if the first argument is null.
 *
 * @throws javax.xml.transform.TransformerException if an error occurs while
 *                                   executing the argument expression.
 */
protected double getArg0AsNumber(XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{

  if(null == m_arg0)
  {
    int currentNode = xctxt.getCurrentNode();
    if(DTM.NULL == currentNode)
      return 0;
    else
    {
      DTM dtm = xctxt.getDTM(currentNode);
      XMLString str = dtm.getStringValue(currentNode);
      return str.toDouble();
    }

  }
  else
    return m_arg0.execute(xctxt).num();
}
 
Example 7
Source File: FuncSum.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 nodes = m_arg0.asIterator(xctxt, xctxt.getCurrentNode());
  double sum = 0.0;
  int pos;

  while (DTM.NULL != (pos = nodes.nextNode()))
  {
    DTM dtm = nodes.getDTM(pos);
    XMLString s = dtm.getStringValue(pos);

    if (null != s)
      sum += s.toDouble();
  }
  nodes.detach();

  return new XNumber(sum);
}
 
Example 8
Source File: FuncSum.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 nodes = m_arg0.asIterator(xctxt, xctxt.getCurrentNode());
  double sum = 0.0;
  int pos;

  while (DTM.NULL != (pos = nodes.nextNode()))
  {
    DTM dtm = nodes.getDTM(pos);
    XMLString s = dtm.getStringValue(pos);

    if (null != s)
      sum += s.toDouble();
  }
  nodes.detach();

  return new XNumber(sum);
}
 
Example 9
Source File: XRTreeFrag.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Cast result object to a number.
 *
 * @return The result tree fragment as a number or NaN
 */
public double num()
  throws javax.xml.transform.TransformerException
{

  XMLString s = xstr();

  return s.toDouble();
}
 
Example 10
Source File: XRTreeFrag.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Cast result object to a number.
 *
 * @return The result tree fragment as a number or NaN
 */
public double num()
  throws javax.xml.transform.TransformerException
{

  XMLString s = xstr();

  return s.toDouble();
}
 
Example 11
Source File: XNodeSet.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compare two strings for less than or equal.
 *
 *
 * @param s1 First string to compare
 * @param s2 Second String to compare
 *
 * @return true if s1 is less than or equal to s2
 */
boolean compareStrings(XMLString s1, XMLString s2)
{
  return (s1.toDouble() <= s2.toDouble());
  // return s1.compareTo(s2) <= 0;
}
 
Example 12
Source File: XNodeSet.java    From hottub with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compare two strings for less than.
 *
 *
 * @param s1 First string to compare
 * @param s2 Second String to compare
 *
 * @return True if s1 is less than s2
 */
boolean compareStrings(XMLString s1, XMLString s2)
{
  return (s1.toDouble() < s2.toDouble());
  // return s1.compareTo(s2) < 0;
}
 
Example 13
Source File: XNodeSet.java    From openjdk-jdk8u with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compare two strings for less than or equal.
 *
 *
 * @param s1 First string to compare
 * @param s2 Second String to compare
 *
 * @return true if s1 is less than or equal to s2
 */
boolean compareStrings(XMLString s1, XMLString s2)
{
  return (s1.toDouble() <= s2.toDouble());
  // return s1.compareTo(s2) <= 0;
}
 
Example 14
Source File: XNodeSet.java    From TencentKona-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compare two strings for greater than.
 *
 *
 * @param s1 First string to compare
 * @param s2 Second String to compare
 *
 * @return true if s1 is greater than s2
 */
boolean compareStrings(XMLString s1, XMLString s2)
{
  return (s1.toDouble() > s2.toDouble());
  // return s1.compareTo(s2) > 0;
}
 
Example 15
Source File: XNodeSet.java    From Bytecoder with Apache License 2.0 2 votes vote down vote up
/**
 * Compare two strings for less than or equal.
 *
 *
 * @param s1 First string to compare
 * @param s2 Second String to compare
 *
 * @return true if s1 is less than or equal to s2
 */
boolean compareStrings(XMLString s1, XMLString s2)
{
  return (s1.toDouble() <= s2.toDouble());
  // return s1.compareTo(s2) <= 0;
}
 
Example 16
Source File: XNodeSet.java    From openjdk-jdk9 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compare two strings for less than or equal.
 *
 *
 * @param s1 First string to compare
 * @param s2 Second String to compare
 *
 * @return true if s1 is less than or equal to s2
 */
boolean compareStrings(XMLString s1, XMLString s2)
{
  return (s1.toDouble() <= s2.toDouble());
  // return s1.compareTo(s2) <= 0;
}
 
Example 17
Source File: XNodeSet.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compare two strings for less than or equal.
 *
 *
 * @param s1 First string to compare
 * @param s2 Second String to compare
 *
 * @return true if s1 is less than or equal to s2
 */
boolean compareStrings(XMLString s1, XMLString s2)
{
  return (s1.toDouble() <= s2.toDouble());
  // return s1.compareTo(s2) <= 0;
}
 
Example 18
Source File: XNodeSet.java    From openjdk-8 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Compare two strings for greater than or equal.
 *
 *
 * @param s1 First string to compare
 * @param s2 Second String to compare
 *
 * @return true if s1 is greater than or equal to s2
 */
boolean compareStrings(XMLString s1, XMLString s2)
{
  return (s1.toDouble() >= s2.toDouble());
  // return s1.compareTo(s2) >= 0;
}
 
Example 19
Source File: XNodeSet.java    From jdk1.8-source-analysis with Apache License 2.0 2 votes vote down vote up
/**
 * Compare two strings for greater than.
 *
 *
 * @param s1 First string to compare
 * @param s2 Second String to compare
 *
 * @return true if s1 is greater than s2
 */
boolean compareStrings(XMLString s1, XMLString s2)
{
  return (s1.toDouble() > s2.toDouble());
  // return s1.compareTo(s2) > 0;
}
 
Example 20
Source File: XNodeSet.java    From JDKSourceCode1.8 with MIT License 2 votes vote down vote up
/**
 * Compare two strings for less than or equal.
 *
 *
 * @param s1 First string to compare
 * @param s2 Second String to compare
 *
 * @return true if s1 is less than or equal to s2
 */
boolean compareStrings(XMLString s1, XMLString s2)
{
  return (s1.toDouble() <= s2.toDouble());
  // return s1.compareTo(s2) <= 0;
}