1 21 package org.jacorb.collection; 22 23 import org.omg.CosCollection.*; 24 import org.jacorb.collection.util.*; 25 import org.omg.PortableServer.POA ; 26 import org.omg.PortableServer.Servant ; 27 import org.omg.CORBA.Any ; 28 import org.omg.CORBA.AnyHolder ; 29 30 class SequentialCollectionImpl 31 extends OrderedCollectionImpl 32 implements SequentialCollectionOperations 33 { 34 35 SequentialCollectionImpl( OperationsOperations ops, POA poa, IteratorFactory iterator_factory ){ 36 super( ops, poa, iterator_factory ); 37 } 38 39 public synchronized void add_element_as_first(Any element) throws ElementInvalid{ 40 try { 41 add_element_at_position( 0, element ); 42 } catch ( PositionInvalid e ){ 43 throw new ElementInvalid( ElementInvalidReason.positioning_property_invalid ); 44 } 45 } 46 47 public synchronized void add_element_as_first_set_iterator(Any element, Iterator where) throws ElementInvalid,IteratorInvalid{ 48 PositionalIteratorImpl i = check_iterator( where ); 49 add_element_as_first( element ); 50 i.set_pos(0); 51 i.set_in_between(false); 52 } 53 54 public synchronized void add_element_as_last(Any element) throws ElementInvalid{ 55 int pos = data.size(); 56 try { 57 add_element_at_position(pos, element ); 58 } catch ( PositionInvalid e ){ 59 throw new ElementInvalid( ElementInvalidReason.positioning_property_invalid ); 60 } 61 } 62 63 public synchronized void add_element_as_last_set_iterator(Any element, Iterator where) throws ElementInvalid,IteratorInvalid{ 64 PositionalIteratorImpl i = check_iterator( where ); 65 add_element_as_last( element ); 66 i.set_pos(data.size()-1); 67 i.set_in_between(false); 68 } 69 70 public synchronized void add_element_as_next(Any element, Iterator where) throws ElementInvalid,IteratorInvalid{ 71 PositionalIteratorImpl i = check_iterator( where ); 72 int pos = i.get_pos(); 73 try { 74 add_element_at_position( pos+1, element ); 75 } catch ( PositionInvalid e ){ 76 throw new ElementInvalid( ElementInvalidReason.positioning_property_invalid ); 77 } 78 } 79 80 public synchronized void add_element_as_previous(Any element, Iterator where) throws ElementInvalid,IteratorInvalid{ 81 PositionalIteratorImpl i = check_iterator( where ); 82 int pos = i.get_pos(); 83 try { 84 add_element_at_position( pos, element ); 85 } catch ( PositionInvalid e ){ 86 throw new ElementInvalid( ElementInvalidReason.positioning_property_invalid ); 87 } 88 } 89 90 public synchronized void add_element_at_position(int position, Any element) throws PositionInvalid,ElementInvalid{ 91 check_element(element); 92 try { 93 if( data.insertElementAt( element, position ) ){ 94 element_inserted( position ); 95 } else { 96 throw new ElementInvalid( ElementInvalidReason.positioning_property_invalid ); 97 } 98 } catch ( ObjectInvalid e ){ 99 throw new ElementInvalid( ElementInvalidReason.element_type_invalid ); 100 } 101 } 102 103 public synchronized void add_element_at_position_set_iterator(int position, Any element, Iterator where) throws PositionInvalid,ElementInvalid,IteratorInvalid{ 104 PositionalIteratorImpl i = check_iterator( where ); 105 add_element_at_position( position, element ); 106 i.set_pos(position); 107 i.set_in_between(false); 108 } 109 110 public synchronized void replace_element_at_position( int position, Any element ) throws PositionInvalid,ElementInvalid{ 111 element_replace( position, element ); 112 } 113 114 public synchronized void replace_first_element(Any element) throws ElementInvalid,EmptyCollection{ 115 try { 116 replace_element_at_position( 0, element ); 117 } catch ( PositionInvalid e ){ 118 throw new ElementInvalid( ElementInvalidReason.positioning_property_invalid ); 119 } 120 } 121 122 public synchronized void replace_last_element(Any element) throws ElementInvalid,EmptyCollection { 123 if( data.size() == 0 ){ 124 throw new EmptyCollection(); 125 } 126 try { 127 replace_element_at_position( data.size()-1, element ); 128 } catch ( PositionInvalid e ){ 129 throw new ElementInvalid( ElementInvalidReason.positioning_property_invalid ); 130 } 131 } 132 133 public synchronized void sort(Comparator comparison){ 134 throw new org.omg.CORBA.NO_IMPLEMENT (); 135 } 136 137 public synchronized void reverse(){ 138 throw new org.omg.CORBA.NO_IMPLEMENT (); 139 } 140 141 142 } 143 144 145 146 147 148 149 | Popular Tags |