1 /* RecordTypeCode.java --
2 Copyright (C) 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
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)
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.
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
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
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. */
39 package gnu.CORBA.typecodes;
41 import gnu.CORBA.CorbaList;
43 import org.omg.CORBA.Any;
44 import org.omg.CORBA.StructMember;
45 import org.omg.CORBA.TCKind;
46 import org.omg.CORBA.TypeCode;
47 import org.omg.CORBA.TypeCodePackage.BadKind;
48 import org.omg.CORBA.TypeCodePackage.Bounds;
49 import org.omg.CORBA.UnionMember;
50 import org.omg.CORBA.ValueMember;
53 * The type code that also has the member property getters
56 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
58 public class RecordTypeCode
59 extends GeneralTypeCode
62 * Use serialVersionUID for interoperability.
64 private static final long serialVersionUID = 1;
67 * The individual field of the record.
69 public static class Field
87 * The record visibility.
89 public int visibility = UNSET;
93 * The members of this data structure.
95 protected CorbaList members = new CorbaList();
96 private TypeCode discriminator_type;
97 private int default_index = UNSET;
100 * Creates the type code of the given kind.
102 public RecordTypeCode(TCKind a_kind)
108 * Set the default index.
110 public void setDefaultIndex(int a_default_index)
112 this.default_index = a_default_index;
116 * Set the discriminator type.
118 public void setDiscriminator_type(TypeCode a_discriminator_type)
120 this.discriminator_type = a_discriminator_type;
123 public Field getField(int p)
125 return (Field) members.get(p);
128 public void add(Field field)
134 * Adds a new field, taking values from the passed
135 * {@link StructMember}.
137 public void add(StructMember m)
145 * Adds a new field, taking values from the passed
146 * {@link ValueMember}.
148 public void add(ValueMember m)
153 f.visibility = m.access;
158 * Adds a new field, taking values from the passed
159 * {@link UnionMember}.
161 public void add(UnionMember m)
169 public int default_index()
172 if (default_index != UNSET)
173 return default_index;
177 public TypeCode discriminator_type()
180 if (discriminator_type != null)
181 return discriminator_type;
186 * Creates, adds and returns new field.
190 Field f = new Field();
196 public int member_count()
198 return members.size();
202 public Any member_label(int index)
203 throws BadKind, Bounds
205 Field f = getField(index);
215 public String member_name(int index)
218 Field f = getField(index);
228 public TypeCode member_type(int index)
229 throws BadKind, Bounds
231 Field f = getField(index);
241 public short member_visibility(int index)
242 throws BadKind, Bounds
244 Field f = getField(index);
245 if (f.visibility != UNSET)
247 return (short) f.visibility;