51 |
import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; |
import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; |
52 |
import org.omg.DynamicAny.DynEnum; |
import org.omg.DynamicAny.DynEnum; |
53 |
|
|
54 |
import java.io.*; |
import java.io.IOException; |
55 |
|
|
56 |
import java.util.Arrays; |
import java.util.Arrays; |
57 |
|
|
60 |
* |
* |
61 |
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) |
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) |
62 |
*/ |
*/ |
63 |
public class gnuDynEnum |
public class gnuDynEnum extends anyUndivideable implements DynEnum |
|
extends anyUndivideable |
|
|
implements DynEnum |
|
64 |
{ |
{ |
65 |
/** |
/** |
66 |
* Use serialVersionUID for interoperability. |
* Use serialVersionUID for interoperability. |
83 |
* Create a new dyn enum from the given typecode. |
* Create a new dyn enum from the given typecode. |
84 |
*/ |
*/ |
85 |
public gnuDynEnum(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory, |
public gnuDynEnum(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory, |
86 |
ORB anOrb |
ORB anOrb |
87 |
) |
) |
88 |
{ |
{ |
89 |
super(oType, aType, aFactory, anOrb); |
super(oType, aType, aFactory, anOrb); |
90 |
try |
try |
115 |
* Assign the Enum from the passed value. The passed DynAny must hold the |
* Assign the Enum from the passed value. The passed DynAny must hold the |
116 |
* enumeration of exactly the same final_type. |
* enumeration of exactly the same final_type. |
117 |
*/ |
*/ |
118 |
public void assign(DynAny from) |
public void assign(DynAny from) throws TypeMismatch |
|
throws TypeMismatch |
|
119 |
{ |
{ |
120 |
checkType(official_type, from.type()); |
checkType(official_type, from.type()); |
121 |
if (!(from instanceof DynEnum)) |
if (!(from instanceof DynEnum)) |
151 |
{ |
{ |
152 |
gnuDynEnum oe = (gnuDynEnum) other; |
gnuDynEnum oe = (gnuDynEnum) other; |
153 |
return current == oe.current && |
return current == oe.current && |
154 |
(oe.values == values || Arrays.equals(values, oe.values)); |
(oe.values == values || Arrays.equals(values, oe.values)); |
155 |
} |
} |
156 |
else if (other instanceof DynEnum) |
else if (other instanceof DynEnum) |
157 |
{ |
{ |
165 |
/** |
/** |
166 |
* Set value from any that must contain enumeration. |
* Set value from any that must contain enumeration. |
167 |
*/ |
*/ |
168 |
public void from_any(Any an_any) |
public void from_any(Any an_any) throws TypeMismatch, InvalidValue |
|
throws TypeMismatch, InvalidValue |
|
169 |
{ |
{ |
170 |
checkType(official_type, an_any.type()); |
checkType(official_type, an_any.type()); |
171 |
try |
try |
203 |
/** |
/** |
204 |
* Set the value of this enumeration as string. |
* Set the value of this enumeration as string. |
205 |
*/ |
*/ |
206 |
public void set_as_string(String value) |
public void set_as_string(String value) throws InvalidValue |
|
throws InvalidValue |
|
207 |
{ |
{ |
208 |
for (int i = 0; i < values.length; i++) |
for (int i = 0; i < values.length; i++) |
209 |
{ |
{ |
220 |
/** |
/** |
221 |
* Set the value of this enumeration as int. |
* Set the value of this enumeration as int. |
222 |
*/ |
*/ |
223 |
public void set_as_ulong(int value) |
public void set_as_ulong(int value) throws InvalidValue |
|
throws InvalidValue |
|
224 |
{ |
{ |
225 |
if (value < 0 || value >= values.length) |
if (value < 0 || value >= values.length) |
226 |
throw new InvalidValue(value + " not in [0.." + values.length); |
throw new InvalidValue(value + " not in [0.." + values.length); |