Java Code Examples for com.sun.org.apache.xml.internal.dtm.Axis#DESCENDANTSFROMROOT

The following examples show how to use com.sun.org.apache.xml.internal.dtm.Axis#DESCENDANTSFROMROOT . 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: WalkingIteratorSorted.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Tell if the nodeset can be walked in doc order, via static analysis.
 *
 *
 * @return true if the nodeset can be walked in doc order, without sorting.
 */
boolean canBeWalkedInNaturalDocOrderStatic()
{

  if (null != m_firstWalker)
  {
    AxesWalker walker = m_firstWalker;
    int prevAxis = -1;
    boolean prevIsSimpleDownAxis = true;

    for(int i = 0; null != walker; i++)
    {
      int axis = walker.getAxis();

      if(walker.isDocOrdered())
      {
        boolean isSimpleDownAxis = ((axis == Axis.CHILD)
                                 || (axis == Axis.SELF)
                                 || (axis == Axis.ROOT));
        // Catching the filtered list here is only OK because
        // FilterExprWalker#isDocOrdered() did the right thing.
        if(isSimpleDownAxis || (axis == -1))
          walker = walker.getNextWalker();
        else
        {
          boolean isLastWalker = (null == walker.getNextWalker());
          if(isLastWalker)
          {
            if(walker.isDocOrdered() && (axis == Axis.DESCENDANT ||
               axis == Axis.DESCENDANTORSELF || axis == Axis.DESCENDANTSFROMROOT
               || axis == Axis.DESCENDANTSORSELFFROMROOT) || (axis == Axis.ATTRIBUTE))
              return true;
          }
          return false;
        }
      }
      else
        return false;
    }
    return true;
  }
  return false;
}
 
Example 2
Source File: WalkingIteratorSorted.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Tell if the nodeset can be walked in doc order, via static analysis.
 *
 *
 * @return true if the nodeset can be walked in doc order, without sorting.
 */
boolean canBeWalkedInNaturalDocOrderStatic()
{

  if (null != m_firstWalker)
  {
    AxesWalker walker = m_firstWalker;
    int prevAxis = -1;
    boolean prevIsSimpleDownAxis = true;

    for(int i = 0; null != walker; i++)
    {
      int axis = walker.getAxis();

      if(walker.isDocOrdered())
      {
        boolean isSimpleDownAxis = ((axis == Axis.CHILD)
                                 || (axis == Axis.SELF)
                                 || (axis == Axis.ROOT));
        // Catching the filtered list here is only OK because
        // FilterExprWalker#isDocOrdered() did the right thing.
        if(isSimpleDownAxis || (axis == -1))
          walker = walker.getNextWalker();
        else
        {
          boolean isLastWalker = (null == walker.getNextWalker());
          if(isLastWalker)
          {
            if(walker.isDocOrdered() && (axis == Axis.DESCENDANT ||
               axis == Axis.DESCENDANTORSELF || axis == Axis.DESCENDANTSFROMROOT
               || axis == Axis.DESCENDANTSORSELFFROMROOT) || (axis == Axis.ATTRIBUTE))
              return true;
          }
          return false;
        }
      }
      else
        return false;
    }
    return true;
  }
  return false;
}
 
Example 3
Source File: WalkerFactory.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
/**
 * Get a corresponding BIT_XXX from an axis.
 * @param axis One of Axis.ANCESTOR, etc.
 * @return One of BIT_ANCESTOR, etc.
 */
static public int getAnalysisBitFromAxes(int axis)
{
  switch (axis) // Generate new traverser
    {
    case Axis.ANCESTOR :
      return BIT_ANCESTOR;
    case Axis.ANCESTORORSELF :
      return BIT_ANCESTOR_OR_SELF;
    case Axis.ATTRIBUTE :
      return BIT_ATTRIBUTE;
    case Axis.CHILD :
      return BIT_CHILD;
    case Axis.DESCENDANT :
      return BIT_DESCENDANT;
    case Axis.DESCENDANTORSELF :
      return BIT_DESCENDANT_OR_SELF;
    case Axis.FOLLOWING :
      return BIT_FOLLOWING;
    case Axis.FOLLOWINGSIBLING :
      return BIT_FOLLOWING_SIBLING;
    case Axis.NAMESPACE :
    case Axis.NAMESPACEDECLS :
      return BIT_NAMESPACE;
    case Axis.PARENT :
      return BIT_PARENT;
    case Axis.PRECEDING :
      return BIT_PRECEDING;
    case Axis.PRECEDINGSIBLING :
      return BIT_PRECEDING_SIBLING;
    case Axis.SELF :
      return BIT_SELF;
    case Axis.ALLFROMNODE :
      return BIT_DESCENDANT_OR_SELF;
      // case Axis.PRECEDINGANDANCESTOR :
    case Axis.DESCENDANTSFROMROOT :
    case Axis.ALL :
    case Axis.DESCENDANTSORSELFFROMROOT :
      return BIT_ANY_DESCENDANT_FROM_ROOT;
    case Axis.ROOT :
      return BIT_ROOT;
    case Axis.FILTEREDLIST :
      return BIT_FILTER;
    default :
      return BIT_FILTER;
  }
}
 
Example 4
Source File: WalkerFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get a corresponding BIT_XXX from an axis.
 * @param axis One of Axis.ANCESTOR, etc.
 * @return One of BIT_ANCESTOR, etc.
 */
static public int getAnalysisBitFromAxes(int axis)
{
  switch (axis) // Generate new traverser
    {
    case Axis.ANCESTOR :
      return BIT_ANCESTOR;
    case Axis.ANCESTORORSELF :
      return BIT_ANCESTOR_OR_SELF;
    case Axis.ATTRIBUTE :
      return BIT_ATTRIBUTE;
    case Axis.CHILD :
      return BIT_CHILD;
    case Axis.DESCENDANT :
      return BIT_DESCENDANT;
    case Axis.DESCENDANTORSELF :
      return BIT_DESCENDANT_OR_SELF;
    case Axis.FOLLOWING :
      return BIT_FOLLOWING;
    case Axis.FOLLOWINGSIBLING :
      return BIT_FOLLOWING_SIBLING;
    case Axis.NAMESPACE :
    case Axis.NAMESPACEDECLS :
      return BIT_NAMESPACE;
    case Axis.PARENT :
      return BIT_PARENT;
    case Axis.PRECEDING :
      return BIT_PRECEDING;
    case Axis.PRECEDINGSIBLING :
      return BIT_PRECEDING_SIBLING;
    case Axis.SELF :
      return BIT_SELF;
    case Axis.ALLFROMNODE :
      return BIT_DESCENDANT_OR_SELF;
      // case Axis.PRECEDINGANDANCESTOR :
    case Axis.DESCENDANTSFROMROOT :
    case Axis.ALL :
    case Axis.DESCENDANTSORSELFFROMROOT :
      return BIT_ANY_DESCENDANT_FROM_ROOT;
    case Axis.ROOT :
      return BIT_ROOT;
    case Axis.FILTEREDLIST :
      return BIT_FILTER;
    default :
      return BIT_FILTER;
  }
}
 
Example 5
Source File: MatchPatternIterator.java    From openjdk-8 with GNU General Public License v2.0 4 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.
 * @param analysis Analysis bits that give general information about the
 * LocationPath.
 *
 * @throws javax.xml.transform.TransformerException
 */
MatchPatternIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{

  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_pattern = WalkerFactory.loadSteps(this, compiler, firstStepPos, 0);

  boolean fromRoot = false;
  boolean walkBack = false;
  boolean walkDescendants = false;
  boolean walkAttributes = false;

  if (0 != (analysis & (WalkerFactory.BIT_ROOT |
                        WalkerFactory.BIT_ANY_DESCENDANT_FROM_ROOT)))
    fromRoot = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_ANCESTOR
               | WalkerFactory.BIT_ANCESTOR_OR_SELF
               | WalkerFactory.BIT_PRECEDING
               | WalkerFactory.BIT_PRECEDING_SIBLING
               | WalkerFactory.BIT_FOLLOWING
               | WalkerFactory.BIT_FOLLOWING_SIBLING
               | WalkerFactory.BIT_PARENT | WalkerFactory.BIT_FILTER)))
    walkBack = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_DESCENDANT_OR_SELF
               | WalkerFactory.BIT_DESCENDANT
               | WalkerFactory.BIT_CHILD)))
    walkDescendants = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_ATTRIBUTE | WalkerFactory.BIT_NAMESPACE)))
    walkAttributes = true;

  if(false || DEBUG)
  {
    System.out.print("analysis: "+Integer.toBinaryString(analysis));
    System.out.println(", "+WalkerFactory.getAnalysisString(analysis));
  }

  if(fromRoot || walkBack)
  {
    if(walkAttributes)
    {
      m_superAxis = Axis.ALL;
    }
    else
    {
      m_superAxis = Axis.DESCENDANTSFROMROOT;
    }
  }
  else if(walkDescendants)
  {
    if(walkAttributes)
    {
      m_superAxis = Axis.ALLFROMNODE;
    }
    else
    {
      m_superAxis = Axis.DESCENDANTORSELF;
    }
  }
  else
  {
    m_superAxis = Axis.ALL;
  }
  if(false || DEBUG)
  {
    System.out.println("axis: "+Axis.getNames(m_superAxis));
  }

}
 
Example 6
Source File: MatchPatternIterator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 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.
 * @param analysis Analysis bits that give general information about the
 * LocationPath.
 *
 * @throws javax.xml.transform.TransformerException
 */
MatchPatternIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{

  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_pattern = WalkerFactory.loadSteps(this, compiler, firstStepPos, 0);

  boolean fromRoot = false;
  boolean walkBack = false;
  boolean walkDescendants = false;
  boolean walkAttributes = false;

  if (0 != (analysis & (WalkerFactory.BIT_ROOT |
                        WalkerFactory.BIT_ANY_DESCENDANT_FROM_ROOT)))
    fromRoot = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_ANCESTOR
               | WalkerFactory.BIT_ANCESTOR_OR_SELF
               | WalkerFactory.BIT_PRECEDING
               | WalkerFactory.BIT_PRECEDING_SIBLING
               | WalkerFactory.BIT_FOLLOWING
               | WalkerFactory.BIT_FOLLOWING_SIBLING
               | WalkerFactory.BIT_PARENT | WalkerFactory.BIT_FILTER)))
    walkBack = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_DESCENDANT_OR_SELF
               | WalkerFactory.BIT_DESCENDANT
               | WalkerFactory.BIT_CHILD)))
    walkDescendants = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_ATTRIBUTE | WalkerFactory.BIT_NAMESPACE)))
    walkAttributes = true;

  if(false || DEBUG)
  {
    System.out.print("analysis: "+Integer.toBinaryString(analysis));
    System.out.println(", "+WalkerFactory.getAnalysisString(analysis));
  }

  if(fromRoot || walkBack)
  {
    if(walkAttributes)
    {
      m_superAxis = Axis.ALL;
    }
    else
    {
      m_superAxis = Axis.DESCENDANTSFROMROOT;
    }
  }
  else if(walkDescendants)
  {
    if(walkAttributes)
    {
      m_superAxis = Axis.ALLFROMNODE;
    }
    else
    {
      m_superAxis = Axis.DESCENDANTORSELF;
    }
  }
  else
  {
    m_superAxis = Axis.ALL;
  }
  if(false || DEBUG)
  {
    System.out.println("axis: "+Axis.getNames(m_superAxis));
  }

}
 
Example 7
Source File: WalkerFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get a corresponding BIT_XXX from an axis.
 * @param axis One of Axis.ANCESTOR, etc.
 * @return One of BIT_ANCESTOR, etc.
 */
static public int getAnalysisBitFromAxes(int axis)
{
  switch (axis) // Generate new traverser
    {
    case Axis.ANCESTOR :
      return BIT_ANCESTOR;
    case Axis.ANCESTORORSELF :
      return BIT_ANCESTOR_OR_SELF;
    case Axis.ATTRIBUTE :
      return BIT_ATTRIBUTE;
    case Axis.CHILD :
      return BIT_CHILD;
    case Axis.DESCENDANT :
      return BIT_DESCENDANT;
    case Axis.DESCENDANTORSELF :
      return BIT_DESCENDANT_OR_SELF;
    case Axis.FOLLOWING :
      return BIT_FOLLOWING;
    case Axis.FOLLOWINGSIBLING :
      return BIT_FOLLOWING_SIBLING;
    case Axis.NAMESPACE :
    case Axis.NAMESPACEDECLS :
      return BIT_NAMESPACE;
    case Axis.PARENT :
      return BIT_PARENT;
    case Axis.PRECEDING :
      return BIT_PRECEDING;
    case Axis.PRECEDINGSIBLING :
      return BIT_PRECEDING_SIBLING;
    case Axis.SELF :
      return BIT_SELF;
    case Axis.ALLFROMNODE :
      return BIT_DESCENDANT_OR_SELF;
      // case Axis.PRECEDINGANDANCESTOR :
    case Axis.DESCENDANTSFROMROOT :
    case Axis.ALL :
    case Axis.DESCENDANTSORSELFFROMROOT :
      return BIT_ANY_DESCENDANT_FROM_ROOT;
    case Axis.ROOT :
      return BIT_ROOT;
    case Axis.FILTEREDLIST :
      return BIT_FILTER;
    default :
      return BIT_FILTER;
  }
}
 
Example 8
Source File: WalkingIteratorSorted.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tell if the nodeset can be walked in doc order, via static analysis.
 *
 *
 * @return true if the nodeset can be walked in doc order, without sorting.
 */
boolean canBeWalkedInNaturalDocOrderStatic()
{

  if (null != m_firstWalker)
  {
    AxesWalker walker = m_firstWalker;
    int prevAxis = -1;
    boolean prevIsSimpleDownAxis = true;

    for(int i = 0; null != walker; i++)
    {
      int axis = walker.getAxis();

      if(walker.isDocOrdered())
      {
        boolean isSimpleDownAxis = ((axis == Axis.CHILD)
                                 || (axis == Axis.SELF)
                                 || (axis == Axis.ROOT));
        // Catching the filtered list here is only OK because
        // FilterExprWalker#isDocOrdered() did the right thing.
        if(isSimpleDownAxis || (axis == -1))
          walker = walker.getNextWalker();
        else
        {
          boolean isLastWalker = (null == walker.getNextWalker());
          if(isLastWalker)
          {
            if(walker.isDocOrdered() && (axis == Axis.DESCENDANT ||
               axis == Axis.DESCENDANTORSELF || axis == Axis.DESCENDANTSFROMROOT
               || axis == Axis.DESCENDANTSORSELFFROMROOT) || (axis == Axis.ATTRIBUTE))
              return true;
          }
          return false;
        }
      }
      else
        return false;
    }
    return true;
  }
  return false;
}
 
Example 9
Source File: WalkingIteratorSorted.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tell if the nodeset can be walked in doc order, via static analysis.
 *
 *
 * @return true if the nodeset can be walked in doc order, without sorting.
 */
boolean canBeWalkedInNaturalDocOrderStatic()
{

  if (null != m_firstWalker)
  {
    AxesWalker walker = m_firstWalker;
    int prevAxis = -1;
    boolean prevIsSimpleDownAxis = true;

    for(int i = 0; null != walker; i++)
    {
      int axis = walker.getAxis();

      if(walker.isDocOrdered())
      {
        boolean isSimpleDownAxis = ((axis == Axis.CHILD)
                                 || (axis == Axis.SELF)
                                 || (axis == Axis.ROOT));
        // Catching the filtered list here is only OK because
        // FilterExprWalker#isDocOrdered() did the right thing.
        if(isSimpleDownAxis || (axis == -1))
          walker = walker.getNextWalker();
        else
        {
          boolean isLastWalker = (null == walker.getNextWalker());
          if(isLastWalker)
          {
            if(walker.isDocOrdered() && (axis == Axis.DESCENDANT ||
               axis == Axis.DESCENDANTORSELF || axis == Axis.DESCENDANTSFROMROOT
               || axis == Axis.DESCENDANTSORSELFFROMROOT) || (axis == Axis.ATTRIBUTE))
              return true;
          }
          return false;
        }
      }
      else
        return false;
    }
    return true;
  }
  return false;
}
 
Example 10
Source File: WalkerFactory.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Get a corresponding BIT_XXX from an axis.
 * @param axis One of Axis.ANCESTOR, etc.
 * @return One of BIT_ANCESTOR, etc.
 */
static public int getAnalysisBitFromAxes(int axis)
{
  switch (axis) // Generate new traverser
    {
    case Axis.ANCESTOR :
      return BIT_ANCESTOR;
    case Axis.ANCESTORORSELF :
      return BIT_ANCESTOR_OR_SELF;
    case Axis.ATTRIBUTE :
      return BIT_ATTRIBUTE;
    case Axis.CHILD :
      return BIT_CHILD;
    case Axis.DESCENDANT :
      return BIT_DESCENDANT;
    case Axis.DESCENDANTORSELF :
      return BIT_DESCENDANT_OR_SELF;
    case Axis.FOLLOWING :
      return BIT_FOLLOWING;
    case Axis.FOLLOWINGSIBLING :
      return BIT_FOLLOWING_SIBLING;
    case Axis.NAMESPACE :
    case Axis.NAMESPACEDECLS :
      return BIT_NAMESPACE;
    case Axis.PARENT :
      return BIT_PARENT;
    case Axis.PRECEDING :
      return BIT_PRECEDING;
    case Axis.PRECEDINGSIBLING :
      return BIT_PRECEDING_SIBLING;
    case Axis.SELF :
      return BIT_SELF;
    case Axis.ALLFROMNODE :
      return BIT_DESCENDANT_OR_SELF;
      // case Axis.PRECEDINGANDANCESTOR :
    case Axis.DESCENDANTSFROMROOT :
    case Axis.ALL :
    case Axis.DESCENDANTSORSELFFROMROOT :
      return BIT_ANY_DESCENDANT_FROM_ROOT;
    case Axis.ROOT :
      return BIT_ROOT;
    case Axis.FILTEREDLIST :
      return BIT_FILTER;
    default :
      return BIT_FILTER;
  }
}
 
Example 11
Source File: WalkerFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get a corresponding BIT_XXX from an axis.
 * @param axis One of Axis.ANCESTOR, etc.
 * @return One of BIT_ANCESTOR, etc.
 */
static public int getAnalysisBitFromAxes(int axis)
{
  switch (axis) // Generate new traverser
    {
    case Axis.ANCESTOR :
      return BIT_ANCESTOR;
    case Axis.ANCESTORORSELF :
      return BIT_ANCESTOR_OR_SELF;
    case Axis.ATTRIBUTE :
      return BIT_ATTRIBUTE;
    case Axis.CHILD :
      return BIT_CHILD;
    case Axis.DESCENDANT :
      return BIT_DESCENDANT;
    case Axis.DESCENDANTORSELF :
      return BIT_DESCENDANT_OR_SELF;
    case Axis.FOLLOWING :
      return BIT_FOLLOWING;
    case Axis.FOLLOWINGSIBLING :
      return BIT_FOLLOWING_SIBLING;
    case Axis.NAMESPACE :
    case Axis.NAMESPACEDECLS :
      return BIT_NAMESPACE;
    case Axis.PARENT :
      return BIT_PARENT;
    case Axis.PRECEDING :
      return BIT_PRECEDING;
    case Axis.PRECEDINGSIBLING :
      return BIT_PRECEDING_SIBLING;
    case Axis.SELF :
      return BIT_SELF;
    case Axis.ALLFROMNODE :
      return BIT_DESCENDANT_OR_SELF;
      // case Axis.PRECEDINGANDANCESTOR :
    case Axis.DESCENDANTSFROMROOT :
    case Axis.ALL :
    case Axis.DESCENDANTSORSELFFROMROOT :
      return BIT_ANY_DESCENDANT_FROM_ROOT;
    case Axis.ROOT :
      return BIT_ROOT;
    case Axis.FILTEREDLIST :
      return BIT_FILTER;
    default :
      return BIT_FILTER;
  }
}
 
Example 12
Source File: MatchPatternIterator.java    From JDKSourceCode1.8 with MIT License 4 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.
 * @param analysis Analysis bits that give general information about the
 * LocationPath.
 *
 * @throws javax.xml.transform.TransformerException
 */
MatchPatternIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{

  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_pattern = WalkerFactory.loadSteps(this, compiler, firstStepPos, 0);

  boolean fromRoot = false;
  boolean walkBack = false;
  boolean walkDescendants = false;
  boolean walkAttributes = false;

  if (0 != (analysis & (WalkerFactory.BIT_ROOT |
                        WalkerFactory.BIT_ANY_DESCENDANT_FROM_ROOT)))
    fromRoot = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_ANCESTOR
               | WalkerFactory.BIT_ANCESTOR_OR_SELF
               | WalkerFactory.BIT_PRECEDING
               | WalkerFactory.BIT_PRECEDING_SIBLING
               | WalkerFactory.BIT_FOLLOWING
               | WalkerFactory.BIT_FOLLOWING_SIBLING
               | WalkerFactory.BIT_PARENT | WalkerFactory.BIT_FILTER)))
    walkBack = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_DESCENDANT_OR_SELF
               | WalkerFactory.BIT_DESCENDANT
               | WalkerFactory.BIT_CHILD)))
    walkDescendants = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_ATTRIBUTE | WalkerFactory.BIT_NAMESPACE)))
    walkAttributes = true;

  if(false || DEBUG)
  {
    System.out.print("analysis: "+Integer.toBinaryString(analysis));
    System.out.println(", "+WalkerFactory.getAnalysisString(analysis));
  }

  if(fromRoot || walkBack)
  {
    if(walkAttributes)
    {
      m_superAxis = Axis.ALL;
    }
    else
    {
      m_superAxis = Axis.DESCENDANTSFROMROOT;
    }
  }
  else if(walkDescendants)
  {
    if(walkAttributes)
    {
      m_superAxis = Axis.ALLFROMNODE;
    }
    else
    {
      m_superAxis = Axis.DESCENDANTORSELF;
    }
  }
  else
  {
    m_superAxis = Axis.ALL;
  }
  if(false || DEBUG)
  {
    System.out.println("axis: "+Axis.getNames(m_superAxis));
  }

}
 
Example 13
Source File: MatchPatternIterator.java    From openjdk-8-source with GNU General Public License v2.0 4 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.
 * @param analysis Analysis bits that give general information about the
 * LocationPath.
 *
 * @throws javax.xml.transform.TransformerException
 */
MatchPatternIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{

  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_pattern = WalkerFactory.loadSteps(this, compiler, firstStepPos, 0);

  boolean fromRoot = false;
  boolean walkBack = false;
  boolean walkDescendants = false;
  boolean walkAttributes = false;

  if (0 != (analysis & (WalkerFactory.BIT_ROOT |
                        WalkerFactory.BIT_ANY_DESCENDANT_FROM_ROOT)))
    fromRoot = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_ANCESTOR
               | WalkerFactory.BIT_ANCESTOR_OR_SELF
               | WalkerFactory.BIT_PRECEDING
               | WalkerFactory.BIT_PRECEDING_SIBLING
               | WalkerFactory.BIT_FOLLOWING
               | WalkerFactory.BIT_FOLLOWING_SIBLING
               | WalkerFactory.BIT_PARENT | WalkerFactory.BIT_FILTER)))
    walkBack = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_DESCENDANT_OR_SELF
               | WalkerFactory.BIT_DESCENDANT
               | WalkerFactory.BIT_CHILD)))
    walkDescendants = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_ATTRIBUTE | WalkerFactory.BIT_NAMESPACE)))
    walkAttributes = true;

  if(false || DEBUG)
  {
    System.out.print("analysis: "+Integer.toBinaryString(analysis));
    System.out.println(", "+WalkerFactory.getAnalysisString(analysis));
  }

  if(fromRoot || walkBack)
  {
    if(walkAttributes)
    {
      m_superAxis = Axis.ALL;
    }
    else
    {
      m_superAxis = Axis.DESCENDANTSFROMROOT;
    }
  }
  else if(walkDescendants)
  {
    if(walkAttributes)
    {
      m_superAxis = Axis.ALLFROMNODE;
    }
    else
    {
      m_superAxis = Axis.DESCENDANTORSELF;
    }
  }
  else
  {
    m_superAxis = Axis.ALL;
  }
  if(false || DEBUG)
  {
    System.out.println("axis: "+Axis.getNames(m_superAxis));
  }

}
 
Example 14
Source File: WalkingIteratorSorted.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tell if the nodeset can be walked in doc order, via static analysis.
 *
 *
 * @return true if the nodeset can be walked in doc order, without sorting.
 */
boolean canBeWalkedInNaturalDocOrderStatic()
{

  if (null != m_firstWalker)
  {
    AxesWalker walker = m_firstWalker;
    int prevAxis = -1;
    boolean prevIsSimpleDownAxis = true;

    for(int i = 0; null != walker; i++)
    {
      int axis = walker.getAxis();

      if(walker.isDocOrdered())
      {
        boolean isSimpleDownAxis = ((axis == Axis.CHILD)
                                 || (axis == Axis.SELF)
                                 || (axis == Axis.ROOT));
        // Catching the filtered list here is only OK because
        // FilterExprWalker#isDocOrdered() did the right thing.
        if(isSimpleDownAxis || (axis == -1))
          walker = walker.getNextWalker();
        else
        {
          boolean isLastWalker = (null == walker.getNextWalker());
          if(isLastWalker)
          {
            if(walker.isDocOrdered() && (axis == Axis.DESCENDANT ||
               axis == Axis.DESCENDANTORSELF || axis == Axis.DESCENDANTSFROMROOT
               || axis == Axis.DESCENDANTSORSELFFROMROOT) || (axis == Axis.ATTRIBUTE))
              return true;
          }
          return false;
        }
      }
      else
        return false;
    }
    return true;
  }
  return false;
}
 
Example 15
Source File: MatchPatternIterator.java    From jdk8u60 with GNU General Public License v2.0 4 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.
 * @param analysis Analysis bits that give general information about the
 * LocationPath.
 *
 * @throws javax.xml.transform.TransformerException
 */
MatchPatternIterator(Compiler compiler, int opPos, int analysis)
        throws javax.xml.transform.TransformerException
{

  super(compiler, opPos, analysis, false);

  int firstStepPos = OpMap.getFirstChildPos(opPos);

  m_pattern = WalkerFactory.loadSteps(this, compiler, firstStepPos, 0);

  boolean fromRoot = false;
  boolean walkBack = false;
  boolean walkDescendants = false;
  boolean walkAttributes = false;

  if (0 != (analysis & (WalkerFactory.BIT_ROOT |
                        WalkerFactory.BIT_ANY_DESCENDANT_FROM_ROOT)))
    fromRoot = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_ANCESTOR
               | WalkerFactory.BIT_ANCESTOR_OR_SELF
               | WalkerFactory.BIT_PRECEDING
               | WalkerFactory.BIT_PRECEDING_SIBLING
               | WalkerFactory.BIT_FOLLOWING
               | WalkerFactory.BIT_FOLLOWING_SIBLING
               | WalkerFactory.BIT_PARENT | WalkerFactory.BIT_FILTER)))
    walkBack = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_DESCENDANT_OR_SELF
               | WalkerFactory.BIT_DESCENDANT
               | WalkerFactory.BIT_CHILD)))
    walkDescendants = true;

  if (0 != (analysis
            & (WalkerFactory.BIT_ATTRIBUTE | WalkerFactory.BIT_NAMESPACE)))
    walkAttributes = true;

  if(false || DEBUG)
  {
    System.out.print("analysis: "+Integer.toBinaryString(analysis));
    System.out.println(", "+WalkerFactory.getAnalysisString(analysis));
  }

  if(fromRoot || walkBack)
  {
    if(walkAttributes)
    {
      m_superAxis = Axis.ALL;
    }
    else
    {
      m_superAxis = Axis.DESCENDANTSFROMROOT;
    }
  }
  else if(walkDescendants)
  {
    if(walkAttributes)
    {
      m_superAxis = Axis.ALLFROMNODE;
    }
    else
    {
      m_superAxis = Axis.DESCENDANTORSELF;
    }
  }
  else
  {
    m_superAxis = Axis.ALL;
  }
  if(false || DEBUG)
  {
    System.out.println("axis: "+Axis.getNames(m_superAxis));
  }

}
 
Example 16
Source File: WalkerFactory.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get a corresponding BIT_XXX from an axis.
 * @param axis One of Axis.ANCESTOR, etc.
 * @return One of BIT_ANCESTOR, etc.
 */
static public int getAnalysisBitFromAxes(int axis)
{
  switch (axis) // Generate new traverser
    {
    case Axis.ANCESTOR :
      return BIT_ANCESTOR;
    case Axis.ANCESTORORSELF :
      return BIT_ANCESTOR_OR_SELF;
    case Axis.ATTRIBUTE :
      return BIT_ATTRIBUTE;
    case Axis.CHILD :
      return BIT_CHILD;
    case Axis.DESCENDANT :
      return BIT_DESCENDANT;
    case Axis.DESCENDANTORSELF :
      return BIT_DESCENDANT_OR_SELF;
    case Axis.FOLLOWING :
      return BIT_FOLLOWING;
    case Axis.FOLLOWINGSIBLING :
      return BIT_FOLLOWING_SIBLING;
    case Axis.NAMESPACE :
    case Axis.NAMESPACEDECLS :
      return BIT_NAMESPACE;
    case Axis.PARENT :
      return BIT_PARENT;
    case Axis.PRECEDING :
      return BIT_PRECEDING;
    case Axis.PRECEDINGSIBLING :
      return BIT_PRECEDING_SIBLING;
    case Axis.SELF :
      return BIT_SELF;
    case Axis.ALLFROMNODE :
      return BIT_DESCENDANT_OR_SELF;
      // case Axis.PRECEDINGANDANCESTOR :
    case Axis.DESCENDANTSFROMROOT :
    case Axis.ALL :
    case Axis.DESCENDANTSORSELFFROMROOT :
      return BIT_ANY_DESCENDANT_FROM_ROOT;
    case Axis.ROOT :
      return BIT_ROOT;
    case Axis.FILTEREDLIST :
      return BIT_FILTER;
    default :
      return BIT_FILTER;
  }
}
 
Example 17
Source File: WalkingIteratorSorted.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Tell if the nodeset can be walked in doc order, via static analysis.
 *
 *
 * @return true if the nodeset can be walked in doc order, without sorting.
 */
boolean canBeWalkedInNaturalDocOrderStatic()
{

  if (null != m_firstWalker)
  {
    AxesWalker walker = m_firstWalker;
    int prevAxis = -1;
    boolean prevIsSimpleDownAxis = true;

    for(int i = 0; null != walker; i++)
    {
      int axis = walker.getAxis();

      if(walker.isDocOrdered())
      {
        boolean isSimpleDownAxis = ((axis == Axis.CHILD)
                                 || (axis == Axis.SELF)
                                 || (axis == Axis.ROOT));
        // Catching the filtered list here is only OK because
        // FilterExprWalker#isDocOrdered() did the right thing.
        if(isSimpleDownAxis || (axis == -1))
          walker = walker.getNextWalker();
        else
        {
          boolean isLastWalker = (null == walker.getNextWalker());
          if(isLastWalker)
          {
            if(walker.isDocOrdered() && (axis == Axis.DESCENDANT ||
               axis == Axis.DESCENDANTORSELF || axis == Axis.DESCENDANTSFROMROOT
               || axis == Axis.DESCENDANTSORSELFFROMROOT) || (axis == Axis.ATTRIBUTE))
              return true;
          }
          return false;
        }
      }
      else
        return false;
    }
    return true;
  }
  return false;
}
 
Example 18
Source File: WalkerFactory.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get a corresponding BIT_XXX from an axis.
 * @param axis One of Axis.ANCESTOR, etc.
 * @return One of BIT_ANCESTOR, etc.
 */
static public int getAnalysisBitFromAxes(int axis)
{
  switch (axis) // Generate new traverser
    {
    case Axis.ANCESTOR :
      return BIT_ANCESTOR;
    case Axis.ANCESTORORSELF :
      return BIT_ANCESTOR_OR_SELF;
    case Axis.ATTRIBUTE :
      return BIT_ATTRIBUTE;
    case Axis.CHILD :
      return BIT_CHILD;
    case Axis.DESCENDANT :
      return BIT_DESCENDANT;
    case Axis.DESCENDANTORSELF :
      return BIT_DESCENDANT_OR_SELF;
    case Axis.FOLLOWING :
      return BIT_FOLLOWING;
    case Axis.FOLLOWINGSIBLING :
      return BIT_FOLLOWING_SIBLING;
    case Axis.NAMESPACE :
    case Axis.NAMESPACEDECLS :
      return BIT_NAMESPACE;
    case Axis.PARENT :
      return BIT_PARENT;
    case Axis.PRECEDING :
      return BIT_PRECEDING;
    case Axis.PRECEDINGSIBLING :
      return BIT_PRECEDING_SIBLING;
    case Axis.SELF :
      return BIT_SELF;
    case Axis.ALLFROMNODE :
      return BIT_DESCENDANT_OR_SELF;
      // case Axis.PRECEDINGANDANCESTOR :
    case Axis.DESCENDANTSFROMROOT :
    case Axis.ALL :
    case Axis.DESCENDANTSORSELFFROMROOT :
      return BIT_ANY_DESCENDANT_FROM_ROOT;
    case Axis.ROOT :
      return BIT_ROOT;
    case Axis.FILTEREDLIST :
      return BIT_FILTER;
    default :
      return BIT_FILTER;
  }
}
 
Example 19
Source File: WalkerFactory.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Get a corresponding BIT_XXX from an axis.
 * @param axis One of Axis.ANCESTOR, etc.
 * @return One of BIT_ANCESTOR, etc.
 */
static public int getAnalysisBitFromAxes(int axis)
{
  switch (axis) // Generate new traverser
    {
    case Axis.ANCESTOR :
      return BIT_ANCESTOR;
    case Axis.ANCESTORORSELF :
      return BIT_ANCESTOR_OR_SELF;
    case Axis.ATTRIBUTE :
      return BIT_ATTRIBUTE;
    case Axis.CHILD :
      return BIT_CHILD;
    case Axis.DESCENDANT :
      return BIT_DESCENDANT;
    case Axis.DESCENDANTORSELF :
      return BIT_DESCENDANT_OR_SELF;
    case Axis.FOLLOWING :
      return BIT_FOLLOWING;
    case Axis.FOLLOWINGSIBLING :
      return BIT_FOLLOWING_SIBLING;
    case Axis.NAMESPACE :
    case Axis.NAMESPACEDECLS :
      return BIT_NAMESPACE;
    case Axis.PARENT :
      return BIT_PARENT;
    case Axis.PRECEDING :
      return BIT_PRECEDING;
    case Axis.PRECEDINGSIBLING :
      return BIT_PRECEDING_SIBLING;
    case Axis.SELF :
      return BIT_SELF;
    case Axis.ALLFROMNODE :
      return BIT_DESCENDANT_OR_SELF;
      // case Axis.PRECEDINGANDANCESTOR :
    case Axis.DESCENDANTSFROMROOT :
    case Axis.ALL :
    case Axis.DESCENDANTSORSELFFROMROOT :
      return BIT_ANY_DESCENDANT_FROM_ROOT;
    case Axis.ROOT :
      return BIT_ROOT;
    case Axis.FILTEREDLIST :
      return BIT_FILTER;
    default :
      return BIT_FILTER;
  }
}
 
Example 20
Source File: WalkingIteratorSorted.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Tell if the nodeset can be walked in doc order, via static analysis.
 *
 *
 * @return true if the nodeset can be walked in doc order, without sorting.
 */
boolean canBeWalkedInNaturalDocOrderStatic()
{

  if (null != m_firstWalker)
  {
    AxesWalker walker = m_firstWalker;
    int prevAxis = -1;
    boolean prevIsSimpleDownAxis = true;

    for(int i = 0; null != walker; i++)
    {
      int axis = walker.getAxis();

      if(walker.isDocOrdered())
      {
        boolean isSimpleDownAxis = ((axis == Axis.CHILD)
                                 || (axis == Axis.SELF)
                                 || (axis == Axis.ROOT));
        // Catching the filtered list here is only OK because
        // FilterExprWalker#isDocOrdered() did the right thing.
        if(isSimpleDownAxis || (axis == -1))
          walker = walker.getNextWalker();
        else
        {
          boolean isLastWalker = (null == walker.getNextWalker());
          if(isLastWalker)
          {
            if(walker.isDocOrdered() && (axis == Axis.DESCENDANT ||
               axis == Axis.DESCENDANTORSELF || axis == Axis.DESCENDANTSFROMROOT
               || axis == Axis.DESCENDANTSORSELFFROMROOT) || (axis == Axis.ATTRIBUTE))
              return true;
          }
          return false;
        }
      }
      else
        return false;
    }
    return true;
  }
  return false;
}