|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
package com.sun.org.apache.xerces.internal.util; |
|
|
|
import java.util.Iterator; |
|
import java.util.NoSuchElementException; |
|
|
|
/** |
|
* |
|
* @author Neeraj Bajaj, Sun Microsystems |
|
*/ |
|
|
|
/** |
|
* 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. |
|
*/ |
|
|
|
public class XMLAttributesIteratorImpl extends XMLAttributesImpl implements |
|
Iterator<XMLAttributesImpl.Attribute> { |
|
|
|
|
|
protected int fCurrent = 0 ; |
|
|
|
protected XMLAttributesImpl.Attribute fLastReturnedItem ; |
|
|
|
|
|
public XMLAttributesIteratorImpl() { |
|
} |
|
|
|
public boolean hasNext() { |
|
return fCurrent < getLength() ? true : false ; |
|
}//hasNext() |
|
|
|
public XMLAttributesImpl.Attribute next() { |
|
if(hasNext()){ |
|
|
|
return fLastReturnedItem = fAttributes[fCurrent++] ; |
|
} |
|
else{ |
|
throw new NoSuchElementException() ; |
|
} |
|
}//next |
|
|
|
public void remove() { |
|
|
|
if(fLastReturnedItem == fAttributes[fCurrent - 1]){ |
|
|
|
removeAttributeAt(fCurrent--) ; |
|
} |
|
else { |
|
//either the next method has been called yet, or the remove method has already been called |
|
|
|
throw new IllegalStateException(); |
|
} |
|
}//remove |
|
|
|
public void removeAllAttributes() { |
|
super.removeAllAttributes() ; |
|
fCurrent = 0 ; |
|
} |
|
/** xxx: should we be doing this way ? Attribute event defines so many functions which doesn't make any sense |
|
*for Attribute. |
|
* |
|
*/ |
|
/* |
|
class AttributeImpl extends com.sun.org.apache.xerces.internal.util.XMLAttributesImpl.Attribute implements javax.xml.stream.events.Attribute{ |
|
|
|
} |
|
*/ |
|
|
|
} //XMLAttributesIteratorImpl |