KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > idl > ShortType


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

20
21 package org.jacorb.idl;
22
23 /**
24  * @author Gerald Brose
25  * @version $Id: ShortType.java,v 1.13 2004/05/06 12:39:58 nicolas Exp $
26  */

27
28 class ShortType
29     extends IntType
30 {
31
32     public ShortType( int num )
33     {
34         super( num );
35     }
36
37     public String JavaDoc typeName()
38     {
39         return "short";
40     }
41
42     /**
43      * get this types's mapped Java name
44      */

45
46     public String JavaDoc getJavaTypeName()
47     {
48         return "short";
49     }
50
51
52     /**
53      * get this symbol's IDL type name
54      */

55
56     public String JavaDoc getIDLTypeName()
57     {
58         if( unsigned )
59             return "ushort";
60         else
61             return "short";
62     }
63
64     public TypeSpec typeSpec()
65     {
66         return this;
67     }
68
69     public boolean basic()
70     {
71         return true;
72     }
73
74     public int getTCKind()
75     {
76         if( unsigned )
77             return 4; //_tk_ushort
78
else
79             return 2; // _tk_short
80
}
81
82     public String JavaDoc toString()
83     {
84         return typeName();
85     }
86
87     public String JavaDoc holderName()
88     {
89         return "org.omg.CORBA.ShortHolder";
90     }
91
92
93     public String JavaDoc printReadExpression( String JavaDoc ps )
94     {
95         if( unsigned )
96             return ps + ".read_ushort()";
97         else
98             return ps + ".read_short()";
99     }
100
101     public String JavaDoc printReadStatement( String JavaDoc var_name, String JavaDoc ps )
102     {
103         if( unsigned )
104             return var_name + "=" + ps + ".read_ushort();";
105         else
106             return var_name + "=" + ps + ".read_short();";
107     }
108
109     public String JavaDoc printWriteStatement( String JavaDoc var_name, String JavaDoc ps )
110     {
111         if( unsigned )
112             return ps + ".write_ushort(" + var_name + ");";
113         else
114             return ps + ".write_short(" + var_name + ");";
115     }
116
117     public String JavaDoc printInsertExpression()
118     {
119         if( unsigned )
120             return "insert_ushort";
121         else
122             return "insert_short";
123     }
124
125     public String JavaDoc printExtractExpression()
126     {
127         if( unsigned )
128             return "extract_ushort";
129         else
130             return "extract_short";
131     }
132 }
133
134
135
136
137
138
Popular Tags