FileDocCategorySizeDatePackage
XMLAttributesIteratorImpl.javaAPI DocJava SE 6 API3495Tue Jun 10 00:22:52 BST 2008com.sun.org.apache.xerces.internal.util

XMLAttributesIteratorImpl

public class XMLAttributesIteratorImpl extends XMLAttributesImpl implements Iterator
Its better to extend the functionality of existing XMLAttributesImpl and also make it of type Iterator. We can directly give an object of type iterator from StartElement event. We should also have Attribute object of type javax.xml.stream.Attribute internally. It would avoid the need of creating new javax.xml.stream.Attribute object at the later stage. Should we change XMLAttributes interface to implement Iteraotr ? I think its better avoid touching XNI as much as possible. - NB.

Fields Summary
protected int
fCurrent
protected XMLAttributesImpl$Attribute
fLastReturnedItem
Constructors Summary
public XMLAttributesIteratorImpl()
Creates a new instance of XMLAttributesIteratorImpl

    
           
      
    
Methods Summary
public booleanhasNext()

        return fCurrent < getLength() ? true : false ;
    
public java.lang.Objectnext()

        if(hasNext()){
            // should this be of type javax.xml.stream.Attribute ?
            return fLastReturnedItem = fAttributes[fCurrent++] ;
        }
        else{
            throw new NoSuchElementException() ;
        }
    
public voidremove()

        //make sure that only last returned item can be removed.
        if(fLastReturnedItem == fAttributes[fCurrent - 1]){
            //remove the attribute at current index and lower the current position by 1.
            removeAttributeAt(fCurrent--) ;
        }
        else {
            //either the next method has been called yet, or the remove method has already been called
            //after the last call to the next method.
            throw new IllegalStateException();
        }
    
public voidremoveAllAttributes()

        super.removeAllAttributes() ;
        fCurrent = 0 ;