14c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/*
24c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one
34c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or more contributor license agreements. See the NOTICE file
44c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed with this work for additional information
54c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * regarding copyright ownership. The ASF licenses this file
64c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * to you under the Apache License, Version 2.0 (the  "License");
74c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * you may not use this file except in compliance with the License.
84c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * You may obtain a copy of the License at
94c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson *
104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson *     http://www.apache.org/licenses/LICENSE-2.0
114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson *
124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Unless required by applicable law or agreed to in writing, software
134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS,
144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * See the License for the specific language governing permissions and
164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * limitations under the License.
174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */
184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/*
194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * $Id: AttributeIterator.java 468655 2006-10-28 07:12:06Z minchau $
204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */
214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpackage org.apache.xpath.axes;
224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.apache.xml.dtm.DTM;
244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.apache.xpath.compiler.Compiler;
254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/**
274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * This class implements an optimized iterator for
284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * attribute axes patterns.
294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see org.apache.xpath.axes#ChildTestIterator
304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @xsl.usage advanced
314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */
324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpublic class AttributeIterator extends ChildTestIterator
334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson{
344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson    static final long serialVersionUID = -8417986700712229686L;
354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Create a AttributeIterator object.
384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   *
394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * @param compiler A reference to the Compiler that contains the op map.
404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * @param opPos The position within the op map, which contains the
414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * location path expression for this itterator.
424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   *
434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * @throws javax.xml.transform.TransformerException
444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  AttributeIterator(Compiler compiler, int opPos, int analysis)
464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson          throws javax.xml.transform.TransformerException
474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  {
484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson    super(compiler, opPos, analysis);
494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  }
504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Get the next node via getFirstAttribute && getNextAttribute.
534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  protected int getNextNode()
554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  {
564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson    m_lastFetched = (DTM.NULL == m_lastFetched)
574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson                     ? m_cdtm.getFirstAttribute(m_context)
584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson                     : m_cdtm.getNextAttribute(m_lastFetched);
594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson    return m_lastFetched;
604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  }
614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Returns the axis being iterated, if it is known.
644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   *
654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * @return Axis.CHILD, etc., or -1 if the axis is not known or is of multiple
664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * types.
674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public int getAxis()
694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  {
704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson    return org.apache.xml.dtm.Axis.ATTRIBUTE;
714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  }
724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson}
76