diff options
| author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-09-23 21:31:04 +0000 |
|---|---|---|
| committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-09-23 21:31:04 +0000 |
| commit | 947b8814056ea2fba6bbcfab86591f74bffc0311 (patch) | |
| tree | 3ca4b2e68dc14c3128b9c781d23f1d0b1f2bee49 /libjava/classpath/gnu/CORBA/GIOP/ServiceContext.java | |
| parent | 49792907376493f0939563eb0219b96a48f1ae3b (diff) | |
| download | ppe42-gcc-947b8814056ea2fba6bbcfab86591f74bffc0311.tar.gz ppe42-gcc-947b8814056ea2fba6bbcfab86591f74bffc0311.zip | |
Imported Classpath 0.18.
* sources.am, Makefile.in: Updated.
* Makefile.am (nat_source_files): Removed natProxy.cc.
* java/lang/reflect/natProxy.cc: Removed.
* gnu/classpath/jdwp/VMFrame.java,
gnu/classpath/jdwp/VMIdManager.java,
gnu/classpath/jdwp/VMVirtualMachine.java,
java/lang/reflect/VMProxy.java: New files.
2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com>
* scripts/makemake.tcl (verbose): Add gnu/java/awt/peer/qt to BC
list.
2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/net/DefaultContentHandlerFactory.java (getContent):
Remove ClasspathToolkit references.
2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/awt/xlib/XCanvasPeer.java: Add new peer methods.
* gnu/awt/xlib/XFramePeer.java: Likewise.
* gnu/awt/xlib/XGraphicsConfiguration.java: Likewise.
2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com>
* Makefile.am (libgcjawt_la_SOURCES): Remove jawt.c. Add
classpath/native/jawt/jawt.c.
* Makefile.in: Regenerate.
* jawt.c: Remove file.
* include/Makefile.am (tool_include__HEADERS): Remove jawt.h and
jawt_md.h. Add ../classpath/include/jawt.h and
../classpath/include/jawt_md.h.
* include/Makefile.in: Regenerate.
* include/jawt.h: Regenerate.
* include/jawt_md.h: Regenerate.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104586 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/CORBA/GIOP/ServiceContext.java')
| -rw-r--r-- | libjava/classpath/gnu/CORBA/GIOP/ServiceContext.java | 138 |
1 files changed, 128 insertions, 10 deletions
diff --git a/libjava/classpath/gnu/CORBA/GIOP/ServiceContext.java b/libjava/classpath/gnu/CORBA/GIOP/ServiceContext.java index 7e44bdcea77..29a8ea8ac77 100644 --- a/libjava/classpath/gnu/CORBA/GIOP/ServiceContext.java +++ b/libjava/classpath/gnu/CORBA/GIOP/ServiceContext.java @@ -41,7 +41,9 @@ package gnu.CORBA.GIOP; import gnu.CORBA.CDR.cdrInput; import gnu.CORBA.CDR.cdrOutput; - +import org.omg.CORBA.BAD_INV_ORDER; +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.CompletionStatus; import org.omg.CORBA.portable.IDLEntity; /** @@ -53,16 +55,40 @@ public class ServiceContext implements IDLEntity { /** - * The context data. + * Use serialVersionUID for interoperability. */ - public byte[] context_data; + private static final long serialVersionUID = 1; /** - * The context id. + * The context id (for instance, 0x1 for code sets context). At the moment of + * writing, the OMG defines 16 standard values and provides rules to register + * the vendor specific context ids. The range 0-4095 is reserved for the + * future standard OMG contexts. */ public int context_id; /** + * The context_data. + */ + public byte[] context_data; + + /** + * Crete unitialised instance. + */ + public ServiceContext() + { + } + + /** + * Create from omg context. + */ + public ServiceContext(org.omg.IOP.ServiceContext from) + { + context_id = from.context_id; + context_data = from.context_data; + } + + /** * Read the context values from the stream. * * @param istream a stream to read from. @@ -73,13 +99,13 @@ public class ServiceContext switch (id) { - case cxCodeSet.ID : + case cxCodeSet.ID: cxCodeSet codeset = new cxCodeSet(); codeset.readContext(istream); return codeset; - default : + default: ServiceContext ctx = new ServiceContext(); ctx.context_id = id; @@ -94,9 +120,9 @@ public class ServiceContext public static ServiceContext[] readSequence(cdrInput istream) { int size = istream.read_long(); - ServiceContext[] value = new gnu.CORBA.GIOP.ServiceContext[ size ]; + ServiceContext[] value = new gnu.CORBA.GIOP.ServiceContext[size]; for (int i = 0; i < value.length; i++) - value [ i ] = read(istream); + value[i] = read(istream); return value; } @@ -118,7 +144,99 @@ public class ServiceContext { ostream.write_long(value.length); for (int i = 0; i < value.length; i++) - value [ i ].write(ostream); + value[i].write(ostream); + } + + /** + * Add context to the given array of contexts. + */ + public static void add(org.omg.IOP.ServiceContext[] cx, + org.omg.IOP.ServiceContext service_context, boolean replace) + { + int exists = -1; + + for (int i = 0; i < cx.length; i++) + if (cx[i].context_id == service_context.context_id) + exists = i; + + if (exists < 0) + { + // Add context. + org.omg.IOP.ServiceContext[] n = new org.omg.IOP.ServiceContext[cx.length + 1]; + for (int i = 0; i < cx.length; i++) + n[i] = cx[i]; + n[cx.length] = service_context; + } + else + { + // Replace context. + if (!replace) + throw new BAD_INV_ORDER("Repetetive setting of the context " + + service_context.context_id, 15, + CompletionStatus.COMPLETED_NO); + else + cx[exists] = service_context; + } + } + + /** + * Add context to the given array of contexts. + */ + public static ServiceContext[] add(ServiceContext[] cx, + org.omg.IOP.ServiceContext service_context, boolean replace) + { + int exists = -1; + + for (int i = 0; i < cx.length; i++) + if (cx[i].context_id == service_context.context_id) + exists = i; + + if (exists < 0) + { + // Add context. + ServiceContext[] n = new ServiceContext[cx.length + 1]; + for (int i = 0; i < cx.length; i++) + n[i] = cx[i]; + n[cx.length] = new ServiceContext(service_context); + return n; + } + else + { + // Replace context. + if (!replace) + throw new BAD_INV_ORDER("Repetetive setting of the context " + + service_context.context_id, 15, + CompletionStatus.COMPLETED_NO); + else + cx[exists] = new ServiceContext(service_context); + return cx; + } + } + + + /** + * Find context with the given name in the context array. + */ + public static org.omg.IOP.ServiceContext findContext(int ctx_name, + org.omg.IOP.ServiceContext[] cx) + { + for (int i = 0; i < cx.length; i++) + if (cx[i].context_id == ctx_name) + return cx[i]; + throw new BAD_PARAM("No context with id " + ctx_name); + } + + /** + * Find context with the given name in the context array, + * converting into org.omg.IOP.ServiceContext. + */ + public static org.omg.IOP.ServiceContext findContext(int ctx_name, + ServiceContext[] cx) + { + for (int i = 0; i < cx.length; i++) + if (cx[i].context_id == ctx_name) + return new org.omg.IOP.ServiceContext(ctx_name, cx[i].context_data); + throw new BAD_PARAM("No context with id " + ctx_name); } /** @@ -126,6 +244,6 @@ public class ServiceContext */ public String toString() { - return "ctx "+context_id+", size "+context_data.length; + return "ctx " + context_id + ", size " + context_data.length; } } |

