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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [gnu/] [CORBA/] [HolderLocator.java] - Blame information for rev 769

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 769 jeremybenn
/* HolderLocator.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 gnu.CORBA;
40
 
41
import org.omg.CORBA.AnyHolder;
42
import org.omg.CORBA.AnySeqHolder;
43
import org.omg.CORBA.BooleanHolder;
44
import org.omg.CORBA.BooleanSeqHolder;
45
import org.omg.CORBA.CharHolder;
46
import org.omg.CORBA.CharSeqHolder;
47
import org.omg.CORBA.DoubleHolder;
48
import org.omg.CORBA.DoubleSeqHolder;
49
import org.omg.CORBA.FixedHolder;
50
import org.omg.CORBA.FloatHolder;
51
import org.omg.CORBA.FloatSeqHolder;
52
import org.omg.CORBA.IntHolder;
53
import org.omg.CORBA.LongHolder;
54
import org.omg.CORBA.LongLongSeqHolder;
55
import org.omg.CORBA.LongSeqHolder;
56
import org.omg.CORBA.OctetSeqHolder;
57
import org.omg.CORBA.PrincipalHolder;
58
import org.omg.CORBA.ShortHolder;
59
import org.omg.CORBA.ShortSeqHolder;
60
import org.omg.CORBA.StringHolder;
61
import org.omg.CORBA.StringSeqHolder;
62
import org.omg.CORBA.TCKind;
63
import org.omg.CORBA.TypeCode;
64
import org.omg.CORBA.TypeCodeHolder;
65
import org.omg.CORBA.ULongLongSeqHolder;
66
import org.omg.CORBA.ULongSeqHolder;
67
import org.omg.CORBA.UShortSeqHolder;
68
import org.omg.CORBA.WCharSeqHolder;
69
import org.omg.CORBA.WStringSeqHolder;
70
import org.omg.CORBA.portable.Streamable;
71
import org.omg.CORBA.ObjectHolder;
72
 
73
/**
74
 * Creates the suitable holder for storing the value of the given final_type.
75
 *
76
 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
77
 */
78
public class HolderLocator
79
{
80
  /**
81
   * The array, sufficiently large to use any {@link TCKind}._tk* constant as
82
   * an index.
83
   */
84
  private static final Class[] holders;
85
 
86
  private static final Class[] seqHolders;
87
 
88
  static
89
    {
90
      holders = new Class[32];
91
      holders[TCKind._tk_Principal] = PrincipalHolder.class;
92
      holders[TCKind._tk_TypeCode] = TypeCodeHolder.class;
93
      holders[TCKind._tk_any] = AnyHolder.class;
94
      holders[TCKind._tk_boolean] = BooleanHolder.class;
95
      holders[TCKind._tk_char] = CharHolder.class;
96
      holders[TCKind._tk_double] = DoubleHolder.class;
97
      holders[TCKind._tk_float] = FloatHolder.class;
98
      holders[TCKind._tk_fixed] = FixedHolder.class;
99
      holders[TCKind._tk_long] = IntHolder.class;
100
      holders[TCKind._tk_longdouble] = DoubleHolder.class;
101
      holders[TCKind._tk_longlong] = LongHolder.class;
102
      holders[TCKind._tk_octet] = OctetHolder.class;
103
      holders[TCKind._tk_short] = ShortHolder.class;
104
      holders[TCKind._tk_string] = StringHolder.class;
105
      holders[TCKind._tk_ulong] = IntHolder.class;
106
      holders[TCKind._tk_ulonglong] = LongHolder.class;
107
      holders[TCKind._tk_ushort] = ShortHolder.class;
108
      holders[TCKind._tk_wchar] = WCharHolder.class;
109
      holders[TCKind._tk_wstring] = WStringHolder.class;
110
      holders[TCKind._tk_objref] = ObjectHolder.class;
111
 
112
      seqHolders = new Class[32];
113
 
114
      seqHolders[TCKind._tk_ulonglong] = ULongLongSeqHolder.class;
115
      seqHolders[TCKind._tk_short] = ShortSeqHolder.class;
116
      seqHolders[TCKind._tk_octet] = OctetSeqHolder.class;
117
      seqHolders[TCKind._tk_any] = AnySeqHolder.class;
118
      seqHolders[TCKind._tk_long] = LongSeqHolder.class;
119
      seqHolders[TCKind._tk_longlong] = LongLongSeqHolder.class;
120
      seqHolders[TCKind._tk_float] = FloatSeqHolder.class;
121
      seqHolders[TCKind._tk_double] = DoubleSeqHolder.class;
122
      seqHolders[TCKind._tk_char] = CharSeqHolder.class;
123
      seqHolders[TCKind._tk_boolean] = BooleanSeqHolder.class;
124
      seqHolders[TCKind._tk_wchar] = WCharSeqHolder.class;
125
      seqHolders[TCKind._tk_ushort] = UShortSeqHolder.class;
126
      seqHolders[TCKind._tk_ulong] = ULongSeqHolder.class;
127
      seqHolders[TCKind._tk_string] = StringSeqHolder.class;
128
      seqHolders[TCKind._tk_wstring] = WStringSeqHolder.class;
129
    }
130
 
131
  /**
132
   * Create a holder for storing the value of the given built-in final_type. This
133
   * function returns the defined holders for the built-in primitive types and
134
   * they sequences.
135
   *
136
   * @param t the typecode
137
   *
138
   * @return an instance of the corresponding built-in holder of null if no such
139
   * is defined for this final_type. The holder is created with a parameterless
140
   * constructor.
141
   */
142
  public static Streamable createHolder(TypeCode t)
143
  {
144
    try
145
      {
146
        int kind = t.kind().value();
147
        int componentKind;
148
 
149
        Streamable holder = null;
150
 
151
        if (kind < holders.length && holders[kind] != null)
152
          holder = (Streamable) holders[kind].newInstance();
153
 
154
        if (holder != null)
155
          return holder;
156
 
157
        switch (kind)
158
          {
159
          case TCKind._tk_sequence:
160
            componentKind = t.content_type().kind().value();
161
            if (componentKind < seqHolders.length)
162
              return (Streamable) seqHolders[componentKind].newInstance();
163
            break;
164
 
165
          default:
166
            break;
167
          }
168
      }
169
    catch (Exception ex)
170
      {
171
        throw new Unexpected(ex);
172
      }
173
 
174
    try
175
      {
176
        Object ox = ObjectCreator.createObject(t.id(), "Holder");
177
        return (Streamable) ox;
178
      }
179
    catch (Exception ex)
180
      {
181
        return null;
182
      }
183
  }
184
}

powered by: WebSVN 2.1.0

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