FileDocCategorySizeDatePackage
FunctionDef1Arg.javaAPI DocJava SE 6 API5394Tue Jun 10 00:23:16 BST 2008com.sun.org.apache.xpath.internal.functions

FunctionDef1Arg

public class FunctionDef1Arg extends FunctionOneArg
Base class for functions that accept one argument that can be defaulted if not specified.
xsl.usage
advanced

Fields Summary
static final long
serialVersionUID
Constructors Summary
Methods Summary
public booleanArg0IsNodesetExpr()
Tell if the expression is a nodeset expression.

return
true if the expression can be represented as a nodeset.

    return (null == m_arg0) ? true : m_arg0.isNodesetExpr();
  
public booleancanTraverseOutsideSubtree()
Tell if this expression or it's subexpressions can traverse outside the current subtree.

return
true if traversal outside the context node's subtree can occur.

    return (null == m_arg0) ? false : super.canTraverseOutsideSubtree();
  
public voidcheckNumberArgs(int argNum)
Check that the number of arguments passed to this function is correct.

param
argNum The number of arguments that is being passed to the function.
throws
WrongNumberArgsException if the number of arguments is not 0 or 1.

    if (argNum > 1)
      reportWrongNumberArgs();
  
protected intgetArg0AsNode(com.sun.org.apache.xpath.internal.XPathContext xctxt)
Execute the first argument expression that is expected to return a nodeset. If the argument is null, then return the current context node.

param
xctxt Runtime XPath context.
return
The first node of the executed nodeset, or the current context node if the first argument is null.
throws
javax.xml.transform.TransformerException if an error occurs while executing the argument expression.


                                                                                                          
     
           
  

    return (null == m_arg0)
           ? xctxt.getCurrentNode() : m_arg0.asNode(xctxt);
  
protected doublegetArg0AsNumber(com.sun.org.apache.xpath.internal.XPathContext xctxt)
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.


    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();
  
protected com.sun.org.apache.xml.internal.utils.XMLStringgetArg0AsString(com.sun.org.apache.xpath.internal.XPathContext xctxt)
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.

    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();   
  
protected voidreportWrongNumberArgs()
Constructs and throws a WrongNumberArgException with the appropriate message for this function object.

throws
WrongNumberArgsException

      throw new WrongNumberArgsException(XSLMessages.createXPATHMessage(XPATHErrorResources.ER_ZERO_OR_ONE, null)); //"0 or 1");