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/] [CORBA/] [ServiceDetailHelper.java] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 jlechner
/* ServiceDetailHelper.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.CORBA;
40
 
41
import gnu.CORBA.Minor;
42
import gnu.CORBA.ServiceDetailHolder;
43
 
44
import org.omg.CORBA.portable.InputStream;
45
import org.omg.CORBA.portable.OutputStream;
46
 
47
/**
48
 * The helper operations on the Service Detail.
49
 *
50
 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
51
 */
52
public abstract class ServiceDetailHelper
53
{
54
  /**
55
   * The service detail repository id.
56
   */
57
  private static String _id = "IDL:omg.org/CORBA/ServiceDetail:1.0";
58
 
59
  /**
60
   * The cached typecode value, computed once.
61
   */
62
  private static TypeCode typeCode;
63
 
64
  /**
65
   * Extract the service detail info from the given {@link Any}
66
   *
67
   * @param a the Any to extract from.
68
   *
69
   * @return the extracted detail.
70
   *
71
   * @throws BAD_OPERATION if the parameter holds something different
72
   * from the ServiceDetail.
73
   */
74
  public static ServiceDetail extract(Any a)
75
  {
76
    try
77
      {
78
        return ((ServiceDetailHolder) a.extract_Streamable()).value;
79
      }
80
    catch (ClassCastException ex)
81
      {
82
        BAD_OPERATION bad = new BAD_OPERATION();
83
        bad.initCause(ex);
84
        bad.minor = Minor.Any;
85
        throw bad;
86
      }
87
  }
88
 
89
  /**
90
   * Get the service detail repository id.
91
   *
92
   * @return the service detail repository id,
93
   * <code>IDL:omg.org/CORBA/ServiceDetail:1.0</code>, always.
94
   */
95
  public static String id()
96
  {
97
    return _id;
98
  }
99
 
100
  /**
101
   * Insert the service detail into the given {@link Any}.
102
   *
103
   * @param a the Any to insert into.
104
   *
105
   * @param that the detail to insert.
106
   */
107
  public static void insert(Any a, ServiceDetail that)
108
  {
109
    a.insert_Streamable(new ServiceDetailHolder(that));
110
  }
111
 
112
  /**
113
   * Read the service detail information from the given CDR
114
   * intput stream. First reads the type, then the flexible
115
   * length byte sequence.
116
   *
117
   * @param istream a stram to read from.
118
   *
119
   * @return the loaded service detail.
120
   */
121
  public static ServiceDetail read(InputStream istream)
122
  {
123
    ServiceDetail value = new ServiceDetail();
124
    value.service_detail_type = istream.read_ulong();
125
 
126
    int l = istream.read_long();
127
    value.service_detail = new byte[ l ];
128
    istream.read_octet_array(value.service_detail, 0, l);
129
    return value;
130
  }
131
 
132
  /**
133
   * Get the typecode of the service detail, assuming to be it
134
   * a structure with the two fields.
135
   *
136
   * @return the newly created or cached typecode value.
137
   */
138
  public static TypeCode type()
139
  {
140
    if (typeCode == null)
141
      {
142
        ORB orb = ORB.init();
143
 
144
        StructMember[] members = new StructMember[ 2 ];
145
 
146
        TypeCode type =
147
          orb.create_alias_tc(_id, "ServiceDetailType",
148
            orb.get_primitive_tc(TCKind.tk_ulong)
149
          );
150
        members [ 0 ] = new StructMember("service_detail_type", type, null);
151
 
152
        TypeCode data =
153
          orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet));
154
        members [ 1 ] = new StructMember("service_detail", data, null);
155
 
156
        typeCode = orb.create_struct_tc(id(), "ServiceDetail", members);
157
      }
158
    return typeCode;
159
  }
160
 
161
  /**
162
   * Write the service detail data to the given CDR output stream.
163
   * Writes the detail type first, then the detail type data
164
   * as the variable length byte sequence.
165
   *
166
   * @param ostream a stream to write into.
167
   * @param value a value to write.
168
   */
169
  public static void write(OutputStream ostream, ServiceDetail value)
170
  {
171
    ostream.write_ulong(value.service_detail_type);
172
    ostream.write_long(value.service_detail.length);
173
    ostream.write_octet_array(value.service_detail, 0,
174
      value.service_detail.length
175
    );
176
  }
177
}

powered by: WebSVN 2.1.0

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