001: /*
002: * JacORB - a free Java ORB
003: *
004: * Copyright (C) 1999-2004 Gerald Brose
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Library General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Library General Public License for more details.
015: *
016: * You should have received a copy of the GNU Library General Public
017: * License along with this library; if not, write to the Free
018: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
019: *
020: */
021: package org.jacorb.collection;
022:
023: import org.omg.CosCollection.*;
024: import org.jacorb.collection.util.*;
025: import java.util.*;
026: import org.omg.PortableServer.POA;
027: import org.omg.PortableServer.Servant;
028: import org.omg.CORBA.Any;
029: import org.omg.CORBA.AnyHolder;
030: import org.omg.CORBA.BooleanHolder;
031:
032: class SequentialIteratorImpl extends OrderedIteratorImpl implements
033: SequentialIteratorOperations {
034:
035: /* ========================================================================= */
036: SequentialIteratorImpl(SequentialCollectionImpl collection) {
037: super (collection);
038: }
039:
040: /* ------------------------------------------------------------------------- */
041: SequentialIteratorImpl(SequentialCollectionImpl collection,
042: boolean read_only) {
043: super (collection, read_only);
044: }
045:
046: /* ------------------------------------------------------------------------- */
047: SequentialIteratorImpl(SequentialCollectionImpl collection,
048: boolean read_only, boolean reverse) {
049: super (collection, read_only, reverse);
050: }
051:
052: /* ========================================================================= */
053: public boolean add_element_as_next_set_iterator(Any element)
054: throws IteratorInvalid, ElementInvalid {
055: synchronized (collection) {
056: check_invalid();
057: try {
058: ((SequentialCollectionImpl) collection)
059: .add_element_at_position(get_pos() + 1, element);
060: set_to_position(get_pos() + 1);
061: } catch (PositionInvalid e) {
062: invalidate();
063: throw new IteratorInvalid(
064: IteratorInvalidReason.is_invalid);
065: }
066: return true;
067: }
068: }
069:
070: /* ------------------------------------------------------------------------- */
071: public void add_n_elements_as_next_set_iterator(Any[] elements)
072: throws IteratorInvalid, ElementInvalid {
073: throw new org.omg.CORBA.NO_IMPLEMENT();
074: // synchronized( collection ){
075: // }
076: }
077:
078: /* ------------------------------------------------------------------------- */
079: public boolean add_element_as_previous_set_iterator(Any element)
080: throws IteratorInvalid, ElementInvalid {
081: synchronized (collection) {
082: check_invalid();
083: try {
084: collection.element_replace(get_pos() - 1, element);
085: set_to_position(get_pos() - 1);
086: } catch (PositionInvalid e) {
087: invalidate();
088: throw new IteratorInvalid(
089: IteratorInvalidReason.is_invalid);
090: }
091: return true;
092: }
093: }
094:
095: /* ------------------------------------------------------------------------- */
096: public void add_n_elements_as_previous_set_iterator(Any[] elements)
097: throws IteratorInvalid, ElementInvalid {
098: throw new org.omg.CORBA.NO_IMPLEMENT();
099: // synchronized( collection ){
100: // }
101: }
102:
103: }
|