/[classpath]/classpath/org/omg/IOP/TaggedComponentHelper.java
ViewVC logotype

Diff of /classpath/org/omg/IOP/TaggedComponentHelper.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2.2.1 by gnu_andrew, Tue Aug 2 20:12:47 2005 UTC revision 1.2.2.2 by gnu_andrew, Sat Sep 10 15:32:05 2005 UTC
# Line 40  package org.omg.IOP; Line 40  package org.omg.IOP;
40    
41  import org.omg.CORBA.Any;  import org.omg.CORBA.Any;
42  import org.omg.CORBA.BAD_OPERATION;  import org.omg.CORBA.BAD_OPERATION;
43    import org.omg.CORBA.MARSHAL;
44  import org.omg.CORBA.ORB;  import org.omg.CORBA.ORB;
45  import org.omg.CORBA.StructMember;  import org.omg.CORBA.StructMember;
46  import org.omg.CORBA.TCKind;  import org.omg.CORBA.TCKind;
# Line 47  import org.omg.CORBA.TypeCode; Line 48  import org.omg.CORBA.TypeCode;
48  import org.omg.CORBA.portable.InputStream;  import org.omg.CORBA.portable.InputStream;
49  import org.omg.CORBA.portable.OutputStream;  import org.omg.CORBA.portable.OutputStream;
50    
51    import java.io.IOException;
52    
53  /**  /**
54  * A helper operations for the {@link TaggedComponent}.   * A helper operations for the {@link TaggedComponent}.
55  *   *
56  * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)   * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
57  */   */
58  public abstract class TaggedComponentHelper  public abstract class TaggedComponentHelper
59  {  {
60    /**    /**
# Line 60  public abstract class TaggedComponentHel Line 63  public abstract class TaggedComponentHel
63    private static TypeCode typeCode;    private static TypeCode typeCode;
64    
65    /**    /**
66     * Create the TaggedComponent typecode (structure,     * Create the TaggedComponent typecode (structure, named "TaggedComponent").
67     * named "TaggedComponent").     * The typecode states that the structure contains the following fields: tag,
68     * The typecode states that the structure contains the     * component_data.
    * following fields: tag, component_data.  
69     */     */
70    public static TypeCode type()    public static TypeCode type()
71    {    {
72      if (typeCode == null)      if (typeCode == null)
73        {        {
74          ORB orb = ORB.init();          ORB orb = ORB.init();
75          StructMember[] members = new StructMember[ 2 ];          StructMember[] members = new StructMember[2];
76    
77          TypeCode field;          TypeCode field;
78    
79          field =          field = orb.create_alias_tc("IDL:omg.org/IOP/ComponentId:1.0",
80            orb.create_alias_tc("IDL:omg.org/IOP/ComponentId:1.0", "ComponentId",                                      "ComponentId",
81                                orb.get_primitive_tc(TCKind.tk_ulong)                                      orb.get_primitive_tc(TCKind.tk_ulong));
82                               );          members[0] = new StructMember("tag", field, null);
83          members [ 0 ] = new StructMember("tag", field, null);  
84            field = orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));
85          field =          members[1] = new StructMember("component_data", field, null);
           orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));  
         members [ 1 ] = new StructMember("component_data", field, null);  
86          typeCode = orb.create_struct_tc(id(), "TaggedComponent", members);          typeCode = orb.create_struct_tc(id(), "TaggedComponent", members);
87        }        }
88      return typeCode;      return typeCode;
89    }    }
90    
91    /**    /**
92    * Insert the TaggedComponent into the given Any.     * Insert the TaggedComponent into the given Any. This method uses the
93    * This method uses the TaggedComponentHolder.     * TaggedComponentHolder.
94    *     *
95    * @param any the Any to insert into.     * @param any the Any to insert into.
96    * @param that the TaggedComponent to insert.     * @param that the TaggedComponent to insert.
97    */     */
98    public static void insert(Any any, TaggedComponent that)    public static void insert(Any any, TaggedComponent that)
99    {    {
100      any.insert_Streamable(new TaggedComponentHolder(that));      any.insert_Streamable(new TaggedComponentHolder(that));
101    }    }
102    
103    /**    /**
104     * Extract the TaggedComponent from given Any.     * Extract the TaggedComponent from given Any. This method uses the
105     * This method uses the TaggedComponentHolder.     * TaggedComponentHolder.
106     *     *
107     * @throws BAD_OPERATION if the passed Any does not contain TaggedComponent.     * @throws BAD_OPERATION if the passed Any does not contain TaggedComponent.
108     */     */
# Line 132  public abstract class TaggedComponentHel Line 132  public abstract class TaggedComponentHel
132    
133    /**    /**
134     * Read the structure from the CDR intput stream. Expects the integer     * Read the structure from the CDR intput stream. Expects the integer
135     * identifier of the tag, then the size of the tag data     * identifier of the tag, then the size of the tag data and then the specified
136     * and then the specified number of bytes, representing the data     * number of bytes, representing the data of the tag.
    * of the tag.  
137     *     *
138     * @param input a org.omg.CORBA.portable stream to read from.     * @param input a org.omg.CORBA.portable stream to read from.
139     */     */
# Line 142  public abstract class TaggedComponentHel Line 141  public abstract class TaggedComponentHel
141    {    {
142      TaggedComponent value = new TaggedComponent();      TaggedComponent value = new TaggedComponent();
143      value.tag = input.read_long();      value.tag = input.read_long();
144      value.component_data = new byte[ input.read_long() ];      value.component_data = new byte[input.read_long()];
145      for (int i0 = 0; i0 < value.component_data.length; i0++)      try
146        value.component_data [ i0 ] = input.read_octet();        {
147            input.read(value.component_data);
148          }
149        catch (IOException e)
150          {
151            MARSHAL m = new MARSHAL();
152            m.initCause(e);
153            throw m;
154          }
155      return value;      return value;
156    }    }
157    
158    /**    /**
159     * Write the structure to the CDR output stream.     * Write the structure to the CDR output stream. Writes the integer identifier
160     * Writes the integer identifier of the tag, then the size of the tag data     * of the tag, then the size of the tag data and then the specified number of
161     * and then the specified number of bytes, representing the data     * bytes, representing the data of the tag.
    * of the tag.  
162     *     *
163     * @param output a org.omg.CORBA.portable stream stream to write into.     * @param output a org.omg.CORBA.portable stream stream to write into.
164     * @param value a value to write.     * @param value a value to write.
# Line 161  public abstract class TaggedComponentHel Line 167  public abstract class TaggedComponentHel
167    {    {
168      output.write_long(value.tag);      output.write_long(value.tag);
169      output.write_long(value.component_data.length);      output.write_long(value.component_data.length);
170      for (int i0 = 0; i0 < value.component_data.length; i0++)  
171        output.write_octet(value.component_data [ i0 ]);      try
172          {
173            output.write(value.component_data);
174          }
175        catch (IOException e)
176          {
177            MARSHAL m = new MARSHAL();
178            m.initCause(e);
179            throw m;
180          }
181    }    }
182  }  }

Legend:
Removed from v.1.2.2.1  
changed lines
  Added in v.1.2.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26