KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > ir > ArrayDef


1 package org.jacorb.ir;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2004 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import org.omg.CORBA.INTF_REPOS JavaDoc;
24 import org.omg.PortableServer.POA JavaDoc;
25 import org.apache.avalon.framework.logger.Logger;
26
27 public class ArrayDef
28     extends IDLType
29     implements org.omg.CORBA.ArrayDefOperations JavaDoc
30 {
31     int size = -1;
32     org.omg.CORBA.TypeCode JavaDoc element_type;
33     org.omg.CORBA.IDLType JavaDoc element_type_def;
34     private org.omg.CORBA.Repository JavaDoc ir;
35
36     private Logger logger;
37     private POA JavaDoc poa;
38
39     public ArrayDef( org.omg.CORBA.TypeCode JavaDoc tc,
40                      org.omg.CORBA.Repository JavaDoc ir,
41                      Logger logger,
42                      POA JavaDoc poa )
43     {
44         this.logger = logger;
45         this.poa = poa;
46
47         if (tc.kind() != org.omg.CORBA.TCKind.tk_array)
48         {
49             throw new INTF_REPOS JavaDoc ("Precondition volation: TypeCode must be of kind array");
50         }
51
52          def_kind = org.omg.CORBA.DefinitionKind.dk_Array;
53          this.ir = ir;
54          type = tc;
55          try
56          {
57              size = tc.length();
58              element_type = tc.content_type();
59              element_type_def = IDLType.create( element_type, ir,
60                                                  this.logger, this.poa);
61          }
62          catch( org.omg.CORBA.TypeCodePackage.BadKind JavaDoc bk )
63          {
64              // cannot happen because of above test
65
}
66
67         if (element_type_def == null)
68         {
69             throw new INTF_REPOS JavaDoc ("Precondition volation: TypeCode must be of kind array");
70         }
71
72         this.logger.debug("New ArrayDef");
73     }
74
75     public int length()
76     {
77         return size;
78     }
79
80     public void length(int a)
81     {
82         size = a;
83     }
84
85     public org.omg.CORBA.TypeCode JavaDoc element_type()
86     {
87         return element_type;
88     }
89
90     public org.omg.CORBA.IDLType JavaDoc element_type_def()
91     {
92         return element_type_def;
93     }
94
95     public void element_type_def(org.omg.CORBA.IDLType JavaDoc a)
96     {
97         element_type_def = a;
98     }
99
100     public void destroy()
101     {
102         type = null;
103         element_type = null;
104         element_type_def = null;
105     }
106     public void define()
107     {
108
109     }
110 }
111
Popular Tags