com.sun.org.apache.xpath.internal.patterns.NodeTest Java Examples

The following examples show how to use com.sun.org.apache.xpath.internal.patterns.NodeTest. 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: DescendantIterator.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Initialize the context values for this expression
 * after it is cloned.
 *
 * @param context The XPath runtime context for this
 * transformation.
 */
public void setRoot(int context, Object environment)
{
  super.setRoot(context, environment);
  m_traverser = m_cdtm.getAxisTraverser(m_axis);

  String localName = getLocalName();
  String namespace = getNamespace();
  int what = m_whatToShow;
  // System.out.println("what: ");
  // NodeTest.debugWhatToShow(what);
  if(DTMFilter.SHOW_ALL == what
     || NodeTest.WILD.equals(localName)
     || NodeTest.WILD.equals(namespace))
  {
    m_extendedTypeID = 0;
  }
  else
  {
    int type = getNodeTypeTest(what);
    m_extendedTypeID = m_cdtm.getExpandedTypeID(namespace, localName, type);
  }

}
 
Example #2
Source File: DescendantIterator.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initialize the context values for this expression
 * after it is cloned.
 *
 * @param context The XPath runtime context for this
 * transformation.
 */
public void setRoot(int context, Object environment)
{
  super.setRoot(context, environment);
  m_traverser = m_cdtm.getAxisTraverser(m_axis);

  String localName = getLocalName();
  String namespace = getNamespace();
  int what = m_whatToShow;
  // System.out.println("what: ");
  // NodeTest.debugWhatToShow(what);
  if(DTMFilter.SHOW_ALL == what
     || NodeTest.WILD.equals(localName)
     || NodeTest.WILD.equals(namespace))
  {
    m_extendedTypeID = 0;
  }
  else
  {
    int type = getNodeTypeTest(what);
    m_extendedTypeID = m_cdtm.getExpandedTypeID(namespace, localName, type);
  }

}
 
Example #3
Source File: OpMap.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the namespace of the step.
 *
 * @param opPosOfStep The position of the FROM_XXX step.
 *
 * @return The step's namespace, NodeTest.WILD, or null for null namespace.
 */
public String getStepNS(int opPosOfStep)
{

  int argLenOfStep = getArgLengthOfStep(opPosOfStep);

  // System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
  if (argLenOfStep == 3)
  {
    int index = m_opMap.elementAt(opPosOfStep + 4);

    if (index >= 0)
      return (String) m_tokenQueue.elementAt(index);
    else if (OpCodes.ELEMWILDCARD == index)
      return NodeTest.WILD;
    else
      return null;
  }
  else
    return null;
}
 
Example #4
Source File: OpMap.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the namespace of the step.
 *
 * @param opPosOfStep The position of the FROM_XXX step.
 *
 * @return The step's namespace, NodeTest.WILD, or null for null namespace.
 */
public String getStepNS(int opPosOfStep)
{

  int argLenOfStep = getArgLengthOfStep(opPosOfStep);

  // System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
  if (argLenOfStep == 3)
  {
    int index = m_opMap.elementAt(opPosOfStep + 4);

    if (index >= 0)
      return (String) m_tokenQueue.elementAt(index);
    else if (OpCodes.ELEMWILDCARD == index)
      return NodeTest.WILD;
    else
      return null;
  }
  else
    return null;
}
 
Example #5
Source File: DescendantIterator.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Initialize the context values for this expression
 * after it is cloned.
 *
 * @param context The XPath runtime context for this
 * transformation.
 */
public void setRoot(int context, Object environment)
{
  super.setRoot(context, environment);
  m_traverser = m_cdtm.getAxisTraverser(m_axis);

  String localName = getLocalName();
  String namespace = getNamespace();
  int what = m_whatToShow;
  // System.out.println("what: ");
  // NodeTest.debugWhatToShow(what);
  if(DTMFilter.SHOW_ALL == what
     || NodeTest.WILD.equals(localName)
     || NodeTest.WILD.equals(namespace))
  {
    m_extendedTypeID = 0;
  }
  else
  {
    int type = getNodeTypeTest(what);
    m_extendedTypeID = m_cdtm.getExpandedTypeID(namespace, localName, type);
  }

}
 
Example #6
Source File: OpMap.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the namespace of the step.
 *
 * @param opPosOfStep The position of the FROM_XXX step.
 *
 * @return The step's namespace, NodeTest.WILD, or null for null namespace.
 */
public String getStepNS(int opPosOfStep)
{

  int argLenOfStep = getArgLengthOfStep(opPosOfStep);

  // System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
  if (argLenOfStep == 3)
  {
    int index = m_opMap.elementAt(opPosOfStep + 4);

    if (index >= 0)
      return (String) m_tokenQueue.elementAt(index);
    else if (OpCodes.ELEMWILDCARD == index)
      return NodeTest.WILD;
    else
      return null;
  }
  else
    return null;
}
 
Example #7
Source File: OpMap.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Get the namespace of the step.
 *
 * @param opPosOfStep The position of the FROM_XXX step.
 *
 * @return The step's namespace, NodeTest.WILD, or null for null namespace.
 */
public String getStepNS(int opPosOfStep)
{

  int argLenOfStep = getArgLengthOfStep(opPosOfStep);

  // System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
  if (argLenOfStep == 3)
  {
    int index = m_opMap.elementAt(opPosOfStep + 4);

    if (index >= 0)
      return (String) m_tokenQueue.elementAt(index);
    else if (OpCodes.ELEMWILDCARD == index)
      return NodeTest.WILD;
    else
      return null;
  }
  else
    return null;
}
 
Example #8
Source File: DescendantIterator.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initialize the context values for this expression
 * after it is cloned.
 *
 * @param context The XPath runtime context for this
 * transformation.
 */
public void setRoot(int context, Object environment)
{
  super.setRoot(context, environment);
  m_traverser = m_cdtm.getAxisTraverser(m_axis);

  String localName = getLocalName();
  String namespace = getNamespace();
  int what = m_whatToShow;
  // System.out.println("what: ");
  // NodeTest.debugWhatToShow(what);
  if(DTMFilter.SHOW_ALL == what
     || NodeTest.WILD.equals(localName)
     || NodeTest.WILD.equals(namespace))
  {
    m_extendedTypeID = 0;
  }
  else
  {
    int type = getNodeTypeTest(what);
    m_extendedTypeID = m_cdtm.getExpandedTypeID(namespace, localName, type);
  }

}
 
Example #9
Source File: OpMap.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the namespace of the step.
 *
 * @param opPosOfStep The position of the FROM_XXX step.
 *
 * @return The step's namespace, NodeTest.WILD, or null for null namespace.
 */
public String getStepNS(int opPosOfStep)
{

  int argLenOfStep = getArgLengthOfStep(opPosOfStep);

  // System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
  if (argLenOfStep == 3)
  {
    int index = m_opMap.elementAt(opPosOfStep + 4);

    if (index >= 0)
      return (String) m_tokenQueue.elementAt(index);
    else if (OpCodes.ELEMWILDCARD == index)
      return NodeTest.WILD;
    else
      return null;
  }
  else
    return null;
}
 
Example #10
Source File: DescendantIterator.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initialize the context values for this expression
 * after it is cloned.
 *
 * @param context The XPath runtime context for this
 * transformation.
 */
public void setRoot(int context, Object environment)
{
  super.setRoot(context, environment);
  m_traverser = m_cdtm.getAxisTraverser(m_axis);

  String localName = getLocalName();
  String namespace = getNamespace();
  int what = m_whatToShow;
  // System.out.println("what: ");
  // NodeTest.debugWhatToShow(what);
  if(DTMFilter.SHOW_ALL == what
     || NodeTest.WILD.equals(localName)
     || NodeTest.WILD.equals(namespace))
  {
    m_extendedTypeID = 0;
  }
  else
  {
    int type = getNodeTypeTest(what);
    m_extendedTypeID = m_cdtm.getExpandedTypeID(namespace, localName, type);
  }

}
 
Example #11
Source File: DescendantIterator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initialize the context values for this expression
 * after it is cloned.
 *
 * @param context The XPath runtime context for this
 * transformation.
 */
public void setRoot(int context, Object environment)
{
  super.setRoot(context, environment);
  m_traverser = m_cdtm.getAxisTraverser(m_axis);

  String localName = getLocalName();
  String namespace = getNamespace();
  int what = m_whatToShow;
  // System.out.println("what: ");
  // NodeTest.debugWhatToShow(what);
  if(DTMFilter.SHOW_ALL == what
     || NodeTest.WILD.equals(localName)
     || NodeTest.WILD.equals(namespace))
  {
    m_extendedTypeID = 0;
  }
  else
  {
    int type = getNodeTypeTest(what);
    m_extendedTypeID = m_cdtm.getExpandedTypeID(namespace, localName, type);
  }

}
 
Example #12
Source File: OpMap.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Get the namespace of the step.
 *
 * @param opPosOfStep The position of the FROM_XXX step.
 *
 * @return The step's namespace, NodeTest.WILD, or null for null namespace.
 */
public String getStepNS(int opPosOfStep)
{

  int argLenOfStep = getArgLengthOfStep(opPosOfStep);

  // System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
  if (argLenOfStep == 3)
  {
    int index = m_opMap.elementAt(opPosOfStep + 4);

    if (index >= 0)
      return (String) m_tokenQueue.elementAt(index);
    else if (OpCodes.ELEMWILDCARD == index)
      return NodeTest.WILD;
    else
      return null;
  }
  else
    return null;
}
 
Example #13
Source File: OpMap.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the namespace of the step.
 *
 * @param opPosOfStep The position of the FROM_XXX step.
 *
 * @return The step's namespace, NodeTest.WILD, or null for null namespace.
 */
public String getStepNS(int opPosOfStep)
{

  int argLenOfStep = getArgLengthOfStep(opPosOfStep);

  // System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
  if (argLenOfStep == 3)
  {
    int index = m_opMap.elementAt(opPosOfStep + 4);

    if (index >= 0)
      return (String) m_tokenQueue.elementAt(index);
    else if (OpCodes.ELEMWILDCARD == index)
      return NodeTest.WILD;
    else
      return null;
  }
  else
    return null;
}
 
Example #14
Source File: DescendantIterator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initialize the context values for this expression
 * after it is cloned.
 *
 * @param context The XPath runtime context for this
 * transformation.
 */
public void setRoot(int context, Object environment)
{
  super.setRoot(context, environment);
  m_traverser = m_cdtm.getAxisTraverser(m_axis);

  String localName = getLocalName();
  String namespace = getNamespace();
  int what = m_whatToShow;
  // System.out.println("what: ");
  // NodeTest.debugWhatToShow(what);
  if(DTMFilter.SHOW_ALL == what
     || NodeTest.WILD.equals(localName)
     || NodeTest.WILD.equals(namespace))
  {
    m_extendedTypeID = 0;
  }
  else
  {
    int type = getNodeTypeTest(what);
    m_extendedTypeID = m_cdtm.getExpandedTypeID(namespace, localName, type);
  }

}
 
Example #15
Source File: OpMap.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the namespace of the step.
 *
 * @param opPosOfStep The position of the FROM_XXX step.
 *
 * @return The step's namespace, NodeTest.WILD, or null for null namespace.
 */
public String getStepNS(int opPosOfStep)
{

  int argLenOfStep = getArgLengthOfStep(opPosOfStep);

  // System.out.println("getStepNS.argLenOfStep: "+argLenOfStep);
  if (argLenOfStep == 3)
  {
    int index = m_opMap.elementAt(opPosOfStep + 4);

    if (index >= 0)
      return (String) m_tokenQueue.elementAt(index);
    else if (OpCodes.ELEMWILDCARD == index)
      return NodeTest.WILD;
    else
      return null;
  }
  else
    return null;
}
 
Example #16
Source File: DescendantIterator.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Initialize the context values for this expression
 * after it is cloned.
 *
 * @param context The XPath runtime context for this
 * transformation.
 */
public void setRoot(int context, Object environment)
{
  super.setRoot(context, environment);
  m_traverser = m_cdtm.getAxisTraverser(m_axis);

  String localName = getLocalName();
  String namespace = getNamespace();
  int what = m_whatToShow;
  // System.out.println("what: ");
  // NodeTest.debugWhatToShow(what);
  if(DTMFilter.SHOW_ALL == what
     || NodeTest.WILD.equals(localName)
     || NodeTest.WILD.equals(namespace))
  {
    m_extendedTypeID = 0;
  }
  else
  {
    int type = getNodeTypeTest(what);
    m_extendedTypeID = m_cdtm.getExpandedTypeID(namespace, localName, type);
  }

}
 
Example #17
Source File: DescendantIterator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the first node out of the nodeset, if this expression is
 * a nodeset expression.  This is the default implementation for
 * nodesets.
 * <p>WARNING: Do not mutate this class from this function!</p>
 * @param xctxt The XPath runtime context.
 * @return the first node out of the nodeset, or DTM.NULL.
 */
public int asNode(XPathContext xctxt)
  throws javax.xml.transform.TransformerException
{
  if(getPredicateCount() > 0)
    return super.asNode(xctxt);

  int current = xctxt.getCurrentNode();

  DTM dtm = xctxt.getDTM(current);
  DTMAxisTraverser traverser = dtm.getAxisTraverser(m_axis);

  String localName = getLocalName();
  String namespace = getNamespace();
  int what = m_whatToShow;

  // System.out.print(" (DescendantIterator) ");

  // System.out.println("what: ");
  // NodeTest.debugWhatToShow(what);
  if(DTMFilter.SHOW_ALL == what
     || localName == NodeTest.WILD
     || namespace == NodeTest.WILD)
  {
    return traverser.first(current);
  }
  else
  {
    int type = getNodeTypeTest(what);
    int extendedType = dtm.getExpandedTypeID(namespace, localName, type);
    return traverser.first(current, extendedType);
  }
}
 
Example #18
Source File: UnionChildIterator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test whether a specified node is visible in the logical view of a
 * TreeWalker or NodeIterator. This function will be called by the
 * implementation of TreeWalker and NodeIterator; it is not intended to
 * be called directly from user code.
 * @param n  The node to check to see if it passes the filter or not.
 * @return  a constant to determine whether the node is accepted,
 *   rejected, or skipped, as defined  above .
 */
public short acceptNode(int n)
{
  XPathContext xctxt = getXPathContext();
  try
  {
    xctxt.pushCurrentNode(n);
    for (int i = 0; i < m_nodeTests.length; i++)
    {
      PredicatedNodeTest pnt = m_nodeTests[i];
      XObject score = pnt.execute(xctxt, n);
      if (score != NodeTest.SCORE_NONE)
      {
        // Note that we are assuming there are no positional predicates!
        if (pnt.getPredicateCount() > 0)
        {
          if (pnt.executePredicates(n, xctxt))
            return DTMIterator.FILTER_ACCEPT;
        }
        else
          return DTMIterator.FILTER_ACCEPT;

      }
    }
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix this.
    throw new RuntimeException(se.getMessage());
  }
  finally
  {
    xctxt.popCurrentNode();
  }
  return DTMIterator.FILTER_SKIP;
}
 
Example #19
Source File: DescendantIterator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the first node out of the nodeset, if this expression is
 * a nodeset expression.  This is the default implementation for
 * nodesets.
 * <p>WARNING: Do not mutate this class from this function!</p>
 * @param xctxt The XPath runtime context.
 * @return the first node out of the nodeset, or DTM.NULL.
 */
public int asNode(XPathContext xctxt)
  throws javax.xml.transform.TransformerException
{
  if(getPredicateCount() > 0)
    return super.asNode(xctxt);

  int current = xctxt.getCurrentNode();

  DTM dtm = xctxt.getDTM(current);
  DTMAxisTraverser traverser = dtm.getAxisTraverser(m_axis);

  String localName = getLocalName();
  String namespace = getNamespace();
  int what = m_whatToShow;

  // System.out.print(" (DescendantIterator) ");

  // System.out.println("what: ");
  // NodeTest.debugWhatToShow(what);
  if(DTMFilter.SHOW_ALL == what
     || localName == NodeTest.WILD
     || namespace == NodeTest.WILD)
  {
    return traverser.first(current);
  }
  else
  {
    int type = getNodeTypeTest(what);
    int extendedType = dtm.getExpandedTypeID(namespace, localName, type);
    return traverser.first(current, extendedType);
  }
}
 
Example #20
Source File: PredicatedNodeTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Test whether a specified node is visible in the logical view of a
 * TreeWalker or NodeIterator. This function will be called by the
 * implementation of TreeWalker and NodeIterator; it is not intended to
 * be called directly from user code.
 * @param n  The node to check to see if it passes the filter or not.
 * @return  a constant to determine whether the node is accepted,
 *   rejected, or skipped, as defined  above .
 */
public short acceptNode(int n)
{

  XPathContext xctxt = m_lpi.getXPathContext();

  try
  {
    xctxt.pushCurrentNode(n);

    XObject score = execute(xctxt, n);

    // System.out.println("\n::acceptNode - score: "+score.num()+"::");
    if (score != NodeTest.SCORE_NONE)
    {
      if (getPredicateCount() > 0)
      {
        countProximityPosition(0);

        if (!executePredicates(n, xctxt))
          return DTMIterator.FILTER_SKIP;
      }

      return DTMIterator.FILTER_ACCEPT;
    }
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix this.
    throw new RuntimeException(se.getMessage());
  }
  finally
  {
    xctxt.popCurrentNode();
  }

  return DTMIterator.FILTER_SKIP;
}
 
Example #21
Source File: UnionChildIterator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test whether a specified node is visible in the logical view of a
 * TreeWalker or NodeIterator. This function will be called by the
 * implementation of TreeWalker and NodeIterator; it is not intended to
 * be called directly from user code.
 * @param n  The node to check to see if it passes the filter or not.
 * @return  a constant to determine whether the node is accepted,
 *   rejected, or skipped, as defined  above .
 */
public short acceptNode(int n)
{
  XPathContext xctxt = getXPathContext();
  try
  {
    xctxt.pushCurrentNode(n);
    for (int i = 0; i < m_nodeTests.length; i++)
    {
      PredicatedNodeTest pnt = m_nodeTests[i];
      XObject score = pnt.execute(xctxt, n);
      if (score != NodeTest.SCORE_NONE)
      {
        // Note that we are assuming there are no positional predicates!
        if (pnt.getPredicateCount() > 0)
        {
          if (pnt.executePredicates(n, xctxt))
            return DTMIterator.FILTER_ACCEPT;
        }
        else
          return DTMIterator.FILTER_ACCEPT;

      }
    }
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix this.
    throw new RuntimeException(se.getMessage());
  }
  finally
  {
    xctxt.popCurrentNode();
  }
  return DTMIterator.FILTER_SKIP;
}
 
Example #22
Source File: PredicatedNodeTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Test whether a specified node is visible in the logical view of a
 * TreeWalker or NodeIterator. This function will be called by the
 * implementation of TreeWalker and NodeIterator; it is not intended to
 * be called directly from user code.
 * @param n  The node to check to see if it passes the filter or not.
 * @return  a constant to determine whether the node is accepted,
 *   rejected, or skipped, as defined  above .
 */
public short acceptNode(int n)
{

  XPathContext xctxt = m_lpi.getXPathContext();

  try
  {
    xctxt.pushCurrentNode(n);

    XObject score = execute(xctxt, n);

    // System.out.println("\n::acceptNode - score: "+score.num()+"::");
    if (score != NodeTest.SCORE_NONE)
    {
      if (getPredicateCount() > 0)
      {
        countProximityPosition(0);

        if (!executePredicates(n, xctxt))
          return DTMIterator.FILTER_SKIP;
      }

      return DTMIterator.FILTER_ACCEPT;
    }
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix this.
    throw new RuntimeException(se.getMessage());
  }
  finally
  {
    xctxt.popCurrentNode();
  }

  return DTMIterator.FILTER_SKIP;
}
 
Example #23
Source File: UnionChildIterator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test whether a specified node is visible in the logical view of a
 * TreeWalker or NodeIterator. This function will be called by the
 * implementation of TreeWalker and NodeIterator; it is not intended to
 * be called directly from user code.
 * @param n  The node to check to see if it passes the filter or not.
 * @return  a constant to determine whether the node is accepted,
 *   rejected, or skipped, as defined  above .
 */
public short acceptNode(int n)
{
  XPathContext xctxt = getXPathContext();
  try
  {
    xctxt.pushCurrentNode(n);
    for (int i = 0; i < m_nodeTests.length; i++)
    {
      PredicatedNodeTest pnt = m_nodeTests[i];
      XObject score = pnt.execute(xctxt, n);
      if (score != NodeTest.SCORE_NONE)
      {
        // Note that we are assuming there are no positional predicates!
        if (pnt.getPredicateCount() > 0)
        {
          if (pnt.executePredicates(n, xctxt))
            return DTMIterator.FILTER_ACCEPT;
        }
        else
          return DTMIterator.FILTER_ACCEPT;

      }
    }
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix this.
    throw new RuntimeException(se.getMessage());
  }
  finally
  {
    xctxt.popCurrentNode();
  }
  return DTMIterator.FILTER_SKIP;
}
 
Example #24
Source File: UnionChildIterator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test whether a specified node is visible in the logical view of a
 * TreeWalker or NodeIterator. This function will be called by the
 * implementation of TreeWalker and NodeIterator; it is not intended to
 * be called directly from user code.
 * @param n  The node to check to see if it passes the filter or not.
 * @return  a constant to determine whether the node is accepted,
 *   rejected, or skipped, as defined  above .
 */
public short acceptNode(int n)
{
  XPathContext xctxt = getXPathContext();
  try
  {
    xctxt.pushCurrentNode(n);
    for (int i = 0; i < m_nodeTests.length; i++)
    {
      PredicatedNodeTest pnt = m_nodeTests[i];
      XObject score = pnt.execute(xctxt, n);
      if (score != NodeTest.SCORE_NONE)
      {
        // Note that we are assuming there are no positional predicates!
        if (pnt.getPredicateCount() > 0)
        {
          if (pnt.executePredicates(n, xctxt))
            return DTMIterator.FILTER_ACCEPT;
        }
        else
          return DTMIterator.FILTER_ACCEPT;

      }
    }
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix this.
    throw new RuntimeException(se.getMessage());
  }
  finally
  {
    xctxt.popCurrentNode();
  }
  return DTMIterator.FILTER_SKIP;
}
 
Example #25
Source File: PredicatedNodeTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Test whether a specified node is visible in the logical view of a
 * TreeWalker or NodeIterator. This function will be called by the
 * implementation of TreeWalker and NodeIterator; it is not intended to
 * be called directly from user code.
 * @param n  The node to check to see if it passes the filter or not.
 * @return  a constant to determine whether the node is accepted,
 *   rejected, or skipped, as defined  above .
 */
public short acceptNode(int n)
{

  XPathContext xctxt = m_lpi.getXPathContext();

  try
  {
    xctxt.pushCurrentNode(n);

    XObject score = execute(xctxt, n);

    // System.out.println("\n::acceptNode - score: "+score.num()+"::");
    if (score != NodeTest.SCORE_NONE)
    {
      if (getPredicateCount() > 0)
      {
        countProximityPosition(0);

        if (!executePredicates(n, xctxt))
          return DTMIterator.FILTER_SKIP;
      }

      return DTMIterator.FILTER_ACCEPT;
    }
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix this.
    throw new RuntimeException(se.getMessage());
  }
  finally
  {
    xctxt.popCurrentNode();
  }

  return DTMIterator.FILTER_SKIP;
}
 
Example #26
Source File: UnionChildIterator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test whether a specified node is visible in the logical view of a
 * TreeWalker or NodeIterator. This function will be called by the
 * implementation of TreeWalker and NodeIterator; it is not intended to
 * be called directly from user code.
 * @param n  The node to check to see if it passes the filter or not.
 * @return  a constant to determine whether the node is accepted,
 *   rejected, or skipped, as defined  above .
 */
public short acceptNode(int n)
{
  XPathContext xctxt = getXPathContext();
  try
  {
    xctxt.pushCurrentNode(n);
    for (int i = 0; i < m_nodeTests.length; i++)
    {
      PredicatedNodeTest pnt = m_nodeTests[i];
      XObject score = pnt.execute(xctxt, n);
      if (score != NodeTest.SCORE_NONE)
      {
        // Note that we are assuming there are no positional predicates!
        if (pnt.getPredicateCount() > 0)
        {
          if (pnt.executePredicates(n, xctxt))
            return DTMIterator.FILTER_ACCEPT;
        }
        else
          return DTMIterator.FILTER_ACCEPT;

      }
    }
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix this.
    throw new RuntimeException(se.getMessage());
  }
  finally
  {
    xctxt.popCurrentNode();
  }
  return DTMIterator.FILTER_SKIP;
}
 
Example #27
Source File: OpMap.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the local name of the step.
 * @param opPosOfStep The position of the FROM_XXX step.
 *
 * @return OpCodes.EMPTY, OpCodes.ELEMWILDCARD, or the local name.
 */
public String getStepLocalName(int opPosOfStep)
{

  int argLenOfStep = getArgLengthOfStep(opPosOfStep);

  // System.out.println("getStepLocalName.argLenOfStep: "+argLenOfStep);
  int index;

  switch (argLenOfStep)
  {
  case 0 :
    index = OpCodes.EMPTY;
    break;
  case 1 :
    index = OpCodes.ELEMWILDCARD;
    break;
  case 2 :
    index = m_opMap.elementAt(opPosOfStep + 4);
    break;
  case 3 :
    index = m_opMap.elementAt(opPosOfStep + 5);
    break;
  default :
    index = OpCodes.EMPTY;
    break;  // Should assert error
  }

  // int index = (argLenOfStep == 3) ? m_opMap[opPosOfStep+5]
  //                                  : ((argLenOfStep == 1) ? -3 : -2);
  if (index >= 0)
    return (String) m_tokenQueue.elementAt(index).toString();
  else if (OpCodes.ELEMWILDCARD == index)
    return NodeTest.WILD;
  else
    return null;
}
 
Example #28
Source File: DescendantIterator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the first node out of the nodeset, if this expression is
 * a nodeset expression.  This is the default implementation for
 * nodesets.
 * <p>WARNING: Do not mutate this class from this function!</p>
 * @param xctxt The XPath runtime context.
 * @return the first node out of the nodeset, or DTM.NULL.
 */
public int asNode(XPathContext xctxt)
  throws javax.xml.transform.TransformerException
{
  if(getPredicateCount() > 0)
    return super.asNode(xctxt);

  int current = xctxt.getCurrentNode();

  DTM dtm = xctxt.getDTM(current);
  DTMAxisTraverser traverser = dtm.getAxisTraverser(m_axis);

  String localName = getLocalName();
  String namespace = getNamespace();
  int what = m_whatToShow;

  // System.out.print(" (DescendantIterator) ");

  // System.out.println("what: ");
  // NodeTest.debugWhatToShow(what);
  if(DTMFilter.SHOW_ALL == what
     || localName == NodeTest.WILD
     || namespace == NodeTest.WILD)
  {
    return traverser.first(current);
  }
  else
  {
    int type = getNodeTypeTest(what);
    int extendedType = dtm.getExpandedTypeID(namespace, localName, type);
    return traverser.first(current, extendedType);
  }
}
 
Example #29
Source File: PredicatedNodeTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 *  Test whether a specified node is visible in the logical view of a
 * TreeWalker or NodeIterator. This function will be called by the
 * implementation of TreeWalker and NodeIterator; it is not intended to
 * be called directly from user code.
 * @param n  The node to check to see if it passes the filter or not.
 * @return  a constant to determine whether the node is accepted,
 *   rejected, or skipped, as defined  above .
 */
public short acceptNode(int n)
{

  XPathContext xctxt = m_lpi.getXPathContext();

  try
  {
    xctxt.pushCurrentNode(n);

    XObject score = execute(xctxt, n);

    // System.out.println("\n::acceptNode - score: "+score.num()+"::");
    if (score != NodeTest.SCORE_NONE)
    {
      if (getPredicateCount() > 0)
      {
        countProximityPosition(0);

        if (!executePredicates(n, xctxt))
          return DTMIterator.FILTER_SKIP;
      }

      return DTMIterator.FILTER_ACCEPT;
    }
  }
  catch (javax.xml.transform.TransformerException se)
  {

    // TODO: Fix this.
    throw new RuntimeException(se.getMessage());
  }
  finally
  {
    xctxt.popCurrentNode();
  }

  return DTMIterator.FILTER_SKIP;
}
 
Example #30
Source File: OpMap.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Get the local name of the step.
 * @param opPosOfStep The position of the FROM_XXX step.
 *
 * @return OpCodes.EMPTY, OpCodes.ELEMWILDCARD, or the local name.
 */
public String getStepLocalName(int opPosOfStep)
{

  int argLenOfStep = getArgLengthOfStep(opPosOfStep);

  // System.out.println("getStepLocalName.argLenOfStep: "+argLenOfStep);
  int index;

  switch (argLenOfStep)
  {
  case 0 :
    index = OpCodes.EMPTY;
    break;
  case 1 :
    index = OpCodes.ELEMWILDCARD;
    break;
  case 2 :
    index = m_opMap.elementAt(opPosOfStep + 4);
    break;
  case 3 :
    index = m_opMap.elementAt(opPosOfStep + 5);
    break;
  default :
    index = OpCodes.EMPTY;
    break;  // Should assert error
  }

  // int index = (argLenOfStep == 3) ? m_opMap[opPosOfStep+5]
  //                                  : ((argLenOfStep == 1) ? -3 : -2);
  if (index >= 0)
    return (String) m_tokenQueue.elementAt(index).toString();
  else if (OpCodes.ELEMWILDCARD == index)
    return NodeTest.WILD;
  else
    return null;
}