KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > iiop > rmi > ir > IDLTypeImpl


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.iiop.rmi.ir;
23
24 import org.omg.CORBA.TypeCode JavaDoc;
25 import org.omg.CORBA.TypeCodePackage.BadKind JavaDoc;
26 import org.omg.CORBA.TCKind JavaDoc;
27 import org.omg.CORBA.DefinitionKind JavaDoc;
28
29 /**
30  * IDLType IR object.
31  *
32  * @author <a HREF="mailto:osh@sparre.dk">Ole Husgaard</a>
33  * @version $Revision: 37459 $
34  */

35 abstract class IDLTypeImpl
36    extends IRObjectImpl
37    implements LocalIDLType
38 {
39    // Constants -----------------------------------------------------
40

41    // Attributes ----------------------------------------------------
42

43    // Static --------------------------------------------------------
44

45    // Constructors --------------------------------------------------
46

47    IDLTypeImpl(TypeCode JavaDoc typeCode, DefinitionKind JavaDoc def_kind,
48                RepositoryImpl repository)
49    {
50       super(def_kind, repository);
51
52       this.typeCode = typeCode;
53    }
54
55    // Public --------------------------------------------------------
56

57    // IDLTypeOperations implementation ---------------------------------
58

59    public TypeCode JavaDoc type()
60    {
61       return typeCode;
62    }
63
64    // Package protected ---------------------------------------------
65

66    /**
67     * Return the LocalIDLType for the given TypeCode.
68     */

69    static LocalIDLType getIDLType(TypeCode JavaDoc typeCode, RepositoryImpl repository)
70    {
71       TCKind JavaDoc tcKind = typeCode.kind();
72
73       if (PrimitiveDefImpl.isPrimitiveTCKind(tcKind))
74          return new PrimitiveDefImpl(typeCode, repository);
75
76       if (tcKind == TCKind.tk_sequence)
77          return repository.getSequenceImpl(typeCode);
78
79       if (tcKind == TCKind.tk_value || tcKind == TCKind.tk_value_box ||
80           tcKind == TCKind.tk_alias || tcKind == TCKind.tk_struct ||
81           tcKind == TCKind.tk_union || tcKind == TCKind.tk_enum ||
82           tcKind == TCKind.tk_objref) {
83          try {
84             return (LocalIDLType)repository._lookup_id(typeCode.id());
85          } catch (BadKind JavaDoc ex) {
86             throw new RuntimeException JavaDoc("Bad kind for TypeCode.id()");
87          }
88       }
89
90       throw new RuntimeException JavaDoc("TODO: tcKind=" + tcKind.value());
91    }
92
93    // Protected -----------------------------------------------------
94

95    /**
96     * Return the POA object ID of this IR object.
97     * We delegate to the IR to get a serial number ID.
98     */

99    protected byte[] getObjectId()
100    {
101       return repository.getNextObjectId();
102    }
103
104    // Private -------------------------------------------------------
105

106    /**
107     * My TypeCode.
108     */

109    private TypeCode JavaDoc typeCode;
110
111 }
112
113
Popular Tags