KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jacorb.idl;
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 /**
24  * Represents positive integer constants, used in array sizes and
25  * sequence bounds declarations.
26  *
27  * @author Gerald Brose
28  * @version $Id: PosIntConst.java,v 1.12 2004/05/06 12:39:58 nicolas Exp $
29  */

30
31 class PosIntConst
32     extends IdlSymbol
33 {
34     private int value = -1;
35     ConstExpr const_expr;
36
37     public PosIntConst( int num )
38     {
39         super( num );
40     }
41
42     void setExpression( ConstExpr const_expr )
43     {
44         this.const_expr = const_expr;
45     }
46
47     public void parse()
48     {
49         const_expr.parse();
50     }
51
52     public int value()
53     {
54         if( value == -1 )
55         {
56             value = const_expr.pos_int_const();
57             if( value <= 0 )
58                 throw new ParseException("Integer constant value must be greater 0.",
59                                          this.myPosition );
60         }
61         return value;
62     }
63
64
65     public String JavaDoc toString()
66     {
67         return const_expr.toString();
68     }
69
70
71     public void setPackage( String JavaDoc s )
72     {
73         s = parser.pack_replace( s );
74         if( pack_name.length() > 0 )
75             pack_name = s + "." + pack_name;
76         else
77             pack_name = s;
78         const_expr.setPackage( s );
79     }
80 }
81
82
83
84
85
86
87
88
89
90
91
Popular Tags