Java Code Examples for com.sun.org.apache.xml.internal.dtm.DTM#getStringValue()

The following examples show how to use com.sun.org.apache.xml.internal.dtm.DTM#getStringValue() . 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 jdk1.8-source-analysis 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 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 3
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 4
Source File: FuncSum.java    From openjdk-jdk8u-backup 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 5
Source File: FunctionDef1Arg.java    From openjdk-8 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 6
Source File: FuncSum.java    From Bytecoder 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 7
Source File: FuncSum.java    From hottub 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-jdk9 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: 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 10
Source File: FunctionDef1Arg.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Execute the first argument expression that is expected to return a
 * string.  If the argument is null, then get the string value from the
 * current context node.
 *
 * @param xctxt Runtime XPath context.
 *
 * @return The string value of the first argument, or the string 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 XMLString getArg0AsString(XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{
  if(null == m_arg0)
  {
    int currentNode = xctxt.getCurrentNode();
    if(DTM.NULL == currentNode)
      return XString.EMPTYSTRING;
    else
    {
      DTM dtm = xctxt.getDTM(currentNode);
      return dtm.getStringValue(currentNode);
    }

  }
  else
    return m_arg0.execute(xctxt).xstr();
}
 
Example 11
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 12
Source File: FunctionDef1Arg.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Execute the first argument expression that is expected to return a
 * string.  If the argument is null, then get the string value from the
 * current context node.
 *
 * @param xctxt Runtime XPath context.
 *
 * @return The string value of the first argument, or the string 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 XMLString getArg0AsString(XPathContext xctxt)
        throws javax.xml.transform.TransformerException
{
  if(null == m_arg0)
  {
    int currentNode = xctxt.getCurrentNode();
    if(DTM.NULL == currentNode)
      return XString.EMPTYSTRING;
    else
    {
      DTM dtm = xctxt.getDTM(currentNode);
      return dtm.getStringValue(currentNode);
    }

  }
  else
    return m_arg0.execute(xctxt).xstr();
}
 
Example 13
Source File: FunctionDef1Arg.java    From openjdk-jdk8u-backup 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 14
Source File: XPathContext.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a node as a number.
 * @param n Node to be converted to a number.  May be null.
 * @return value of n as a number.
 */
public double toNumber(org.w3c.dom.Node n)
{
  // %REVIEW% You can't get much uglier than this...
  int nodeHandle = getDTMHandleFromNode(n);
  DTM dtm = getDTM(nodeHandle);
  XString xobj = (XString)dtm.getStringValue(nodeHandle);
  return xobj.num();
}
 
Example 15
Source File: XPathContext.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a node as a string.
 * @param n Node to be converted to a string.  May be null.
 * @return value of n as a string, or an empty string if n is null.
 */
public String toString(org.w3c.dom.Node n)
{
  // %REVIEW% You can't get much uglier than this...
  int nodeHandle = getDTMHandleFromNode(n);
  DTM dtm = getDTM(nodeHandle);
  XMLString strVal = dtm.getStringValue(nodeHandle);
  return strVal.toString();
}
 
Example 16
Source File: XPathContext.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a node as a number.
 * @param n Node to be converted to a number.  May be null.
 * @return value of n as a number.
 */
public double toNumber(org.w3c.dom.Node n)
{
  // %REVIEW% You can't get much uglier than this...
  int nodeHandle = getDTMHandleFromNode(n);
  DTM dtm = getDTM(nodeHandle);
  XString xobj = (XString)dtm.getStringValue(nodeHandle);
  return xobj.num();
}
 
Example 17
Source File: XPathContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a node as a number.
 * @param n Node to be converted to a number.  May be null.
 * @return value of n as a number.
 */
public double toNumber(org.w3c.dom.Node n)
{
  // %REVIEW% You can't get much uglier than this...
  int nodeHandle = getDTMHandleFromNode(n);
  DTM dtm = getDTM(nodeHandle);
  XString xobj = (XString)dtm.getStringValue(nodeHandle);
  return xobj.num();
}
 
Example 18
Source File: XPathContext.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a node as a number.
 * @param n Node to be converted to a number.  May be null.
 * @return value of n as a number.
 */
public double toNumber(org.w3c.dom.Node n)
{
  // %REVIEW% You can't get much uglier than this...
  int nodeHandle = getDTMHandleFromNode(n);
  DTM dtm = getDTM(nodeHandle);
  XString xobj = (XString)dtm.getStringValue(nodeHandle);
  return xobj.num();
}
 
Example 19
Source File: XPathContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the value of a node as a string.
 * @param n Node to be converted to a string.  May be null.
 * @return value of n as a string, or an empty string if n is null.
 */
public String toString(org.w3c.dom.Node n)
{
  // %REVIEW% You can't get much uglier than this...
  int nodeHandle = getDTMHandleFromNode(n);
  DTM dtm = getDTM(nodeHandle);
  XMLString strVal = dtm.getStringValue(nodeHandle);
  return strVal.toString();
}
 
Example 20
Source File: XPathContext.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Get the value of a node as a string.
 * @param n Node to be converted to a string.  May be null.
 * @return value of n as a string, or an empty string if n is null.
 */
public String toString(org.w3c.dom.Node n)
{
  // %REVIEW% You can't get much uglier than this...
  int nodeHandle = getDTMHandleFromNode(n);
  DTM dtm = getDTM(nodeHandle);
  XMLString strVal = dtm.getStringValue(nodeHandle);
  return strVal.toString();
}