KickJava   Java API By Example, From Geeks To Geeks.

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


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.TCKind JavaDoc;
26 import org.omg.CORBA.IRObject JavaDoc;
27 import org.omg.CORBA.DefinitionKind JavaDoc;
28 import org.omg.CORBA.PrimitiveKind JavaDoc;
29 import org.omg.CORBA.PrimitiveDef JavaDoc;
30 import org.omg.CORBA.PrimitiveDefOperations JavaDoc;
31 import org.omg.CORBA.PrimitiveDefPOATie;
32
33 import java.util.Map JavaDoc;
34 import java.util.HashMap JavaDoc;
35
36 /**
37  * PrimitiveDef IR object.
38  *
39  * @author <a HREF="mailto:osh@sparre.dk">Ole Husgaard</a>
40  * @version $Revision: 37459 $
41  */

42 class PrimitiveDefImpl
43    extends IDLTypeImpl
44    implements PrimitiveDefOperations JavaDoc, LocalIDLType
45 {
46    // Constants -----------------------------------------------------
47

48    // Attributes ----------------------------------------------------
49

50    // Static --------------------------------------------------------
51

52    // Constructors --------------------------------------------------
53

54    PrimitiveDefImpl(TypeCode JavaDoc typeCode,
55                     RepositoryImpl repository)
56    {
57       super(typeCode, DefinitionKind.dk_Primitive, repository);
58    }
59
60    // Public --------------------------------------------------------
61

62
63    // LocalIRObject implementation ---------------------------------
64

65    public IRObject JavaDoc getReference()
66    {
67       if (ref == null) {
68          ref = org.omg.CORBA.PrimitiveDefHelper.narrow(
69                             servantToReference(new PrimitiveDefPOATie(this)) );
70       }
71       return ref;
72    }
73
74
75    // PrimitiveDefOperations implementation ----------------------------
76

77    public PrimitiveKind JavaDoc kind()
78    {
79       return (PrimitiveKind JavaDoc)primitiveTCKindMap.get(type().kind());
80    }
81
82    // Package protected ---------------------------------------------
83

84    static boolean isPrimitiveTCKind(TCKind JavaDoc tcKind)
85    {
86       return primitiveTCKindMap.containsKey(tcKind);
87    }
88
89    // Private -------------------------------------------------------
90

91    /**
92     * My CORBA reference.
93     */

94    private PrimitiveDef JavaDoc ref = null;
95
96    /**
97     * Maps TCKind to PrimitiveKind.
98     */

99    private static Map JavaDoc primitiveTCKindMap;
100
101    static {
102       // Create and initialize the map
103
primitiveTCKindMap = new HashMap JavaDoc();
104       primitiveTCKindMap.put(TCKind.tk_null, PrimitiveKind.pk_null);
105       primitiveTCKindMap.put(TCKind.tk_void, PrimitiveKind.pk_void);
106       primitiveTCKindMap.put(TCKind.tk_short, PrimitiveKind.pk_short);
107       primitiveTCKindMap.put(TCKind.tk_long, PrimitiveKind.pk_long);
108       primitiveTCKindMap.put(TCKind.tk_ushort, PrimitiveKind.pk_ushort);
109       primitiveTCKindMap.put(TCKind.tk_ulong, PrimitiveKind.pk_ulong);
110       primitiveTCKindMap.put(TCKind.tk_float, PrimitiveKind.pk_float);
111       primitiveTCKindMap.put(TCKind.tk_double, PrimitiveKind.pk_double);
112       primitiveTCKindMap.put(TCKind.tk_boolean, PrimitiveKind.pk_boolean);
113       primitiveTCKindMap.put(TCKind.tk_char, PrimitiveKind.pk_char);
114       primitiveTCKindMap.put(TCKind.tk_octet, PrimitiveKind.pk_octet);
115       primitiveTCKindMap.put(TCKind.tk_any, PrimitiveKind.pk_any);
116       primitiveTCKindMap.put(TCKind.tk_TypeCode, PrimitiveKind.pk_TypeCode);
117       primitiveTCKindMap.put(TCKind.tk_Principal, PrimitiveKind.pk_Principal);
118       primitiveTCKindMap.put(TCKind.tk_objref, PrimitiveKind.pk_objref);
119       primitiveTCKindMap.put(TCKind.tk_string, PrimitiveKind.pk_string);
120       primitiveTCKindMap.put(TCKind.tk_longlong, PrimitiveKind.pk_longlong);
121       primitiveTCKindMap.put(TCKind.tk_ulonglong, PrimitiveKind.pk_ulonglong);
122       primitiveTCKindMap.put(TCKind.tk_longdouble, PrimitiveKind.pk_longdouble);
123       primitiveTCKindMap.put(TCKind.tk_wchar, PrimitiveKind.pk_wchar);
124       primitiveTCKindMap.put(TCKind.tk_wstring, PrimitiveKind.pk_wstring);
125    }
126
127 }
128
129
Popular Tags