1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /*
  17. * $Id: AttributeIterator.java,v 1.15 2004/02/17 04:32:08 minchau Exp $
  18. */
  19. package com.sun.org.apache.xpath.internal.axes;
  20. import com.sun.org.apache.xml.internal.dtm.DTM;
  21. import com.sun.org.apache.xpath.internal.compiler.Compiler;
  22. /**
  23. * This class implements an optimized iterator for
  24. * attribute axes patterns.
  25. * @see com.sun.org.apache.xpath.internal.axes#ChildTestIterator
  26. * @xsl.usage advanced
  27. */
  28. public class AttributeIterator extends ChildTestIterator
  29. {
  30. /**
  31. * Create a AttributeIterator object.
  32. *
  33. * @param compiler A reference to the Compiler that contains the op map.
  34. * @param opPos The position within the op map, which contains the
  35. * location path expression for this itterator.
  36. *
  37. * @throws javax.xml.transform.TransformerException
  38. */
  39. AttributeIterator(Compiler compiler, int opPos, int analysis)
  40. throws javax.xml.transform.TransformerException
  41. {
  42. super(compiler, opPos, analysis);
  43. }
  44. /**
  45. * Get the next node via getFirstAttribute && getNextAttribute.
  46. */
  47. protected int getNextNode()
  48. {
  49. m_lastFetched = (DTM.NULL == m_lastFetched)
  50. ? m_cdtm.getFirstAttribute(m_context)
  51. : m_cdtm.getNextAttribute(m_lastFetched);
  52. return m_lastFetched;
  53. }
  54. /**
  55. * Returns the axis being iterated, if it is known.
  56. *
  57. * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple
  58. * types.
  59. */
  60. public int getAxis()
  61. {
  62. return com.sun.org.apache.xml.internal.dtm.Axis.ATTRIBUTE;
  63. }
  64. }