com.sun.org.apache.xml.internal.dtm.DTMFilter Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.dtm.DTMFilter. 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: BasicTestIterator.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a LocPathIterator object, including creation
 * of step walkers from the opcode list, and call back
 * into the Compiler to create predicate expressions.
 *
 * @param compiler The Compiler which is creating
 * this expression.
 * @param opPos The position of this iterator in the
 * opcode list from the compiler.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected BasicTestIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);
  int whatToShow = compiler.getWhatToShow(firstStepPos);

  if ((0 == (whatToShow
             & (DTMFilter.SHOW_ATTRIBUTE
             | DTMFilter.SHOW_NAMESPACE
             | DTMFilter.SHOW_ELEMENT
             | DTMFilter.SHOW_PROCESSING_INSTRUCTION)))
             || (whatToShow == DTMFilter.SHOW_ALL))
    initNodeTest(whatToShow);
  else
  {
    initNodeTest(whatToShow, compiler.getStepNS(firstStepPos),
                            compiler.getStepLocalName(firstStepPos));
  }
  initPredicateInfo(compiler, firstStepPos);
}
 
Example #2
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 #3
Source File: BasicTestIterator.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Create a LocPathIterator object, including creation
 * of step walkers from the opcode list, and call back
 * into the Compiler to create predicate expressions.
 *
 * @param compiler The Compiler which is creating
 * this expression.
 * @param opPos The position of this iterator in the
 * opcode list from the compiler.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected BasicTestIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);
  int whatToShow = compiler.getWhatToShow(firstStepPos);

  if ((0 == (whatToShow
             & (DTMFilter.SHOW_ATTRIBUTE
             | DTMFilter.SHOW_NAMESPACE
             | DTMFilter.SHOW_ELEMENT
             | DTMFilter.SHOW_PROCESSING_INSTRUCTION)))
             || (whatToShow == DTMFilter.SHOW_ALL))
    initNodeTest(whatToShow);
  else
  {
    initNodeTest(whatToShow, compiler.getStepNS(firstStepPos),
                            compiler.getStepLocalName(firstStepPos));
  }
  initPredicateInfo(compiler, firstStepPos);
}
 
Example #4
Source File: BasicTestIterator.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a LocPathIterator object, including creation
 * of step walkers from the opcode list, and call back
 * into the Compiler to create predicate expressions.
 *
 * @param compiler The Compiler which is creating
 * this expression.
 * @param opPos The position of this iterator in the
 * opcode list from the compiler.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected BasicTestIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);
  int whatToShow = compiler.getWhatToShow(firstStepPos);

  if ((0 == (whatToShow
             & (DTMFilter.SHOW_ATTRIBUTE
             | DTMFilter.SHOW_NAMESPACE
             | DTMFilter.SHOW_ELEMENT
             | DTMFilter.SHOW_PROCESSING_INSTRUCTION)))
             || (whatToShow == DTMFilter.SHOW_ALL))
    initNodeTest(whatToShow);
  else
  {
    initNodeTest(whatToShow, compiler.getStepNS(firstStepPos),
                            compiler.getStepLocalName(firstStepPos));
  }
  initPredicateInfo(compiler, firstStepPos);
}
 
Example #5
Source File: BasicTestIterator.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a LocPathIterator object, including creation
 * of step walkers from the opcode list, and call back
 * into the Compiler to create predicate expressions.
 *
 * @param compiler The Compiler which is creating
 * this expression.
 * @param opPos The position of this iterator in the
 * opcode list from the compiler.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected BasicTestIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);
  int whatToShow = compiler.getWhatToShow(firstStepPos);

  if ((0 == (whatToShow
             & (DTMFilter.SHOW_ATTRIBUTE
             | DTMFilter.SHOW_NAMESPACE
             | DTMFilter.SHOW_ELEMENT
             | DTMFilter.SHOW_PROCESSING_INSTRUCTION)))
             || (whatToShow == DTMFilter.SHOW_ALL))
    initNodeTest(whatToShow);
  else
  {
    initNodeTest(whatToShow, compiler.getStepNS(firstStepPos),
                            compiler.getStepLocalName(firstStepPos));
  }
  initPredicateInfo(compiler, firstStepPos);
}
 
Example #6
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 #7
Source File: BasicTestIterator.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Create a LocPathIterator object, including creation
 * of step walkers from the opcode list, and call back
 * into the Compiler to create predicate expressions.
 *
 * @param compiler The Compiler which is creating
 * this expression.
 * @param opPos The position of this iterator in the
 * opcode list from the compiler.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected BasicTestIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);
  int whatToShow = compiler.getWhatToShow(firstStepPos);

  if ((0 == (whatToShow
             & (DTMFilter.SHOW_ATTRIBUTE
             | DTMFilter.SHOW_NAMESPACE
             | DTMFilter.SHOW_ELEMENT
             | DTMFilter.SHOW_PROCESSING_INSTRUCTION)))
             || (whatToShow == DTMFilter.SHOW_ALL))
    initNodeTest(whatToShow);
  else
  {
    initNodeTest(whatToShow, compiler.getStepNS(firstStepPos),
                            compiler.getStepLocalName(firstStepPos));
  }
  initPredicateInfo(compiler, firstStepPos);
}
 
Example #8
Source File: BasicTestIterator.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Create a LocPathIterator object, including creation
 * of step walkers from the opcode list, and call back
 * into the Compiler to create predicate expressions.
 *
 * @param compiler The Compiler which is creating
 * this expression.
 * @param opPos The position of this iterator in the
 * opcode list from the compiler.
 *
 * @throws javax.xml.transform.TransformerException
 */
protected BasicTestIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{
  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);
  int whatToShow = compiler.getWhatToShow(firstStepPos);

  if ((0 == (whatToShow
             & (DTMFilter.SHOW_ATTRIBUTE
             | DTMFilter.SHOW_NAMESPACE
             | DTMFilter.SHOW_ELEMENT
             | DTMFilter.SHOW_PROCESSING_INSTRUCTION)))
             || (whatToShow == DTMFilter.SHOW_ALL))
    initNodeTest(whatToShow);
  else
  {
    initNodeTest(whatToShow, compiler.getStepNS(firstStepPos),
                            compiler.getStepLocalName(firstStepPos));
  }
  initPredicateInfo(compiler, firstStepPos);
}
 
Example #9
Source File: DescendantIterator.java    From openjdk-8 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 #10
Source File: DescendantIterator.java    From jdk1.8-source-analysis with Apache License 2.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 #11
Source File: DescendantIterator.java    From openjdk-jdk8u-backup 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 #12
Source File: FilterIterator.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public int next() {
    int node;
    while ((node = _source.next()) != END) {
        if (_filter.acceptNode(node, DTMFilter.SHOW_ALL) == DTMIterator.FILTER_ACCEPT) {
            return returnNode(node);
        }
    }
    return END;
}
 
Example #13
Source File: FilterIterator.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public int next() {
    int node;
    while ((node = _source.next()) != END) {
        if (_filter.acceptNode(node, DTMFilter.SHOW_ALL) == DTMIterator.FILTER_ACCEPT) {
            return returnNode(node);
        }
    }
    return END;
}
 
Example #14
Source File: StepPattern.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculate the local name or psuedo name of the node that this pattern will test,
 * for hash table lookup optimization.
 *
 * @see com.sun.org.apache.xpath.internal.compiler.PsuedoNames
 */
public void calcTargetString()
{

  int whatToShow = getWhatToShow();

  switch (whatToShow)
  {
  case DTMFilter.SHOW_COMMENT :
    m_targetString = PsuedoNames.PSEUDONAME_COMMENT;
    break;
  case DTMFilter.SHOW_TEXT :
  case DTMFilter.SHOW_CDATA_SECTION :
  case (DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION) :
    m_targetString = PsuedoNames.PSEUDONAME_TEXT;
    break;
  case DTMFilter.SHOW_ALL :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  case DTMFilter.SHOW_DOCUMENT :
  case DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT :
    m_targetString = PsuedoNames.PSEUDONAME_ROOT;
    break;
  case DTMFilter.SHOW_ELEMENT :
    if (this.WILD == m_name)
      m_targetString = PsuedoNames.PSEUDONAME_ANY;
    else
      m_targetString = m_name;
    break;
  default :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  }
}
 
Example #15
Source File: StepPattern.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculate the local name or psuedo name of the node that this pattern will test,
 * for hash table lookup optimization.
 *
 * @see com.sun.org.apache.xpath.internal.compiler.PsuedoNames
 */
public void calcTargetString()
{

  int whatToShow = getWhatToShow();

  switch (whatToShow)
  {
  case DTMFilter.SHOW_COMMENT :
    m_targetString = PsuedoNames.PSEUDONAME_COMMENT;
    break;
  case DTMFilter.SHOW_TEXT :
  case DTMFilter.SHOW_CDATA_SECTION :
  case (DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION) :
    m_targetString = PsuedoNames.PSEUDONAME_TEXT;
    break;
  case DTMFilter.SHOW_ALL :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  case DTMFilter.SHOW_DOCUMENT :
  case DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT :
    m_targetString = PsuedoNames.PSEUDONAME_ROOT;
    break;
  case DTMFilter.SHOW_ELEMENT :
    if (this.WILD == m_name)
      m_targetString = PsuedoNames.PSEUDONAME_ANY;
    else
      m_targetString = m_name;
    break;
  default :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  }
}
 
Example #16
Source File: DescendantIterator.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Create a DescendantIterator object.
 *
 */
public DescendantIterator()
{
  super(null);
  m_axis = Axis.DESCENDANTSORSELFFROMROOT;
  int whatToShow = DTMFilter.SHOW_ALL;
  initNodeTest(whatToShow);
}
 
Example #17
Source File: DescendantIterator.java    From JDKSourceCode1.8 with MIT License 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: OneStepIteratorForward.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Create a OneStepIterator object that will just traverse the self axes.
 *
 * @param axis One of the com.sun.org.apache.xml.internal.dtm.Axis integers.
 *
 * @throws javax.xml.transform.TransformerException
 */
public OneStepIteratorForward(int axis)
{
  super(null);

  m_axis = axis;
  int whatToShow = DTMFilter.SHOW_ALL;
  initNodeTest(whatToShow);
}
 
Example #19
Source File: OneStepIterator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a OneStepIterator object.
 *
 * @param iterator The DTM iterator which this iterator will use.
 * @param axis One of Axis.Child, etc., or -1 if the axis is unknown.
 *
 * @throws javax.xml.transform.TransformerException
 */
public OneStepIterator(DTMAxisIterator iterator, int axis)
        throws javax.xml.transform.TransformerException
{
  super(null);

  m_iterator = iterator;
  m_axis = axis;
  int whatToShow = DTMFilter.SHOW_ALL;
  initNodeTest(whatToShow);
}
 
Example #20
Source File: OneStepIterator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a OneStepIterator object.
 *
 * @param iterator The DTM iterator which this iterator will use.
 * @param axis One of Axis.Child, etc., or -1 if the axis is unknown.
 *
 * @throws javax.xml.transform.TransformerException
 */
public OneStepIterator(DTMAxisIterator iterator, int axis)
        throws javax.xml.transform.TransformerException
{
  super(null);

  m_iterator = iterator;
  m_axis = axis;
  int whatToShow = DTMFilter.SHOW_ALL;
  initNodeTest(whatToShow);
}
 
Example #21
Source File: FilterIterator.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public int next() {
    int node;
    while ((node = _source.next()) != END) {
        if (_filter.acceptNode(node, DTMFilter.SHOW_ALL) == DTMIterator.FILTER_ACCEPT) {
            return returnNode(node);
        }
    }
    return END;
}
 
Example #22
Source File: StepPattern.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculate the local name or psuedo name of the node that this pattern will test,
 * for hash table lookup optimization.
 *
 * @see com.sun.org.apache.xpath.internal.compiler.PsuedoNames
 */
public void calcTargetString()
{

  int whatToShow = getWhatToShow();

  switch (whatToShow)
  {
  case DTMFilter.SHOW_COMMENT :
    m_targetString = PsuedoNames.PSEUDONAME_COMMENT;
    break;
  case DTMFilter.SHOW_TEXT :
  case DTMFilter.SHOW_CDATA_SECTION :
  case (DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION) :
    m_targetString = PsuedoNames.PSEUDONAME_TEXT;
    break;
  case DTMFilter.SHOW_ALL :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  case DTMFilter.SHOW_DOCUMENT :
  case DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT :
    m_targetString = PsuedoNames.PSEUDONAME_ROOT;
    break;
  case DTMFilter.SHOW_ELEMENT :
    if (this.WILD == m_name)
      m_targetString = PsuedoNames.PSEUDONAME_ANY;
    else
      m_targetString = m_name;
    break;
  default :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  }
}
 
Example #23
Source File: StepPattern.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calculate the local name or psuedo name of the node that this pattern will test,
 * for hash table lookup optimization.
 *
 * @see com.sun.org.apache.xpath.internal.compiler.PsuedoNames
 */
public void calcTargetString()
{

  int whatToShow = getWhatToShow();

  switch (whatToShow)
  {
  case DTMFilter.SHOW_COMMENT :
    m_targetString = PsuedoNames.PSEUDONAME_COMMENT;
    break;
  case DTMFilter.SHOW_TEXT :
  case DTMFilter.SHOW_CDATA_SECTION :
  case (DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION) :
    m_targetString = PsuedoNames.PSEUDONAME_TEXT;
    break;
  case DTMFilter.SHOW_ALL :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  case DTMFilter.SHOW_DOCUMENT :
  case DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT :
    m_targetString = PsuedoNames.PSEUDONAME_ROOT;
    break;
  case DTMFilter.SHOW_ELEMENT :
    if (this.WILD == m_name)
      m_targetString = PsuedoNames.PSEUDONAME_ANY;
    else
      m_targetString = m_name;
    break;
  default :
    m_targetString = PsuedoNames.PSEUDONAME_ANY;
    break;
  }
}
 
Example #24
Source File: DescendantIterator.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a DescendantIterator object.
 *
 */
public DescendantIterator()
{
  super(null);
  m_axis = Axis.DESCENDANTSORSELFFROMROOT;
  int whatToShow = DTMFilter.SHOW_ALL;
  initNodeTest(whatToShow);
}
 
Example #25
Source File: OneStepIteratorForward.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a OneStepIterator object that will just traverse the self axes.
 *
 * @param axis One of the com.sun.org.apache.xml.internal.dtm.Axis integers.
 *
 * @throws javax.xml.transform.TransformerException
 */
public OneStepIteratorForward(int axis)
{
  super(null);

  m_axis = axis;
  int whatToShow = DTMFilter.SHOW_ALL;
  initNodeTest(whatToShow);
}
 
Example #26
Source File: ContextMatchStepPattern.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Construct a ContextMatchStepPattern.
 *
 */
public ContextMatchStepPattern(int axis, int paxis)
{
  super(DTMFilter.SHOW_ALL, axis, paxis);
}
 
Example #27
Source File: NodeTest.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Tell what the test score is for the given node.
 *
 *
 * @param xctxt XPath runtime context.
 * @param context The node being tested.
 *
 * @return {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NODETEST},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NONE},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_NSWILD},
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_QNAME}, or
 *         {@link com.sun.org.apache.xpath.internal.patterns.NodeTest#SCORE_OTHER}.
 *
 * @throws javax.xml.transform.TransformerException
 */
public XObject execute(XPathContext xctxt, int context,
                       DTM dtm, int expType)
        throws javax.xml.transform.TransformerException
{

  if (m_whatToShow == DTMFilter.SHOW_ALL)
    return m_score;

  int nodeBit = (m_whatToShow & (0x00000001
                 << ((dtm.getNodeType(context)) - 1)));

  switch (nodeBit)
  {
  case DTMFilter.SHOW_DOCUMENT_FRAGMENT :
  case DTMFilter.SHOW_DOCUMENT :
    return SCORE_OTHER;
  case DTMFilter.SHOW_COMMENT :
    return m_score;
  case DTMFilter.SHOW_CDATA_SECTION :
  case DTMFilter.SHOW_TEXT :

    // was:
    // return (!xctxt.getDOMHelper().shouldStripSourceNode(context))
    //       ? m_score : SCORE_NONE;
    return m_score;
  case DTMFilter.SHOW_PROCESSING_INSTRUCTION :
    return subPartMatch(dtm.getNodeName(context), m_name)
           ? m_score : SCORE_NONE;

  // From the draft: "Two expanded names are equal if they
  // have the same local part, and either both have no URI or
  // both have the same URI."
  // "A node test * is true for any node of the principal node type.
  // For example, child::* will select all element children of the
  // context node, and attribute::* will select all attributes of
  // the context node."
  // "A node test can have the form NCName:*. In this case, the prefix
  // is expanded in the same way as with a QName using the context
  // namespace declarations. The node test will be true for any node
  // of the principal type whose expanded name has the URI to which
  // the prefix expands, regardless of the local part of the name."
  case DTMFilter.SHOW_NAMESPACE :
  {
    String ns = dtm.getLocalName(context);

    return (subPartMatch(ns, m_name)) ? m_score : SCORE_NONE;
  }
  case DTMFilter.SHOW_ATTRIBUTE :
  case DTMFilter.SHOW_ELEMENT :
  {
    return (m_isTotallyWild || (subPartMatchNS(dtm.getNamespaceURI(context), m_namespace) && subPartMatch(dtm.getLocalName(context), m_name)))
           ? m_score : SCORE_NONE;
  }
  default :
    return SCORE_NONE;
  }  // end switch(testType)
}
 
Example #28
Source File: Compiler.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
   * Get a {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what
   * to show for a given node test.
   *
   * @param opPos the op map position for the location step.
   *
   * @return {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what
   *         to show for a given node test.
   */
  public int getWhatToShow(int opPos)
  {

    int axesType = getOp(opPos);
    int testType = getOp(opPos + 3);

    // System.out.println("testType: "+testType);
    switch (testType)
    {
    case OpCodes.NODETYPE_COMMENT :
      return DTMFilter.SHOW_COMMENT;
    case OpCodes.NODETYPE_TEXT :
//      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_COMMENT;
      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION ;
    case OpCodes.NODETYPE_PI :
      return DTMFilter.SHOW_PROCESSING_INSTRUCTION;
    case OpCodes.NODETYPE_NODE :
//      return DTMFilter.SHOW_ALL;
      switch (axesType)
      {
      case OpCodes.FROM_NAMESPACE:
        return DTMFilter.SHOW_NAMESPACE;
      case OpCodes.FROM_ATTRIBUTES :
      case OpCodes.MATCH_ATTRIBUTE :
        return DTMFilter.SHOW_ATTRIBUTE;
      case OpCodes.FROM_SELF:
      case OpCodes.FROM_ANCESTORS_OR_SELF:
      case OpCodes.FROM_DESCENDANTS_OR_SELF:
        return DTMFilter.SHOW_ALL;
      default:
        if (getOp(0) == OpCodes.OP_MATCHPATTERN)
          return ~DTMFilter.SHOW_ATTRIBUTE
                  & ~DTMFilter.SHOW_DOCUMENT
                  & ~DTMFilter.SHOW_DOCUMENT_FRAGMENT;
        else
          return ~DTMFilter.SHOW_ATTRIBUTE;
      }
    case OpCodes.NODETYPE_ROOT :
      return DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT;
    case OpCodes.NODETYPE_FUNCTEST :
      return NodeTest.SHOW_BYFUNCTION;
    case OpCodes.NODENAME :
      switch (axesType)
      {
      case OpCodes.FROM_NAMESPACE :
        return DTMFilter.SHOW_NAMESPACE;
      case OpCodes.FROM_ATTRIBUTES :
      case OpCodes.MATCH_ATTRIBUTE :
        return DTMFilter.SHOW_ATTRIBUTE;

      // break;
      case OpCodes.MATCH_ANY_ANCESTOR :
      case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
        return DTMFilter.SHOW_ELEMENT;

      // break;
      default :
        return DTMFilter.SHOW_ELEMENT;
      }
    default :
      // System.err.println("We should never reach here.");
      return DTMFilter.SHOW_ALL;
    }
  }
 
Example #29
Source File: Compiler.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
   * Get a {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what
   * to show for a given node test.
   *
   * @param opPos the op map position for the location step.
   *
   * @return {@link org.w3c.dom.traversal.NodeFilter} bit set that tells what
   *         to show for a given node test.
   */
  public int getWhatToShow(int opPos)
  {

    int axesType = getOp(opPos);
    int testType = getOp(opPos + 3);

    // System.out.println("testType: "+testType);
    switch (testType)
    {
    case OpCodes.NODETYPE_COMMENT :
      return DTMFilter.SHOW_COMMENT;
    case OpCodes.NODETYPE_TEXT :
//      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_COMMENT;
      return DTMFilter.SHOW_TEXT | DTMFilter.SHOW_CDATA_SECTION ;
    case OpCodes.NODETYPE_PI :
      return DTMFilter.SHOW_PROCESSING_INSTRUCTION;
    case OpCodes.NODETYPE_NODE :
//      return DTMFilter.SHOW_ALL;
      switch (axesType)
      {
      case OpCodes.FROM_NAMESPACE:
        return DTMFilter.SHOW_NAMESPACE;
      case OpCodes.FROM_ATTRIBUTES :
      case OpCodes.MATCH_ATTRIBUTE :
        return DTMFilter.SHOW_ATTRIBUTE;
      case OpCodes.FROM_SELF:
      case OpCodes.FROM_ANCESTORS_OR_SELF:
      case OpCodes.FROM_DESCENDANTS_OR_SELF:
        return DTMFilter.SHOW_ALL;
      default:
        if (getOp(0) == OpCodes.OP_MATCHPATTERN)
          return ~DTMFilter.SHOW_ATTRIBUTE
                  & ~DTMFilter.SHOW_DOCUMENT
                  & ~DTMFilter.SHOW_DOCUMENT_FRAGMENT;
        else
          return ~DTMFilter.SHOW_ATTRIBUTE;
      }
    case OpCodes.NODETYPE_ROOT :
      return DTMFilter.SHOW_DOCUMENT | DTMFilter.SHOW_DOCUMENT_FRAGMENT;
    case OpCodes.NODETYPE_FUNCTEST :
      return NodeTest.SHOW_BYFUNCTION;
    case OpCodes.NODENAME :
      switch (axesType)
      {
      case OpCodes.FROM_NAMESPACE :
        return DTMFilter.SHOW_NAMESPACE;
      case OpCodes.FROM_ATTRIBUTES :
      case OpCodes.MATCH_ATTRIBUTE :
        return DTMFilter.SHOW_ATTRIBUTE;

      // break;
      case OpCodes.MATCH_ANY_ANCESTOR :
      case OpCodes.MATCH_IMMEDIATE_ANCESTOR :
        return DTMFilter.SHOW_ELEMENT;

      // break;
      default :
        return DTMFilter.SHOW_ELEMENT;
      }
    default :
      // System.err.println("We should never reach here.");
      return DTMFilter.SHOW_ALL;
    }
  }
 
Example #30
Source File: NodeTest.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Tell what node type to test, if not DTMFilter.SHOW_ALL.
 *
 * @param whatToShow Bit set defined mainly by
 *        {@link com.sun.org.apache.xml.internal.dtm.DTMFilter}.
 * @return the node type for the whatToShow.  Since whatToShow can specify
 *         multiple types, it will return the first bit tested that is on,
 *         so the caller of this function should take care that this is
 *         the function they really want to call.  If none of the known bits
 *         are set, this function will return zero.
 */
public static int getNodeTypeTest(int whatToShow)
{
  // %REVIEW% Is there a better way?
  if (0 != (whatToShow & DTMFilter.SHOW_ELEMENT))
    return DTM.ELEMENT_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_ATTRIBUTE))
    return DTM.ATTRIBUTE_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_TEXT))
    return DTM.TEXT_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT))
    return DTM.DOCUMENT_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_FRAGMENT))
    return DTM.DOCUMENT_FRAGMENT_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_NAMESPACE))
    return DTM.NAMESPACE_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_COMMENT))
    return DTM.COMMENT_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_PROCESSING_INSTRUCTION))
    return DTM.PROCESSING_INSTRUCTION_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_DOCUMENT_TYPE))
    return DTM.DOCUMENT_TYPE_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY))
    return DTM.ENTITY_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_ENTITY_REFERENCE))
    return DTM.ENTITY_REFERENCE_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_NOTATION))
    return DTM.NOTATION_NODE;

  if (0 != (whatToShow & DTMFilter.SHOW_CDATA_SECTION))
    return DTM.CDATA_SECTION_NODE;


  return 0;
}