OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libjava/] [classpath/] [org/] [omg/] [IOP/] [TaggedProfileHelper.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* TaggedProfileHelper.java --
2
   Copyright (C) 2005 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package org.omg.IOP;
40
 
41
import gnu.CORBA.Minor;
42
import gnu.CORBA.CDR.BufferredCdrInput;
43
import gnu.CORBA.CDR.BufferedCdrOutput;
44
 
45
import org.omg.CORBA.Any;
46
import org.omg.CORBA.BAD_OPERATION;
47
import org.omg.CORBA.MARSHAL;
48
import org.omg.CORBA.ORB;
49
import org.omg.CORBA.StructMember;
50
import org.omg.CORBA.TCKind;
51
import org.omg.CORBA.TypeCode;
52
import org.omg.CORBA.portable.InputStream;
53
import org.omg.CORBA.portable.OutputStream;
54
 
55
import java.io.IOException;
56
 
57
/**
58
 * A helper operations for the structure {@link TaggedProfile}.
59
 *
60
 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
61
 */
62
public abstract class TaggedProfileHelper
63
{
64
  /**
65
   * The cached typecode value, computed only once.
66
   */
67
  private static TypeCode typeCode;
68
 
69
  /**
70
   * Create the TaggedProfile typecode (structure, named "TaggedProfile"). The
71
   * typecode states that the structure contains the following fields: tag,
72
   * profile_data.
73
   */
74
  public static TypeCode type()
75
  {
76
    if (typeCode == null)
77
      {
78
        ORB orb = ORB.init();
79
        StructMember[] members = new StructMember[2];
80
 
81
        TypeCode field;
82
 
83
        field = orb.create_alias_tc("IDL:omg.org/IOP/ProfileId:1.0",
84
                                    "ProfileId",
85
                                    orb.get_primitive_tc(TCKind.tk_ulong));
86
        members[0] = new StructMember("tag", field, null);
87
 
88
        field = orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));
89
        members[1] = new StructMember("profile_data", field, null);
90
        typeCode = orb.create_struct_tc(id(), "TaggedProfile", members);
91
      }
92
    return typeCode;
93
  }
94
 
95
  /**
96
   * Insert the TaggedProfile into the given Any. This method uses the
97
   * TaggedProfileHolder.
98
   *
99
   * @param any the Any to insert into.
100
   * @param that the TaggedProfile to insert.
101
   */
102
  public static void insert(Any any, TaggedProfile that)
103
  {
104
    any.insert_Streamable(new TaggedProfileHolder(that));
105
  }
106
 
107
  /**
108
   * Extract the TaggedProfile from given Any. This method uses the
109
   * TaggedProfileHolder.
110
   *
111
   * @throws BAD_OPERATION if the passed Any does not contain TaggedProfile.
112
   */
113
  public static TaggedProfile extract(Any any)
114
  {
115
    try
116
      {
117
        return ((TaggedProfileHolder) any.extract_Streamable()).value;
118
      }
119
    catch (ClassCastException cex)
120
      {
121
        BAD_OPERATION bad = new BAD_OPERATION("TaggedProfile expected");
122
        bad.minor = Minor.Any;
123
        bad.initCause(cex);
124
        throw bad;
125
      }
126
  }
127
 
128
  /**
129
   * Get the TaggedProfile repository id.
130
   *
131
   * @return "IDL:omg.org/IOP/TaggedProfile:1.0", always.
132
   */
133
  public static String id()
134
  {
135
    return "IDL:omg.org/IOP/TaggedProfile:1.0";
136
  }
137
 
138
  /**
139
   * Read the structure from the CDR intput stream.
140
   *
141
   * @param input a org.omg.CORBA.portable stream to read from.
142
   */
143
  public static TaggedProfile read(InputStream input)
144
  {
145
    TaggedProfile value = new TaggedProfile();
146
    value.tag = input.read_long();
147
 
148
    if (input instanceof BufferredCdrInput)
149
      {
150
        // Highly probable.
151
        value.profile_data = ((BufferredCdrInput) input).read_sequence();
152
      }
153
    else
154
      {
155
        value.profile_data = new byte[input.read_long()];
156
        for (int i0 = 0; i0 < value.profile_data.length; i0++)
157
          value.profile_data[i0] = input.read_octet();
158
      }
159
    return value;
160
  }
161
 
162
  /**
163
   * Write the structure to the CDR output stream.
164
   *
165
   * @param output a org.omg.CORBA.portable stream stream to write into.
166
   * @param value a value to write.
167
   */
168
  public static void write(OutputStream output, TaggedProfile value)
169
  {
170
    output.write_long(value.tag);
171
 
172
    if (output instanceof BufferedCdrOutput)
173
      {
174
        // Highly probable.
175
        output.write_long(value.profile_data.length);
176
        try
177
          {
178
            output.write(value.profile_data);
179
          }
180
        catch (IOException e)
181
          {
182
            MARSHAL m = new MARSHAL();
183
            m.minor = Minor.Encapsulation;
184
            m.initCause(e);
185
            throw m;
186
          }
187
      }
188
    else
189
      {
190
        output.write_long(value.profile_data.length);
191
        for (int i0 = 0; i0 < value.profile_data.length; i0++)
192
          output.write_octet(value.profile_data[i0]);
193
      }
194
  }
195
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.