From 3b3101d8b5ae4f08a16c0b7111da6cad41bbd282 Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 15 Nov 2005 23:20:01 +0000 Subject: Imported GNU Classpath 0.19 + gcj-import-20051115. * sources.am: Regenerated. * Makefile.in: Likewise. * scripts/makemake.tcl: Use glob -nocomplain. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107049 138bc75d-0d04-0410-961f-82ee72b054a4 --- libjava/classpath/gnu/CORBA/DynAn/AbstractAny.java | 177 +++++++ .../classpath/gnu/CORBA/DynAn/DivideableAny.java | 514 +++++++++++++++++++++ libjava/classpath/gnu/CORBA/DynAn/RecordAny.java | 405 ++++++++++++++++ .../classpath/gnu/CORBA/DynAn/UndivideableAny.java | 493 ++++++++++++++++++++ .../gnu/CORBA/DynAn/ValueChangeListener.java | 50 ++ .../classpath/gnu/CORBA/DynAn/abstractDynAny.java | 177 ------- .../classpath/gnu/CORBA/DynAn/abstractRecord.java | 405 ---------------- .../classpath/gnu/CORBA/DynAn/anyDivideable.java | 514 --------------------- .../classpath/gnu/CORBA/DynAn/anyUndivideable.java | 493 -------------------- libjava/classpath/gnu/CORBA/DynAn/gnuDynAny.java | 28 +- .../gnu/CORBA/DynAn/gnuDynAnyFactory.java | 8 +- libjava/classpath/gnu/CORBA/DynAn/gnuDynArray.java | 14 +- libjava/classpath/gnu/CORBA/DynAn/gnuDynEnum.java | 2 +- libjava/classpath/gnu/CORBA/DynAn/gnuDynFixed.java | 2 +- .../classpath/gnu/CORBA/DynAn/gnuDynStruct.java | 4 +- libjava/classpath/gnu/CORBA/DynAn/gnuDynUnion.java | 10 +- libjava/classpath/gnu/CORBA/DynAn/gnuDynValue.java | 14 +- .../classpath/gnu/CORBA/DynAn/gnuDynValueBox.java | 6 +- .../gnu/CORBA/DynAn/valueChangedListener.java | 50 -- 19 files changed, 1685 insertions(+), 1681 deletions(-) create mode 100644 libjava/classpath/gnu/CORBA/DynAn/AbstractAny.java create mode 100644 libjava/classpath/gnu/CORBA/DynAn/DivideableAny.java create mode 100644 libjava/classpath/gnu/CORBA/DynAn/RecordAny.java create mode 100644 libjava/classpath/gnu/CORBA/DynAn/UndivideableAny.java create mode 100644 libjava/classpath/gnu/CORBA/DynAn/ValueChangeListener.java delete mode 100644 libjava/classpath/gnu/CORBA/DynAn/abstractDynAny.java delete mode 100644 libjava/classpath/gnu/CORBA/DynAn/abstractRecord.java delete mode 100644 libjava/classpath/gnu/CORBA/DynAn/anyDivideable.java delete mode 100644 libjava/classpath/gnu/CORBA/DynAn/anyUndivideable.java delete mode 100644 libjava/classpath/gnu/CORBA/DynAn/valueChangedListener.java (limited to 'libjava/classpath/gnu/CORBA/DynAn') diff --git a/libjava/classpath/gnu/CORBA/DynAn/AbstractAny.java b/libjava/classpath/gnu/CORBA/DynAn/AbstractAny.java new file mode 100644 index 00000000000..7060f86b27f --- /dev/null +++ b/libjava/classpath/gnu/CORBA/DynAn/AbstractAny.java @@ -0,0 +1,177 @@ +/* AbstractAny.java -- + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.CORBA.DynAn; + +import gnu.CORBA.TypeKindNamer; + +import org.omg.CORBA.Any; +import org.omg.CORBA.LocalObject; +import org.omg.CORBA.ORB; +import org.omg.CORBA.TypeCode; +import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; + +import java.io.Serializable; + +/** + * The top of our DynAny implementation, this class provides ORB that is + * required to create anys and factory that is required to initialise DynAnys. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class AbstractAny + extends LocalObject + implements Serializable +{ + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + + /** + * The "initial final_type" that can be an alias of the known final_type. + */ + public TypeCode official_type; + + /** + * The "basic" final_type to that the final_type finally evaluates. + */ + public final TypeCode final_type; + + /** + * The DynAny factory, required in initializations. + */ + public final gnuDynAnyFactory factory; + + /** + * The ORB, to that this DynAny belongs. + */ + public final ORB orb; + + /** + * The minor code, indicating the error, related to work with non - GNU + * Classpath DynAny. + */ + short MINOR = 8148; + + /** + * The message about the empty structure or exception. + */ + static final String EMPTY = "Empty structure with no fields."; + + /** + * The message about the structure or exception size mismatch. + */ + static final String SIZE = "Size mismatch."; + + /** + * The message about the content of this DynAny being equal to + * null + */ + static final String ISNULL = "The content is null"; + + /** + * The change value listener. + */ + ValueChangeListener listener; + + /** + * Create the abstract dyn any. + */ + public AbstractAny(TypeCode oType, TypeCode aType, + gnuDynAnyFactory aFactory, ORB anOrb + ) + { + official_type = oType; + final_type = aType; + factory = aFactory; + orb = anOrb; + } + + /** + * Get the typecode. + */ + public TypeCode type() + { + return official_type; + } + + /** + * Create the Any. + */ + public Any createAny() + { + return orb.create_any(); + } + + /** + * The "value changed" listener. + */ + protected void valueChanged() + { + if (listener != null) + listener.changed(); + } + + /** + * Check the type. + */ + void checkType(TypeCode expected, TypeCode actual) + throws TypeMismatch + { + if (!expected.equal(actual)) + throw new TypeMismatch(typeMismatch(expected, actual)); + } + + /** + * Format "Type mismatch" string. + */ + String typeMismatch(TypeCode expected, TypeCode actual) + { + return TypeKindNamer.nameIt(expected) + " expected " + + TypeKindNamer.nameIt(actual); + } + + /** + * Format "size mismatch" string. + */ + String sizeMismatch(int here, int other) + { + return "Size mismatch, " + other + " (expected " + here + ")"; + } +} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/DynAn/DivideableAny.java b/libjava/classpath/gnu/CORBA/DynAn/DivideableAny.java new file mode 100644 index 00000000000..c96cbedc73b --- /dev/null +++ b/libjava/classpath/gnu/CORBA/DynAn/DivideableAny.java @@ -0,0 +1,514 @@ +/* DivideableAny.java -- + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.CORBA.DynAn; + +import gnu.CORBA.TypeKindNamer; + +import org.omg.CORBA.Any; +import org.omg.CORBA.CompletionStatus; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Object; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.UNKNOWN; +import org.omg.DynamicAny.DynAny; +import org.omg.DynamicAny.DynAnyPackage.InvalidValue; +import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; +import org.omg.DynamicAny.DynValueCommon; + +import java.io.Serializable; + +/** + * Provides a base for DynAnys, having multiple components. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class DivideableAny + extends AbstractAny + implements Serializable +{ + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + + /** + * The array of the components that in general case may have different + * final_type. + */ + protected DynAny[] array; + + /** + * The internal pointer. + */ + protected int pos = 0; + + public DivideableAny(TypeCode oType, TypeCode aType, + gnuDynAnyFactory aFactory, ORB anOrb + ) + { + super(oType, aType, aFactory, anOrb); + } + + /** + * Advance forward. + */ + public boolean next() + { + pos++; + return array.length > pos; + } + + /** + * Set zero position. + */ + public void rewind() + { + pos = 0; + } + + /** + * Set a position. + */ + public boolean seek(int p) + { + pos = p; + return pos >= 0 && array.length > pos; + } + + /** + * Get the insertion point as DynAny. This method may throw exceptions if the + * current insertion point does not support reading or insertion of the + * primitive types. + * + * @return the focused component, from where the primitve value can be read or + * where it can be inserted. + * @throws InvalidValue if the primitive value cannot be inserted at the given + * point. + */ + protected DynAny focused() + throws InvalidValue, TypeMismatch + { + if (pos >= 0 && pos < array.length) + { + if (array [ pos ].component_count() == 0) + return array [ pos ]; + else + throw new TypeMismatch("Multiple coponents at " + pos); + } + else + throw new InvalidValue("Out of bounds at " + pos + " valid 0.." + + (array.length - 1) + ); + } + + /** {@inheritDoc} */ + public int component_count() + { + return array.length; + } + + /** + * Return the second (enclosed any) that is stored in the wrapped Any. + */ + public Any get_any() + throws TypeMismatch, InvalidValue + { + return focused().get_any(); + } + + /** {@inheritDoc} */ + public boolean get_boolean() + throws TypeMismatch, InvalidValue + { + return focused().get_boolean(); + } + + /** {@inheritDoc} */ + public char get_char() + throws TypeMismatch, InvalidValue + { + return focused().get_char(); + } + + /** {@inheritDoc} */ + public double get_double() + throws TypeMismatch, InvalidValue + { + return focused().get_double(); + } + + /** {@inheritDoc} */ + public float get_float() + throws TypeMismatch, InvalidValue + { + return focused().get_float(); + } + + /** {@inheritDoc} */ + public int get_long() + throws TypeMismatch, InvalidValue + { + return focused().get_long(); + } + + /** {@inheritDoc} */ + public long get_longlong() + throws TypeMismatch, InvalidValue + { + return focused().get_longlong(); + } + + /** {@inheritDoc} */ + public byte get_octet() + throws TypeMismatch, InvalidValue + { + return focused().get_octet(); + } + + /** {@inheritDoc} */ + public Object get_reference() + throws TypeMismatch, InvalidValue + { + return focused().get_reference(); + } + + /** {@inheritDoc} */ + public short get_short() + throws TypeMismatch, InvalidValue + { + return focused().get_short(); + } + + /** {@inheritDoc} */ + public String get_string() + throws TypeMismatch, InvalidValue + { + return focused().get_string(); + } + + /** {@inheritDoc} */ + public TypeCode get_typecode() + throws TypeMismatch, InvalidValue + { + return focused().get_typecode(); + } + + /** {@inheritDoc} */ + public int get_ulong() + throws TypeMismatch, InvalidValue + { + return focused().get_ulong(); + } + + /** {@inheritDoc} */ + public long get_ulonglong() + throws TypeMismatch, InvalidValue + { + return focused().get_ulonglong(); + } + + /** {@inheritDoc} */ + public short get_ushort() + throws TypeMismatch, InvalidValue + { + return focused().get_ushort(); + } + + /** {@inheritDoc} */ + public Serializable get_val() + throws TypeMismatch, InvalidValue + { + if (pos >= 0 && pos < array.length) + { + if (array [ pos ] instanceof DynValueCommon) + return array [ pos ].get_val(); + else + throw new TypeMismatch(); + } + else + throw new InvalidValue("Out of bounds at " + pos + " valid 0.." + + (array.length - 1) + ); + } + + /** {@inheritDoc} */ + public char get_wchar() + throws TypeMismatch, InvalidValue + { + return focused().get_wchar(); + } + + /** {@inheritDoc} */ + public String get_wstring() + throws TypeMismatch, InvalidValue + { + return focused().get_wstring(); + } + + /** {@inheritDoc} */ + public void insert_any(Any a_x) + throws TypeMismatch, InvalidValue + { + focused().insert_any(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_boolean(boolean a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_boolean(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_char(char a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_char(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_double(double a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_double(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_float(float a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_float(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_long(int a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_long(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_longlong(long a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_longlong(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_octet(byte a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_octet(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_reference(Object a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_reference(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_short(short a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_short(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_string(String a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_string(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_typecode(TypeCode a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_typecode(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_ulong(int a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_ulong(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_ulonglong(long a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_ulonglong(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_ushort(short a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_ushort(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_val(Serializable a_x) + throws InvalidValue, TypeMismatch + { + if (pos >= 0 && pos < array.length) + { + if (array [ pos ] instanceof DynValueCommon) + array [ pos ].insert_val(a_x); + else + throw new TypeMismatch(); + } + else + throw new InvalidValue("Out of bounds at " + pos + " valid 0.." + + (array.length - 1) + ); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_wchar(char a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_wchar(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public void insert_wstring(String a_x) + throws InvalidValue, TypeMismatch + { + focused().insert_wstring(a_x); + valueChanged(); + } + + /** {@inheritDoc} */ + public DynAny get_dyn_any() + throws TypeMismatch, InvalidValue + { + return focused().get_dyn_any(); + } + + /** {@inheritDoc} */ + public void insert_dyn_any(DynAny insert_it) + throws TypeMismatch, InvalidValue + { + focused().insert_dyn_any(insert_it); + } + + /** + * Get current component. + * + * @return current component or null if the pointer is out of + * bounds. + */ + public DynAny current_component() + throws TypeMismatch + { + if (array.length == 0) + throw new TypeMismatch("empty"); + return (pos >= 0 && pos < array.length) ? array [ pos ] : null; + } + + /** + * No action, cleanup is done by garbage collector in java. + */ + public void destroy() + { + } + + /** + * Involved in equal(DynAny). + */ + public abstract Any to_any() + throws TypeMismatch; + + /** + * Compares with other DynAny for equality. The final_type, array size and + * array members must match. + */ + public boolean equal(DynAny other) + { + try + { + if (!official_type.equal(other.type())) + return false; + else if (other instanceof DivideableAny) + { + DivideableAny x = (DivideableAny) other; + if (x.array.length != array.length) + return false; + + for (int i = 0; i < array.length; i++) + { + if (!array [ i ].equal(x.array [ i ])) + return false; + } + return true; + } + else if (other == null || other instanceof AbstractAny) + return false; + else + return other.to_any().equal(to_any()); + } + catch (TypeMismatch e) + { + UNKNOWN u = new UNKNOWN(MINOR, CompletionStatus.COMPLETED_NO); + u.initCause(e); + throw u; + } + } +} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/DynAn/RecordAny.java b/libjava/classpath/gnu/CORBA/DynAn/RecordAny.java new file mode 100644 index 00000000000..a3e3680d966 --- /dev/null +++ b/libjava/classpath/gnu/CORBA/DynAn/RecordAny.java @@ -0,0 +1,405 @@ +/* RecordAny.java -- + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.CORBA.DynAn; + +import gnu.CORBA.Unexpected; +import gnu.CORBA.HolderLocator; + +import org.omg.CORBA.Any; +import org.omg.CORBA.ORB; +import org.omg.CORBA.TCKind; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.TypeCodePackage.BadKind; +import org.omg.CORBA.TypeCodePackage.Bounds; +import org.omg.CORBA.portable.Streamable; +import org.omg.DynamicAny.DynAny; +import org.omg.DynamicAny.DynAnyPackage.InvalidValue; +import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; +import org.omg.DynamicAny.DynStruct; +import org.omg.DynamicAny.DynValueCommonOperations; +import org.omg.DynamicAny.NameDynAnyPair; +import org.omg.DynamicAny.NameValuePair; + +import java.io.Serializable; + +import java.lang.reflect.Field; + +/** + * A shared base for both dynamic structure an dynamic value final_type. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class RecordAny + extends DivideableAny + implements DynAny, Serializable +{ + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + String[] fNames; + + /** + * Creates the structure with the given typecode. + * + * @param fields The DynAny's, representing the fields of the structure. + */ + public RecordAny(TypeCode oType, TypeCode aType, + gnuDynAnyFactory aFactory, ORB anOrb + ) + { + super(oType, aType, aFactory, anOrb); + } + + /** @inheritDoc */ + public TCKind current_member_kind() + throws TypeMismatch, InvalidValue + { + if (array.length == 0) + throw new TypeMismatch(EMPTY); + try + { + return final_type.member_type(pos).kind(); + } + catch (BadKind e) + { + TypeMismatch t = new TypeMismatch(); + t.initCause(e); + throw t; + } + catch (Bounds e) + { + InvalidValue t = new InvalidValue(); + t.initCause(e); + throw t; + } + } + + /** @inheritDoc */ + public String current_member_name() + throws TypeMismatch, InvalidValue + { + if (array.length == 0) + throw new TypeMismatch(EMPTY); + try + { + return final_type.member_name(pos); + } + catch (BadKind e) + { + TypeMismatch t = new TypeMismatch(); + t.initCause(e); + throw t; + } + catch (Bounds e) + { + InvalidValue t = new InvalidValue(); + t.initCause(e); + throw t; + } + } + + /** + * Get content of the structure. This method must be defined on a different + * name because get_members_as_dyn_any() throws exception only in some of the + * supported interfaces. + */ + public NameDynAnyPair[] gnu_get_members_as_dyn_any() + { + NameDynAnyPair[] r = new NameDynAnyPair[ array.length ]; + for (int i = 0; i < r.length; i++) + { + try + { + r [ i ] = new NameDynAnyPair(fNames [ i ], array [ i ]); + } + catch (Exception ex) + { + throw new Unexpected(ex); + } + } + return r; + } + + /** + * Get content of the structure. This method must be defined on a different + * name because get_members_as_dyn_any() throws exception only in some of the + * supported interfaces. + */ + public NameValuePair[] gnu_get_members() + { + NameValuePair[] r = new NameValuePair[ array.length ]; + for (int i = 0; i < r.length; i++) + { + try + { + r [ i ] = new NameValuePair(fNames [ i ], array [ i ].to_any()); + } + catch (Exception ex) + { + throw new Unexpected(ex); + } + } + return r; + } + + /** + * Set members from the provided array. + */ + public void set_members_as_dyn_any(NameDynAnyPair[] value) + throws TypeMismatch, InvalidValue + { + if (value.length != array.length) + throw new InvalidValue(sizeMismatch(array.length, value.length)); + + for (int i = 0; i < value.length; i++) + { + DynAny dynAny = value [ i ].value; + checkType(dynAny.type(), i); + checkName(value [ i ].id, i); + + array [ i ] = dynAny; + } + pos = 0; + } + + /** + * Check the name at the given position ("" matches everything). + */ + private void checkName(String xName, int i) + throws TypeMismatch + { + if (xName.length() > 0 && fNames [ i ].length() > 0) + if (!xName.equals(fNames [ i ])) + throw new TypeMismatch("Field name mismatch " + xName + " expected " + + fNames [ i ] + ); + } + + /** + * Check the type at the given position. + */ + private void checkType(TypeCode t, int i) + throws TypeMismatch + { + if (!array [ i ].type().equal(t)) + throw new TypeMismatch(typeMismatch(array [ i ].type(), t) + " field " + + i + ); + } + + /** + * Set members from the provided array. + */ + public void set_members(NameValuePair[] value) + throws TypeMismatch, InvalidValue + { + if (value.length != array.length) + throw new InvalidValue(sizeMismatch(array.length, value.length)); + + for (int i = 0; i < value.length; i++) + { + Any any = value [ i ].value; + checkType(any.type(), i); + checkName(value [ i ].id, i); + + array [ i ].from_any(any); + } + pos = 0; + } + + /** @inheritDoc */ + public void assign(DynAny from) + throws TypeMismatch + { + checkType(official_type, from.type()); + if (from instanceof DynStruct) + { + try + { + set_members_as_dyn_any(((DynStruct) from).get_members_as_dyn_any()); + } + catch (InvalidValue e) + { + TypeMismatch t = new TypeMismatch("Invalid value"); + t.initCause(e); + throw t; + } + } + else + throw new TypeMismatch("Not a DynStruct"); + } + + /** + * Create a copy. + */ + public DynAny copy() + { + DynAny[] c = new DynAny[ array.length ]; + for (int i = 0; i < c.length; i++) + { + c [ i ] = array [ i ].copy(); + } + + RecordAny d = newInstance(official_type, final_type, factory, orb); + d.array = c; + return d; + } + + /** + * Create a new instance when copying. + */ + protected abstract RecordAny newInstance(TypeCode oType, TypeCode aType, + gnuDynAnyFactory aFactory, + ORB anOrb + ); + + /** + * Done via reflection. + */ + public Any to_any() + { + try + { + Streamable sHolder = HolderLocator.createHolder(official_type); + + Class sHolderClass = sHolder.getClass(); + Field sHolderValue = sHolderClass.getField("value"); + Class sClass = sHolderValue.getType(); + + Object structure = sClass.newInstance(); + Object member; + Any am; + Field vread; + Field vwrite; + Streamable memberHolder; + + for (int i = 0; i < array.length; i++) + { + am = array [ i ].to_any(); + memberHolder = am.extract_Streamable(); + vwrite = structure.getClass().getField(final_type.member_name(i)); + vread = memberHolder.getClass().getField("value"); + member = vread.get(memberHolder); + vwrite.set(structure, member); + } + + Any g = createAny(); + sHolderValue.set(sHolder, structure); + g.insert_Streamable(sHolder); + g.type(official_type); + return g; + } + catch (Exception e) + { + throw new Unexpected(e); + } + } + + /** + * Done via reflection. + */ + public void from_any(Any an_any) + throws TypeMismatch, InvalidValue + { + checkType(official_type, an_any.type()); + try + { + Streamable s = an_any.extract_Streamable(); + if (s == null) + { + if (this instanceof DynValueCommonOperations) + { + ((DynValueCommonOperations) this).set_to_null(); + return; + } + else + throw new InvalidValue(ISNULL); + } + + Object structure = s.getClass().getField("value").get(s); + if (structure == null && (this instanceof DynValueCommonOperations)) + { + ((DynValueCommonOperations) this).set_to_null(); + return; + } + + Any member; + Streamable holder; + Object field; + TypeCode fType; + Field fField; + + for (int i = 0; i < array.length; i++) + { + fField = structure.getClass().getField(fNames [ i ]); + field = fField.get(structure); + fType = array [ i ].type(); + holder = HolderLocator.createHolder(fType); + + member = createAny(); + holder.getClass().getField("value").set(holder, field); + member.insert_Streamable(holder); + member.type(fType); + + array [ i ].from_any(member); + } + + if (this instanceof DynValueCommonOperations) + ((DynValueCommonOperations) this).set_to_value(); + } + catch (InvalidValue v) + { + throw v; + } + catch (NoSuchFieldException ex) + { + TypeMismatch v = + new TypeMismatch("holder value does not match typecode"); + v.initCause(ex); + throw v; + } + catch (Exception ex) + { + TypeMismatch t = new TypeMismatch(); + t.initCause(ex); + throw t; + } + } +} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/DynAn/UndivideableAny.java b/libjava/classpath/gnu/CORBA/DynAn/UndivideableAny.java new file mode 100644 index 00000000000..da4e9618ee7 --- /dev/null +++ b/libjava/classpath/gnu/CORBA/DynAn/UndivideableAny.java @@ -0,0 +1,493 @@ +/* Undivideable.java -- + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.CORBA.DynAn; + +import java.io.Serializable; + +import org.omg.CORBA.Any; +import org.omg.CORBA.ORB; +import org.omg.CORBA.Object; +import org.omg.CORBA.TypeCode; +import org.omg.DynamicAny.DynAny; +import org.omg.DynamicAny.DynAnyPackage.InvalidValue; +import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; + +/** + * Represent DynAny that has no internal components (DynEnum and so on). The + * methods, related to internal components, throw exceptions or return agreed + * values like null. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class UndivideableAny + extends AbstractAny + implements Serializable +{ + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + + /** + * Create a new instance with the given typecode. + */ + public UndivideableAny(TypeCode oType, TypeCode aType, + gnuDynAnyFactory aFactory, ORB anOrb) + { + super(oType, aType, aFactory, anOrb); + } + + /** + * There are no components. + * + * @return 0, always. + */ + public int component_count() + { + return 0; + } + + /** + * There is no current component. + * + * @throws TypeMismatch, always. + */ + public DynAny current_component() + throws TypeMismatch + { + throw new TypeMismatch("Not applicable"); + } + + /** + * Returns without action. + */ + public void destroy() + { + } + + /** + * Not in use. + */ + public Any get_any() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public boolean get_boolean() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public char get_char() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public double get_double() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public DynAny get_dyn_any() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public float get_float() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public int get_long() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public long get_longlong() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public byte get_octet() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public Object get_reference() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public short get_short() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public String get_string() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public TypeCode get_typecode() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public int get_ulong() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public long get_ulonglong() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public short get_ushort() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public Serializable get_val() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public char get_wchar() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public String get_wstring() + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_any(Any an_any) + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_boolean(boolean a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_char(char a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_double(double a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_dyn_any(DynAny insert_it) + throws TypeMismatch, InvalidValue + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_float(float a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_long(int a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_longlong(long a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_octet(byte a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_reference(Object a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_short(short a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_string(String a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_typecode(TypeCode a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_ulong(int a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_ulonglong(long a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_ushort(short a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_val(Serializable a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_wchar(char a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public void insert_wstring(String a_x) + throws InvalidValue, TypeMismatch + { + throw new TypeMismatch(); + } + + /** + * Not in use. + */ + public boolean next() + { + return false; + } + + /** + * Not in use. + */ + public void rewind() + { + } + + /** + * Not in use. + */ + public boolean seek(int p) + { + return false; + } + + /** + * Get the typecode of this enumeration. + */ + public TypeCode type() + { + return official_type; + } + + /** + * Compares with other DynAny for equality. + */ + public boolean equals(java.lang.Object other) + { + if (other instanceof DynAny) + return equal((DynAny) other); + else + return false; + } + + /** + * This depends on an object. + */ + public abstract boolean equal(DynAny other); + +} diff --git a/libjava/classpath/gnu/CORBA/DynAn/ValueChangeListener.java b/libjava/classpath/gnu/CORBA/DynAn/ValueChangeListener.java new file mode 100644 index 00000000000..59727615999 --- /dev/null +++ b/libjava/classpath/gnu/CORBA/DynAn/ValueChangeListener.java @@ -0,0 +1,50 @@ +/* ValueChangeListener.java -- + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ + + +package gnu.CORBA.DynAn; + +/** + * An interface, able to receive notification about the change of value + * of some DynAny. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ValueChangeListener +{ + void changed(); +} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/DynAn/abstractDynAny.java b/libjava/classpath/gnu/CORBA/DynAn/abstractDynAny.java deleted file mode 100644 index 47176c4b589..00000000000 --- a/libjava/classpath/gnu/CORBA/DynAn/abstractDynAny.java +++ /dev/null @@ -1,177 +0,0 @@ -/* abstractDynAny.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.CORBA.DynAn; - -import gnu.CORBA.typeNamer; - -import org.omg.CORBA.Any; -import org.omg.CORBA.LocalObject; -import org.omg.CORBA.ORB; -import org.omg.CORBA.TypeCode; -import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; - -import java.io.Serializable; - -/** - * The top of our DynAny implementation, this class provides ORB that is - * required to create anys and factory that is required to initialise DynAnys. - * - * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) - */ -public abstract class abstractDynAny - extends LocalObject - implements Serializable -{ - /** - * Use serialVersionUID for interoperability. - */ - private static final long serialVersionUID = 1; - - /** - * The "initial final_type" that can be an alias of the known final_type. - */ - public TypeCode official_type; - - /** - * The "basic" final_type to that the final_type finally evaluates. - */ - public final TypeCode final_type; - - /** - * The DynAny factory, required in initializations. - */ - public final gnuDynAnyFactory factory; - - /** - * The ORB, to that this DynAny belongs. - */ - public final ORB orb; - - /** - * The minor code, indicating the error, related to work with non - GNU - * Classpath DynAny. - */ - short MINOR = 8148; - - /** - * The message about the empty structure or exception. - */ - static final String EMPTY = "Empty structure with no fields."; - - /** - * The message about the structure or exception size mismatch. - */ - static final String SIZE = "Size mismatch."; - - /** - * The message about the content of this DynAny being equal to - * null - */ - static final String ISNULL = "The content is null"; - - /** - * The change value listener. - */ - valueChangedListener listener; - - /** - * Create the abstract dyn any. - */ - public abstractDynAny(TypeCode oType, TypeCode aType, - gnuDynAnyFactory aFactory, ORB anOrb - ) - { - official_type = oType; - final_type = aType; - factory = aFactory; - orb = anOrb; - } - - /** - * Get the typecode. - */ - public TypeCode type() - { - return official_type; - } - - /** - * Create the Any. - */ - public Any createAny() - { - return orb.create_any(); - } - - /** - * The "value changed" listener. - */ - protected void valueChanged() - { - if (listener != null) - listener.changed(); - } - - /** - * Check the type. - */ - void checkType(TypeCode expected, TypeCode actual) - throws TypeMismatch - { - if (!expected.equal(actual)) - throw new TypeMismatch(typeMismatch(expected, actual)); - } - - /** - * Format "Type mismatch" string. - */ - String typeMismatch(TypeCode expected, TypeCode actual) - { - return typeNamer.nameIt(expected) + " expected " + - typeNamer.nameIt(actual); - } - - /** - * Format "size mismatch" string. - */ - String sizeMismatch(int here, int other) - { - return "Size mismatch, " + other + " (expected " + here + ")"; - } -} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/DynAn/abstractRecord.java b/libjava/classpath/gnu/CORBA/DynAn/abstractRecord.java deleted file mode 100644 index 8d8b7a559b1..00000000000 --- a/libjava/classpath/gnu/CORBA/DynAn/abstractRecord.java +++ /dev/null @@ -1,405 +0,0 @@ -/* abstractRecord.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.CORBA.DynAn; - -import gnu.CORBA.Unexpected; -import gnu.CORBA.holderFactory; - -import org.omg.CORBA.Any; -import org.omg.CORBA.ORB; -import org.omg.CORBA.TCKind; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.TypeCodePackage.BadKind; -import org.omg.CORBA.TypeCodePackage.Bounds; -import org.omg.CORBA.portable.Streamable; -import org.omg.DynamicAny.DynAny; -import org.omg.DynamicAny.DynAnyPackage.InvalidValue; -import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; -import org.omg.DynamicAny.DynStruct; -import org.omg.DynamicAny.DynValueCommonOperations; -import org.omg.DynamicAny.NameDynAnyPair; -import org.omg.DynamicAny.NameValuePair; - -import java.io.Serializable; - -import java.lang.reflect.Field; - -/** - * A shared base for both dynamic structure an dynamic value final_type. - * - * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) - */ -public abstract class abstractRecord - extends anyDivideable - implements DynAny, Serializable -{ - /** - * Use serialVersionUID for interoperability. - */ - private static final long serialVersionUID = 1; - String[] fNames; - - /** - * Creates the structure with the given typecode. - * - * @param fields The DynAny's, representing the fields of the structure. - */ - public abstractRecord(TypeCode oType, TypeCode aType, - gnuDynAnyFactory aFactory, ORB anOrb - ) - { - super(oType, aType, aFactory, anOrb); - } - - /** @inheritDoc */ - public TCKind current_member_kind() - throws TypeMismatch, InvalidValue - { - if (array.length == 0) - throw new TypeMismatch(EMPTY); - try - { - return final_type.member_type(pos).kind(); - } - catch (BadKind e) - { - TypeMismatch t = new TypeMismatch(); - t.initCause(e); - throw t; - } - catch (Bounds e) - { - InvalidValue t = new InvalidValue(); - t.initCause(e); - throw t; - } - } - - /** @inheritDoc */ - public String current_member_name() - throws TypeMismatch, InvalidValue - { - if (array.length == 0) - throw new TypeMismatch(EMPTY); - try - { - return final_type.member_name(pos); - } - catch (BadKind e) - { - TypeMismatch t = new TypeMismatch(); - t.initCause(e); - throw t; - } - catch (Bounds e) - { - InvalidValue t = new InvalidValue(); - t.initCause(e); - throw t; - } - } - - /** - * Get content of the structure. This method must be defined on a different - * name because get_members_as_dyn_any() throws exception only in some of the - * supported interfaces. - */ - public NameDynAnyPair[] gnu_get_members_as_dyn_any() - { - NameDynAnyPair[] r = new NameDynAnyPair[ array.length ]; - for (int i = 0; i < r.length; i++) - { - try - { - r [ i ] = new NameDynAnyPair(fNames [ i ], array [ i ]); - } - catch (Exception ex) - { - throw new Unexpected(ex); - } - } - return r; - } - - /** - * Get content of the structure. This method must be defined on a different - * name because get_members_as_dyn_any() throws exception only in some of the - * supported interfaces. - */ - public NameValuePair[] gnu_get_members() - { - NameValuePair[] r = new NameValuePair[ array.length ]; - for (int i = 0; i < r.length; i++) - { - try - { - r [ i ] = new NameValuePair(fNames [ i ], array [ i ].to_any()); - } - catch (Exception ex) - { - throw new Unexpected(ex); - } - } - return r; - } - - /** - * Set members from the provided array. - */ - public void set_members_as_dyn_any(NameDynAnyPair[] value) - throws TypeMismatch, InvalidValue - { - if (value.length != array.length) - throw new InvalidValue(sizeMismatch(array.length, value.length)); - - for (int i = 0; i < value.length; i++) - { - DynAny dynAny = value [ i ].value; - checkType(dynAny.type(), i); - checkName(value [ i ].id, i); - - array [ i ] = dynAny; - } - pos = 0; - } - - /** - * Check the name at the given position ("" matches everything). - */ - private void checkName(String xName, int i) - throws TypeMismatch - { - if (xName.length() > 0 && fNames [ i ].length() > 0) - if (!xName.equals(fNames [ i ])) - throw new TypeMismatch("Field name mismatch " + xName + " expected " + - fNames [ i ] - ); - } - - /** - * Check the type at the given position. - */ - private void checkType(TypeCode t, int i) - throws TypeMismatch - { - if (!array [ i ].type().equal(t)) - throw new TypeMismatch(typeMismatch(array [ i ].type(), t) + " field " + - i - ); - } - - /** - * Set members from the provided array. - */ - public void set_members(NameValuePair[] value) - throws TypeMismatch, InvalidValue - { - if (value.length != array.length) - throw new InvalidValue(sizeMismatch(array.length, value.length)); - - for (int i = 0; i < value.length; i++) - { - Any any = value [ i ].value; - checkType(any.type(), i); - checkName(value [ i ].id, i); - - array [ i ].from_any(any); - } - pos = 0; - } - - /** @inheritDoc */ - public void assign(DynAny from) - throws TypeMismatch - { - checkType(official_type, from.type()); - if (from instanceof DynStruct) - { - try - { - set_members_as_dyn_any(((DynStruct) from).get_members_as_dyn_any()); - } - catch (InvalidValue e) - { - TypeMismatch t = new TypeMismatch("Invalid value"); - t.initCause(e); - throw t; - } - } - else - throw new TypeMismatch("Not a DynStruct"); - } - - /** - * Create a copy. - */ - public DynAny copy() - { - DynAny[] c = new DynAny[ array.length ]; - for (int i = 0; i < c.length; i++) - { - c [ i ] = array [ i ].copy(); - } - - abstractRecord d = newInstance(official_type, final_type, factory, orb); - d.array = c; - return d; - } - - /** - * Create a new instance when copying. - */ - protected abstract abstractRecord newInstance(TypeCode oType, TypeCode aType, - gnuDynAnyFactory aFactory, - ORB anOrb - ); - - /** - * Done via reflection. - */ - public Any to_any() - { - try - { - Streamable sHolder = holderFactory.createHolder(official_type); - - Class sHolderClass = sHolder.getClass(); - Field sHolderValue = sHolderClass.getField("value"); - Class sClass = sHolderValue.getType(); - - Object structure = sClass.newInstance(); - Object member; - Any am; - Field vread; - Field vwrite; - Streamable memberHolder; - - for (int i = 0; i < array.length; i++) - { - am = array [ i ].to_any(); - memberHolder = am.extract_Streamable(); - vwrite = structure.getClass().getField(final_type.member_name(i)); - vread = memberHolder.getClass().getField("value"); - member = vread.get(memberHolder); - vwrite.set(structure, member); - } - - Any g = createAny(); - sHolderValue.set(sHolder, structure); - g.insert_Streamable(sHolder); - g.type(official_type); - return g; - } - catch (Exception e) - { - throw new Unexpected(e); - } - } - - /** - * Done via reflection. - */ - public void from_any(Any an_any) - throws TypeMismatch, InvalidValue - { - checkType(official_type, an_any.type()); - try - { - Streamable s = an_any.extract_Streamable(); - if (s == null) - { - if (this instanceof DynValueCommonOperations) - { - ((DynValueCommonOperations) this).set_to_null(); - return; - } - else - throw new InvalidValue(ISNULL); - } - - Object structure = s.getClass().getField("value").get(s); - if (structure == null && (this instanceof DynValueCommonOperations)) - { - ((DynValueCommonOperations) this).set_to_null(); - return; - } - - Any member; - Streamable holder; - Object field; - TypeCode fType; - Field fField; - - for (int i = 0; i < array.length; i++) - { - fField = structure.getClass().getField(fNames [ i ]); - field = fField.get(structure); - fType = array [ i ].type(); - holder = holderFactory.createHolder(fType); - - member = createAny(); - holder.getClass().getField("value").set(holder, field); - member.insert_Streamable(holder); - member.type(fType); - - array [ i ].from_any(member); - } - - if (this instanceof DynValueCommonOperations) - ((DynValueCommonOperations) this).set_to_value(); - } - catch (InvalidValue v) - { - throw v; - } - catch (NoSuchFieldException ex) - { - TypeMismatch v = - new TypeMismatch("holder value does not match typecode"); - v.initCause(ex); - throw v; - } - catch (Exception ex) - { - TypeMismatch t = new TypeMismatch(); - t.initCause(ex); - throw t; - } - } -} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/DynAn/anyDivideable.java b/libjava/classpath/gnu/CORBA/DynAn/anyDivideable.java deleted file mode 100644 index 5f52c8078eb..00000000000 --- a/libjava/classpath/gnu/CORBA/DynAn/anyDivideable.java +++ /dev/null @@ -1,514 +0,0 @@ -/* anyDivideable.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.CORBA.DynAn; - -import gnu.CORBA.typeNamer; - -import org.omg.CORBA.Any; -import org.omg.CORBA.CompletionStatus; -import org.omg.CORBA.ORB; -import org.omg.CORBA.Object; -import org.omg.CORBA.TypeCode; -import org.omg.CORBA.UNKNOWN; -import org.omg.DynamicAny.DynAny; -import org.omg.DynamicAny.DynAnyPackage.InvalidValue; -import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; -import org.omg.DynamicAny.DynValueCommon; - -import java.io.Serializable; - -/** - * Provides a base for DynAnys, having multiple components. - * - * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) - */ -public abstract class anyDivideable - extends abstractDynAny - implements Serializable -{ - /** - * Use serialVersionUID for interoperability. - */ - private static final long serialVersionUID = 1; - - /** - * The array of the components that in general case may have different - * final_type. - */ - protected DynAny[] array; - - /** - * The internal pointer. - */ - protected int pos = 0; - - public anyDivideable(TypeCode oType, TypeCode aType, - gnuDynAnyFactory aFactory, ORB anOrb - ) - { - super(oType, aType, aFactory, anOrb); - } - - /** - * Advance forward. - */ - public boolean next() - { - pos++; - return array.length > pos; - } - - /** - * Set zero position. - */ - public void rewind() - { - pos = 0; - } - - /** - * Set a position. - */ - public boolean seek(int p) - { - pos = p; - return pos >= 0 && array.length > pos; - } - - /** - * Get the insertion point as DynAny. This method may throw exceptions if the - * current insertion point does not support reading or insertion of the - * primitive types. - * - * @return the focused component, from where the primitve value can be read or - * where it can be inserted. - * @throws InvalidValue if the primitive value cannot be inserted at the given - * point. - */ - protected DynAny focused() - throws InvalidValue, TypeMismatch - { - if (pos >= 0 && pos < array.length) - { - if (array [ pos ].component_count() == 0) - return array [ pos ]; - else - throw new TypeMismatch("Multiple coponents at " + pos); - } - else - throw new InvalidValue("Out of bounds at " + pos + " valid 0.." + - (array.length - 1) - ); - } - - /** {@inheritDoc} */ - public int component_count() - { - return array.length; - } - - /** - * Return the second (enclosed any) that is stored in the wrapped Any. - */ - public Any get_any() - throws TypeMismatch, InvalidValue - { - return focused().get_any(); - } - - /** {@inheritDoc} */ - public boolean get_boolean() - throws TypeMismatch, InvalidValue - { - return focused().get_boolean(); - } - - /** {@inheritDoc} */ - public char get_char() - throws TypeMismatch, InvalidValue - { - return focused().get_char(); - } - - /** {@inheritDoc} */ - public double get_double() - throws TypeMismatch, InvalidValue - { - return focused().get_double(); - } - - /** {@inheritDoc} */ - public float get_float() - throws TypeMismatch, InvalidValue - { - return focused().get_float(); - } - - /** {@inheritDoc} */ - public int get_long() - throws TypeMismatch, InvalidValue - { - return focused().get_long(); - } - - /** {@inheritDoc} */ - public long get_longlong() - throws TypeMismatch, InvalidValue - { - return focused().get_longlong(); - } - - /** {@inheritDoc} */ - public byte get_octet() - throws TypeMismatch, InvalidValue - { - return focused().get_octet(); - } - - /** {@inheritDoc} */ - public Object get_reference() - throws TypeMismatch, InvalidValue - { - return focused().get_reference(); - } - - /** {@inheritDoc} */ - public short get_short() - throws TypeMismatch, InvalidValue - { - return focused().get_short(); - } - - /** {@inheritDoc} */ - public String get_string() - throws TypeMismatch, InvalidValue - { - return focused().get_string(); - } - - /** {@inheritDoc} */ - public TypeCode get_typecode() - throws TypeMismatch, InvalidValue - { - return focused().get_typecode(); - } - - /** {@inheritDoc} */ - public int get_ulong() - throws TypeMismatch, InvalidValue - { - return focused().get_ulong(); - } - - /** {@inheritDoc} */ - public long get_ulonglong() - throws TypeMismatch, InvalidValue - { - return focused().get_ulonglong(); - } - - /** {@inheritDoc} */ - public short get_ushort() - throws TypeMismatch, InvalidValue - { - return focused().get_ushort(); - } - - /** {@inheritDoc} */ - public Serializable get_val() - throws TypeMismatch, InvalidValue - { - if (pos >= 0 && pos < array.length) - { - if (array [ pos ] instanceof DynValueCommon) - return array [ pos ].get_val(); - else - throw new TypeMismatch(); - } - else - throw new InvalidValue("Out of bounds at " + pos + " valid 0.." + - (array.length - 1) - ); - } - - /** {@inheritDoc} */ - public char get_wchar() - throws TypeMismatch, InvalidValue - { - return focused().get_wchar(); - } - - /** {@inheritDoc} */ - public String get_wstring() - throws TypeMismatch, InvalidValue - { - return focused().get_wstring(); - } - - /** {@inheritDoc} */ - public void insert_any(Any a_x) - throws TypeMismatch, InvalidValue - { - focused().insert_any(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_boolean(boolean a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_boolean(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_char(char a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_char(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_double(double a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_double(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_float(float a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_float(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_long(int a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_long(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_longlong(long a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_longlong(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_octet(byte a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_octet(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_reference(Object a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_reference(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_short(short a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_short(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_string(String a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_string(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_typecode(TypeCode a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_typecode(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_ulong(int a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_ulong(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_ulonglong(long a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_ulonglong(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_ushort(short a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_ushort(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_val(Serializable a_x) - throws InvalidValue, TypeMismatch - { - if (pos >= 0 && pos < array.length) - { - if (array [ pos ] instanceof DynValueCommon) - array [ pos ].insert_val(a_x); - else - throw new TypeMismatch(); - } - else - throw new InvalidValue("Out of bounds at " + pos + " valid 0.." + - (array.length - 1) - ); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_wchar(char a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_wchar(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public void insert_wstring(String a_x) - throws InvalidValue, TypeMismatch - { - focused().insert_wstring(a_x); - valueChanged(); - } - - /** {@inheritDoc} */ - public DynAny get_dyn_any() - throws TypeMismatch, InvalidValue - { - return focused().get_dyn_any(); - } - - /** {@inheritDoc} */ - public void insert_dyn_any(DynAny insert_it) - throws TypeMismatch, InvalidValue - { - focused().insert_dyn_any(insert_it); - } - - /** - * Get current component. - * - * @return current component or null if the pointer is out of - * bounds. - */ - public DynAny current_component() - throws TypeMismatch - { - if (array.length == 0) - throw new TypeMismatch("empty"); - return (pos >= 0 && pos < array.length) ? array [ pos ] : null; - } - - /** - * No action, cleanup is done by garbage collector in java. - */ - public void destroy() - { - } - - /** - * Involved in equal(DynAny). - */ - public abstract Any to_any() - throws TypeMismatch; - - /** - * Compares with other DynAny for equality. The final_type, array size and - * array members must match. - */ - public boolean equal(DynAny other) - { - try - { - if (!official_type.equal(other.type())) - return false; - else if (other instanceof anyDivideable) - { - anyDivideable x = (anyDivideable) other; - if (x.array.length != array.length) - return false; - - for (int i = 0; i < array.length; i++) - { - if (!array [ i ].equal(x.array [ i ])) - return false; - } - return true; - } - else if (other == null || other instanceof abstractDynAny) - return false; - else - return other.to_any().equal(to_any()); - } - catch (TypeMismatch e) - { - UNKNOWN u = new UNKNOWN(MINOR, CompletionStatus.COMPLETED_NO); - u.initCause(e); - throw u; - } - } -} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/DynAn/anyUndivideable.java b/libjava/classpath/gnu/CORBA/DynAn/anyUndivideable.java deleted file mode 100644 index b31a6b357f9..00000000000 --- a/libjava/classpath/gnu/CORBA/DynAn/anyUndivideable.java +++ /dev/null @@ -1,493 +0,0 @@ -/* Undivideable.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.CORBA.DynAn; - -import java.io.Serializable; - -import org.omg.CORBA.Any; -import org.omg.CORBA.ORB; -import org.omg.CORBA.Object; -import org.omg.CORBA.TypeCode; -import org.omg.DynamicAny.DynAny; -import org.omg.DynamicAny.DynAnyPackage.InvalidValue; -import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; - -/** - * Represent DynAny that has no internal components (DynEnum and so on). The - * methods, related to internal components, throw exceptions or return agreed - * values like null. - * - * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) - */ -public abstract class anyUndivideable - extends abstractDynAny - implements Serializable -{ - /** - * Use serialVersionUID for interoperability. - */ - private static final long serialVersionUID = 1; - - /** - * Create a new instance with the given typecode. - */ - public anyUndivideable(TypeCode oType, TypeCode aType, - gnuDynAnyFactory aFactory, ORB anOrb) - { - super(oType, aType, aFactory, anOrb); - } - - /** - * There are no components. - * - * @return 0, always. - */ - public int component_count() - { - return 0; - } - - /** - * There is no current component. - * - * @throws TypeMismatch, always. - */ - public DynAny current_component() - throws TypeMismatch - { - throw new TypeMismatch("Not applicable"); - } - - /** - * Returns without action. - */ - public void destroy() - { - } - - /** - * Not in use. - */ - public Any get_any() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public boolean get_boolean() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public char get_char() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public double get_double() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public DynAny get_dyn_any() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public float get_float() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public int get_long() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public long get_longlong() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public byte get_octet() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public Object get_reference() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public short get_short() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public String get_string() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public TypeCode get_typecode() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public int get_ulong() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public long get_ulonglong() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public short get_ushort() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public Serializable get_val() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public char get_wchar() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public String get_wstring() - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_any(Any an_any) - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_boolean(boolean a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_char(char a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_double(double a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_dyn_any(DynAny insert_it) - throws TypeMismatch, InvalidValue - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_float(float a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_long(int a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_longlong(long a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_octet(byte a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_reference(Object a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_short(short a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_string(String a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_typecode(TypeCode a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_ulong(int a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_ulonglong(long a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_ushort(short a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_val(Serializable a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_wchar(char a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public void insert_wstring(String a_x) - throws InvalidValue, TypeMismatch - { - throw new TypeMismatch(); - } - - /** - * Not in use. - */ - public boolean next() - { - return false; - } - - /** - * Not in use. - */ - public void rewind() - { - } - - /** - * Not in use. - */ - public boolean seek(int p) - { - return false; - } - - /** - * Get the typecode of this enumeration. - */ - public TypeCode type() - { - return official_type; - } - - /** - * Compares with other DynAny for equality. - */ - public boolean equals(java.lang.Object other) - { - if (other instanceof DynAny) - return equal((DynAny) other); - else - return false; - } - - /** - * This depends on an object. - */ - public abstract boolean equal(DynAny other); - -} diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynAny.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynAny.java index 015628ebf90..23141de3d96 100644 --- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynAny.java +++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynAny.java @@ -38,14 +38,14 @@ exception statement from your version. */ package gnu.CORBA.DynAn; -import gnu.CORBA.CDR.cdrBufOutput; +import gnu.CORBA.CDR.BufferedCdrOutput; import gnu.CORBA.OctetHolder; import gnu.CORBA.Unexpected; import gnu.CORBA.WCharHolder; import gnu.CORBA.WStringHolder; -import gnu.CORBA.holderFactory; -import gnu.CORBA.typeNamer; -import gnu.CORBA.universalHolder; +import gnu.CORBA.HolderLocator; +import gnu.CORBA.TypeKindNamer; +import gnu.CORBA.GeneralHolder; import org.omg.CORBA.Any; import org.omg.CORBA.AnyHolder; @@ -84,7 +84,7 @@ import java.util.Arrays; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class gnuDynAny extends abstractDynAny implements DynAny, Serializable +public class gnuDynAny extends AbstractAny implements DynAny, Serializable { /** * Use serialVersionUID for interoperability. @@ -132,7 +132,7 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable { if (holder != null) { - cdrBufOutput buffer = new cdrBufOutput(); + BufferedCdrOutput buffer = new BufferedCdrOutput(); holder._write(buffer); gnuDynAny other; @@ -165,7 +165,7 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable public DynAny current_component() throws TypeMismatch { throw new TypeMismatch("Not applicable for " + - typeNamer.nameIt(final_type) + TypeKindNamer.nameIt(final_type) ); } @@ -193,14 +193,14 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable { throw new InvalidValue(ISNULL); } - else if (a_holder instanceof universalHolder) + else if (a_holder instanceof GeneralHolder) { - holder = holderFactory.createHolder(official_type); + holder = HolderLocator.createHolder(official_type); if (holder == null) - holder = holderFactory.createHolder(final_type); + holder = HolderLocator.createHolder(final_type); if (holder == null) - holder = ((universalHolder) a_holder).Clone(); + holder = ((GeneralHolder) a_holder).Clone(); else { InputStream in = an_any.create_input_stream(); @@ -890,7 +890,7 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable */ public boolean equal(DynAny other) { - if (other instanceof abstractDynAny) + if (other instanceof AbstractAny) { if (other instanceof gnuDynAny) { @@ -899,10 +899,10 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable if (!x.holder.getClass().equals(holder.getClass())) return false; - cdrBufOutput b1 = new cdrBufOutput(); + BufferedCdrOutput b1 = new BufferedCdrOutput(); x.holder._write(b1); - cdrBufOutput b2 = new cdrBufOutput(b1.buffer.size() + 10); + BufferedCdrOutput b2 = new BufferedCdrOutput(b1.buffer.size() + 10); holder._write(b2); return Arrays.equals(b1.buffer.toByteArray(), diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynAnyFactory.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynAnyFactory.java index dd1762890de..b8b39bfbcdf 100644 --- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynAnyFactory.java +++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynAnyFactory.java @@ -40,8 +40,8 @@ package gnu.CORBA.DynAn; import gnu.CORBA.Poa.ORB_1_4; import gnu.CORBA.Unexpected; -import gnu.CORBA.holderFactory; -import gnu.CORBA.typeNamer; +import gnu.CORBA.HolderLocator; +import gnu.CORBA.TypeKindNamer; import org.omg.CORBA.Any; import org.omg.CORBA.LocalObject; @@ -227,7 +227,7 @@ public class gnuDynAnyFactory */ public DynAny create_simple(TypeCode official, TypeCode type) { - Streamable holder = holderFactory.createHolder(type); + Streamable holder = HolderLocator.createHolder(type); return new gnuDynAny(holder, official, type, this, orb); } @@ -314,7 +314,7 @@ public class gnuDynAnyFactory case TCKind._tk_Principal : case TCKind._tk_abstract_interface : throw new InconsistentTypeCode("Following API, the " + - typeNamer.nameIt(type) + + TypeKindNamer.nameIt(type) + " must not be supported." ); diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynArray.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynArray.java index 1c08496d423..825cd0a5638 100644 --- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynArray.java +++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynArray.java @@ -39,7 +39,7 @@ exception statement from your version. */ package gnu.CORBA.DynAn; import gnu.CORBA.Unexpected; -import gnu.CORBA.holderFactory; +import gnu.CORBA.HolderLocator; import org.omg.CORBA.Any; import org.omg.CORBA.BAD_PARAM; @@ -66,7 +66,7 @@ import java.lang.reflect.Field; * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ public class gnuDynArray - extends anyDivideable + extends DivideableAny implements DynArray, Serializable { /** @@ -238,10 +238,10 @@ public class gnuDynArray try { Streamable memberHolder = - holderFactory.createHolder(official_components); + HolderLocator.createHolder(official_components); if (memberHolder == null) - memberHolder = holderFactory.createHolder(final_components); + memberHolder = HolderLocator.createHolder(final_components); Class memberHolderClass = memberHolder.getClass(); Class memberClass = memberHolderClass.getField("value").getType(); @@ -260,7 +260,7 @@ public class gnuDynArray Array.set(members, i, member); } - Streamable arrayHolder = holderFactory.createHolder(official_type); + Streamable arrayHolder = HolderLocator.createHolder(official_type); arrayHolder.getClass().getField("value").set(arrayHolder, members); Any g = createAny(); @@ -296,9 +296,9 @@ public class gnuDynArray { if (holderClass == null) { - holder = holderFactory.createHolder(official_components); + holder = HolderLocator.createHolder(official_components); if (holder == null) - holder = holderFactory.createHolder(final_components); + holder = HolderLocator.createHolder(final_components); holderClass = holder.getClass(); } else diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynEnum.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynEnum.java index 2fccc85c59d..6eb7fe2bcac 100644 --- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynEnum.java +++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynEnum.java @@ -60,7 +60,7 @@ import java.util.Arrays; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class gnuDynEnum extends anyUndivideable implements DynEnum +public class gnuDynEnum extends UndivideableAny implements DynEnum { /** * Use serialVersionUID for interoperability. diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynFixed.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynFixed.java index 39b00226245..9655f0387da 100644 --- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynFixed.java +++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynFixed.java @@ -57,7 +57,7 @@ import java.math.BigDecimal; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class gnuDynFixed extends anyUndivideable implements DynFixed +public class gnuDynFixed extends UndivideableAny implements DynFixed { /** * Use serialVersionUID for interoperability. diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynStruct.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynStruct.java index b086d6478cc..b15aff3e124 100644 --- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynStruct.java +++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynStruct.java @@ -54,7 +54,7 @@ import org.omg.DynamicAny.DynAny; * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ public class gnuDynStruct - extends abstractRecord + extends RecordAny implements DynStruct, Serializable { /** @@ -89,7 +89,7 @@ public class gnuDynStruct } /** @inheritDoc */ - protected abstractRecord newInstance(TypeCode oType, TypeCode aType, + protected RecordAny newInstance(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory, ORB anOrb) { return new gnuDynStruct(oType, aType, aFactory, anOrb); diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynUnion.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynUnion.java index ad41e24b6ae..ef5aed64512 100644 --- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynUnion.java +++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynUnion.java @@ -62,8 +62,8 @@ import java.io.Serializable; * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ public class gnuDynUnion - extends anyDivideable - implements DynUnion, Serializable, valueChangedListener + extends DivideableAny + implements DynUnion, Serializable, ValueChangeListener { /** * Use serialVersionUID for interoperability. @@ -96,7 +96,7 @@ public class gnuDynUnion discriminator = factory.create_dyn_any_from_type_code(final_type.discriminator_type()); - ((abstractDynAny) discriminator).listener = this; + ((AbstractAny) discriminator).listener = this; if (final_type.default_index() >= 0) set_to_default_member(); @@ -114,7 +114,7 @@ public class gnuDynUnion /* * (non-Javadoc) * - * @see gnu.CORBA.DynAn.anyDivideable#to_any() + * @see gnu.CORBA.DynAn.DivideableAny#to_any() */ public Any to_any() { @@ -171,7 +171,7 @@ public class gnuDynUnion gnuDynUnion other = new gnuDynUnion(official_type, final_type, factory, orb); other.discriminator = discriminator.copy(); - ((abstractDynAny) other.discriminator).listener = other; + ((AbstractAny) other.discriminator).listener = other; if (array.length == 1) { other.array = new DynAny[] { other.discriminator }; diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynValue.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynValue.java index c2db9479785..0c31d4093e2 100644 --- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynValue.java +++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynValue.java @@ -38,6 +38,7 @@ exception statement from your version. */ package gnu.CORBA.DynAn; +import gnu.CORBA.Minor; import gnu.CORBA.Unexpected; import org.omg.CORBA.Any; @@ -66,7 +67,7 @@ import java.io.Serializable; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class gnuDynValue extends abstractRecord implements DynValue, +public class gnuDynValue extends RecordAny implements DynValue, Serializable { /** @@ -243,7 +244,7 @@ public class gnuDynValue extends abstractRecord implements DynValue, /** * Create a new instance. */ - protected abstractRecord newInstance(TypeCode oType, TypeCode aType, + protected RecordAny newInstance(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory, ORB anOrb ) { @@ -301,9 +302,12 @@ public class gnuDynValue extends abstractRecord implements DynValue, ValueFactory factory = ((org.omg.CORBA_2_3.ORB) orb).lookup_value_factory(official_type.id()); if (factory == null) - throw new MARSHAL("Factory for " + official_type.id() + - " not registered." - ); + { + MARSHAL m = new MARSHAL("Factory for " + official_type.id() + + " not registered."); + m.minor = Minor.Factory; + throw m; + } OutputStream out = orb.create_output_stream(); diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynValueBox.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynValueBox.java index 66e18f3b2fe..a13e9fc2c50 100644 --- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynValueBox.java +++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynValueBox.java @@ -39,7 +39,7 @@ exception statement from your version. */ package gnu.CORBA.DynAn; import gnu.CORBA.Unexpected; -import gnu.CORBA.holderFactory; +import gnu.CORBA.HolderLocator; import org.omg.CORBA.Any; import org.omg.CORBA.ORB; @@ -65,7 +65,7 @@ import java.lang.reflect.Field; * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ public class gnuDynValueBox - extends anyDivideable + extends DivideableAny implements DynValueBox, Serializable { /** @@ -208,7 +208,7 @@ public class gnuDynValueBox { try { - Streamable holder = holderFactory.createHolder(content); + Streamable holder = HolderLocator.createHolder(content); Field v = holder.getClass().getField("value"); v.set(holder, s); diff --git a/libjava/classpath/gnu/CORBA/DynAn/valueChangedListener.java b/libjava/classpath/gnu/CORBA/DynAn/valueChangedListener.java deleted file mode 100644 index 94ddffbecf7..00000000000 --- a/libjava/classpath/gnu/CORBA/DynAn/valueChangedListener.java +++ /dev/null @@ -1,50 +0,0 @@ -/* valueChangedListener.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is part of GNU Classpath. - -GNU Classpath is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -GNU Classpath is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU Classpath; see the file COPYING. If not, write to the -Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 USA. - -Linking this library statically or dynamically with other modules is -making a combined work based on this library. Thus, the terms and -conditions of the GNU General Public License cover the whole -combination. - -As a special exception, the copyright holders of this library give you -permission to link this library with independent modules to produce an -executable, regardless of the license terms of these independent -modules, and to copy and distribute the resulting executable under -terms of your choice, provided that you also meet, for each linked -independent module, the terms and conditions of the license of that -module. An independent module is a module which is not derived from -or based on this library. If you modify this library, you may extend -this exception to your version of the library, but you are not -obligated to do so. If you do not wish to do so, delete this -exception statement from your version. */ - - -package gnu.CORBA.DynAn; - -/** - * An interface, able to receive notification about the change of value - * of some DynAny. - * - * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) - */ -public interface valueChangedListener -{ - void changed(); -} \ No newline at end of file -- cgit v1.2.3