KickJava   Java API By Example, From Geeks To Geeks.

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


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: CharType.java,v 1.15 2004/05/06 12:39:58 nicolas Exp $
26  */

27
28 class CharType
29     extends BaseType
30     implements SwitchTypeSpec
31 {
32     private boolean wide = false;
33
34     public CharType( int num )
35     {
36         super( num );
37     }
38
39     public Object JavaDoc clone()
40     {
41         CharType s = new CharType( new_num() );
42         if( wide )
43             s.setWide();
44         return s;
45     }
46
47     public boolean isWide()
48     {
49         return wide;
50     }
51
52     public void setWide()
53     {
54         wide = true;
55     }
56
57     public String JavaDoc typeName()
58     {
59         return "char";
60     }
61
62     public String JavaDoc getIDLTypeName()
63     {
64         return ( wide ? "wchar" : "char" );
65     }
66
67     public TypeSpec typeSpec()
68     {
69         return this;
70     }
71
72     public String JavaDoc toString()
73     {
74         return typeName();
75     }
76
77     public boolean basic()
78     {
79         return true;
80     }
81
82     public int getTCKind()
83     {
84         if( wide )
85             return 26;
86         else
87             return 9;
88     }
89
90     public String JavaDoc holderName()
91     {
92         return "org.omg.CORBA.CharHolder";
93     }
94
95     public String JavaDoc printReadExpression( String JavaDoc strname )
96     {
97         if( wide )
98             return strname + ".read_wchar()";
99         else
100             return strname + ".read_char()";
101     }
102
103     public String JavaDoc printWriteStatement( String JavaDoc var_name, String JavaDoc strname )
104     {
105         if( wide )
106             return strname + ".write_wchar(" + var_name + ");";
107         else
108             return strname + ".write_char(" + var_name + ");";
109     }
110
111     public String JavaDoc printInsertExpression()
112     {
113         if( wide )
114             return "insert_wchar";
115         else
116             return "insert_char";
117
118     }
119
120     public String JavaDoc printExtractExpression()
121     {
122         if( wide )
123             return "extract_wchar";
124         else
125             return "extract_char";
126     }
127
128     public boolean isSwitchable()
129     {
130         // wchar is not a valid union discriminator type
131

132         return !wide;
133     }
134 }
135
136
137
138
Popular Tags