2005-06-22 Audrius Meskauskas <[EMAIL PROTECTED]>
* org/omg/IOP/ServiceContextListHolder.java,
org/omg/IOP/ServiceContext.java
org/omg/IOP/ServiceContextHelper.java
org/omg/IOP/ServiceContextHolder.java
org/omg/IOP/ServiceContextListHelper.java
org/omg/IOP/ServiceIdHelper.java: New files.
/* ServiceIdHelper.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., 59 Temple Place, Suite 330, Boston, MA
02111-1307 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 org.omg.IOP;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
/**
* A helper operations for a context service id. A service Id is an integer
* constant and needs no helper, but the one is included to
* to facilitate the automated code handling.
*
* @specnote In this implementation, this class is not in use. Its "logical"
* place is the read/write methods of the ServiceContextHelper, to handle the
* first member (int) of the context record.
*
* @author Audrius Meskauskas, Lithuania ([EMAIL PROTECTED])
*/
public abstract class ServiceIdHelper
{
/**
* Create the ServiceId typecode (alias of CORBA ulong, named "ServiceId".
*/
public static TypeCode type()
{
ORB orb = ORB.init();
return orb.create_alias_tc("IDL:omg.org/IOP/ServiceId:1.0", "ServiceId",
orb.get_primitive_tc(TCKind.tk_ulong)
);
}
/**
* Insert the int into the given Any.
*/
public static void insert(Any any, int that)
{
any.insert_ulong(that);
}
/**
* Extract the int from given Any.
* This method uses the ServiceContextHolder.
*
* @throws BAD_OPERATION if the passed Any does not contain int.
*/
public static int extract(Any any)
{
return any.extract_ulong();
}
/**
* Get the int repository id.
*
* @return "IDL:omg.org/IOP/ServiceId:1.0", always.
*/
public static String id()
{
return "IDL:omg.org/IOP/ServiceId:1.0";
}
/**
* Read the ServiceId from the CDR intput stream.
*
* @param input a org.omg.CORBA.portable stream to read from.
*/
public static int read(InputStream input)
{
return input.read_ulong();
}
/**
* Write the ServiceId to the CDR output stream.
*
* @param output a org.omg.CORBA.portable stream stream to write into.
* @param value a value to write.
*/
public static void write(OutputStream output, int value)
{
output.write_ulong(value);
}
}/* ServiceContext.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., 59 Temple Place, Suite 330, Boston, MA
02111-1307 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 org.omg.IOP;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
/**
* The ServiceContext structure contains the service data, being passed in the
* CORBA message. For instance, then passing the wide characters, it is
* mandatory to include the service context, defining the used encoding.
* The contexts are recognised by they integer indentifier.
* In this class, the content of the context is represented as an abstract
* array of bytes.
*
* @see ServiceContextHolder
* @see ServiceContextHelper
*
* @author Audrius Meskauskas, Lithuania ([EMAIL PROTECTED])
*/
public class ServiceContext
implements IDLEntity, Serializable
{
/**
* Use serialVersionUID (v1.4) for interoperability.
*/
private static final long serialVersionUID = -2232391417465261379L;
/**
* 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;
/**
* Create the unitialised instance, assigning to
* the all fields java default values.
*/
public ServiceContext()
{
}
/**
* Create the instance, initialising the fields to the given values.
*/
public ServiceContext(int a_context_id, byte[] a_context_data)
{
this.context_id = a_context_id;
this.context_data = a_context_data;
}
}/* ServiceContextHelper.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., 59 Temple Place, Suite 330, Boston, MA
02111-1307 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 org.omg.IOP;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
/**
* A helper operations for the structure [EMAIL PROTECTED] ServiceContext}.
*
* @author Audrius Meskauskas, Lithuania ([EMAIL PROTECTED])
*/
public abstract class ServiceContextHelper
{
/**
* The cached typecode value, computed only once.
*/
private static TypeCode typeCode;
/**
* Create the ServiceContext typecode (structure,
* named "ServiceContext").
* The typecode states that the structure contains the
* following fields: context_id, context_data.
*/
public static TypeCode type()
{
if (typeCode == null)
{
ORB orb = ORB.init();
StructMember[] members = new StructMember[ 2 ];
TypeCode field;
field =
orb.create_alias_tc("IDL:omg.org/IOP/ServiceId:1.0", "ServiceId",
orb.get_primitive_tc(TCKind.tk_ulong)
);
members [ 0 ] = new StructMember("context_id", field, null);
field =
orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));
members [ 1 ] = new StructMember("context_data", field, null);
typeCode = orb.create_struct_tc(id(), "ServiceContext", members);
}
return typeCode;
}
/**
* Insert the ServiceContext into the given Any.
* This method uses the ServiceContextHolder.
*
* @param any the Any to insert into.
* @param that the ServiceContext to insert.
*/
public static void insert(Any any, ServiceContext that)
{
any.insert_Streamable(new ServiceContextHolder(that));
}
/**
* Extract the ServiceContext from given Any.
* This method uses the ServiceContextHolder.
*
* @throws BAD_OPERATION if the passed Any does not contain ServiceContext.
*/
public static ServiceContext extract(Any any)
{
try
{
return ((ServiceContextHolder) any.extract_Streamable()).value;
}
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("ServiceContext expected");
bad.initCause(cex);
throw bad;
}
}
/**
* Get the ServiceContext repository id.
*
* @return "IDL:omg.org/IOP/ServiceContext:1.0", always.
*/
public static String id()
{
return "IDL:omg.org/IOP/ServiceContext:1.0";
}
/**
* Read the context from the CDR intput stream (first id, then
* data as a flexible length byte sequence).
*
* @param input a org.omg.CORBA.portable stream to read from.
*/
public static ServiceContext read(InputStream input)
{
ServiceContext value = new ServiceContext();
value.context_id = input.read_long();
value.context_data = new byte[ input.read_long() ];
for (int i0 = 0; i0 < value.context_data.length; i0++)
value.context_data [ i0 ] = input.read_octet();
return value;
}
/**
* Write the context to the CDR output stream (first id, then
* data as a flexible length byte sequence).
*
* @param output a org.omg.CORBA.portable stream stream to write into.
* @param value a value to write.
*/
public static void write(OutputStream output, ServiceContext value)
{
output.write_long(value.context_id);
output.write_long(value.context_data.length);
for (int i0 = 0; i0 < value.context_data.length; i0++)
output.write_octet(value.context_data [ i0 ]);
}
}/* ServiceContextHolder.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., 59 Temple Place, Suite 330, Boston, MA
02111-1307 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 org.omg.IOP;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
/**
* A holder for the structure [EMAIL PROTECTED] ServiceContext}.
*
* @author Audrius Meskauskas, Lithuania ([EMAIL PROTECTED])
*/
public class ServiceContextHolder
implements Streamable
{
/**
* The stored ServiceContext value.
*/
public ServiceContext value;
/**
* Create the unitialised instance, leaving the value field
* with default <code>null</code> value.
*/
public ServiceContextHolder()
{
}
/**
* Create the initialised instance.
* @param initialValue the value that will be assigned to
* the <code>value</code> field.
*/
public ServiceContextHolder(ServiceContext initialValue)
{
value = initialValue;
}
/**
* Fill in the [EMAIL PROTECTED] value} by data from the CDR stream.
*
* @param input the org.omg.CORBA.portable stream to read.
*/
public void _read(InputStream input)
{
value = ServiceContextHelper.read(input);
}
/**
* Write the stored value into the CDR stream.
*
* @param output the org.omg.CORBA.portable stream to write.
*/
public void _write(OutputStream output)
{
ServiceContextHelper.write(output, value);
}
/**
* Get the typecode of the ServiceContext.
*/
public org.omg.CORBA.TypeCode _type()
{
return ServiceContextHelper.type();
}
}/* ServiceContextListHelper.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., 59 Temple Place, Suite 330, Boston, MA
02111-1307 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 org.omg.IOP;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
/**
* The helper operations for the
* CORBA object [EMAIL PROTECTED] ServiceContext[]}.
*
* @author Audrius Meskauskas, Lithuania ([EMAIL PROTECTED])
*/
public abstract class ServiceContextListHelper
{
/**
* The cached [EMAIL PROTECTED] ServiceContext[]} typecode, computed once.
*/
private static TypeCode typeCode;
/**
* Get the type code of the [EMAIL PROTECTED] ServiceContext[]}.
*/
public static TypeCode type()
{
if (typeCode == null)
typeCode = ORB.init().create_interface_tc(id(), "ServiceContextList");
return typeCode;
}
/**
* Insert the ServiceContext[] into the given Any.
*
* @param any the Any to insert into.
* @param that the ServiceContext[] to insert.
*/
public static void insert(Any any, ServiceContext[] that)
{
any.insert_Streamable(new ServiceContextListHolder(that));
}
/**
* Extract the ServiceContext[] from given Any.
*
* @throws BAD_OPERATION if the passed Any does not contain ServiceContext[].
*/
public static ServiceContext[] extract(Any any)
{
try
{
ServiceContextListHolder holder =
(ServiceContextListHolder) any.extract_Streamable();
return holder.value;
}
catch (ClassCastException ex)
{
throw new BAD_OPERATION("ServiceContext[] expected.");
}
}
/**
* Get the ServiceContext[] repository id.
*
* @return "IDL:omg.org/IOP/ServiceContextList:1.0", always.
*/
public static String id()
{
return "IDL:omg.org/IOP/ServiceContextList:1.0";
}
/**
* Read the ServiceContext[] from the CDR intput stream as a flexible lenth
* sequence.
*
* @param input a org.omg.CORBA.portable stream to read from.
*/
public static ServiceContext[] read(InputStream input)
{
ServiceContext[] value = new ServiceContext[ input.read_long() ];
for (int i = 0; i < value.length; i++)
{
value [ i ] = ServiceContextHelper.read(input);
}
return value;
}
/**
* Write the ServiceContext[] to the CDR output stream as a flexible length
* sequence.
*
* @param output a org.omg.CORBA.portable stream stream to write into.
* @param value a value to write.
*/
public static void write(OutputStream output, ServiceContext[] value)
{
output.write_long(value.length);
for (int i = 0; i < value.length; i++)
{
ServiceContextHelper.write(output, value [ i ]);
}
}
}/* ServiceContextListHolder.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., 59 Temple Place, Suite 330, Boston, MA
02111-1307 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 org.omg.IOP;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
/**
* A holder for the sequence of the [EMAIL PROTECTED] ServiceContext}s.
*
* @author Audrius Meskauskas, Lithuania ([EMAIL PROTECTED])
*/
public class ServiceContextListHolder
implements Streamable
{
/**
* The stored ServiceContext[] value.
*/
public ServiceContext[] value;
/**
* Create the unitialised instance, leaving the value field
* with default <code>null</code> value.
*/
public ServiceContextListHolder()
{
}
/**
* Create the initialised instance.
* @param initialValue the value that will be assigned to
* the <code>value</code> field.
*/
public ServiceContextListHolder(ServiceContext[] initialValue)
{
value = initialValue;
}
/**
* Fill in the [EMAIL PROTECTED] value} by data from the CDR stream.
*
* @param input the org.omg.CORBA.portable stream to read.
*/
public void _read(InputStream input)
{
value = ServiceContextListHelper.read(input);
}
/**
* Write the stored value into the CDR stream.
*
* @param output the org.omg.CORBA.portable stream to write.
*/
public void _write(OutputStream output)
{
ServiceContextListHelper.write(output, value);
}
/**
* Get the typecode of the ServiceContext[].
*/
public org.omg.CORBA.TypeCode _type()
{
return ServiceContextListHelper.type();
}
}_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches