public boolean hasNext() { if (_eof) return false; int len = _parent.get_child_count(); if (_next_idx > 0) { // first we have to verify the position of the // current value, since it might move if local // symbol tables get created. In which case it // will be moved down the list. int ii = _next_idx - 1; _next_idx = len; // if we can't find our current // value we'll be at eof anyway while (ii < len) { if (_curr == _parent.get_child(ii)) { _next_idx = ii + 1; break; } } } // if there anything left? if (_next_idx >= _parent.get_child_count()) { _eof = true; } return !_eof; }
public IonValue next() { // the hasNext() is needed to adjust our _next_idx // value if the underlying arraylist moved under us if (!hasNext()) { _curr = null; } else { _curr = _parent.get_child(_next_idx); _next_idx++; } return _curr; }
Children(IonContainer parent) { if (parent instanceof PrivateIonContainer) { _parent = (PrivateIonContainer) parent; _next_idx = 0; _curr = null; if (_parent.isNullValue()) { // otherwise the empty contents member will cause trouble _eof = true; } } else { throw new UnsupportedOperationException("this only supports IonContainerImpl instances"); } }