KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > impl > BooleanConstant


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.compiler.impl;
12
13 public class BooleanConstant extends Constant {
14
15 private boolean value;
16
17 private static final BooleanConstant TRUE = new BooleanConstant(true);
18 private static final BooleanConstant FALSE = new BooleanConstant(false);
19
20 public static BooleanConstant fromValue(boolean value) {
21     return value ? BooleanConstant.TRUE : BooleanConstant.FALSE;
22 }
23 private BooleanConstant(boolean value) {
24     this.value = value;
25 }
26
27 public boolean booleanValue() {
28     return value;
29 }
30
31 public String JavaDoc stringValue() {
32     //spec 15.17.11
33
return String.valueOf(this.value);
34 }
35
36 public String JavaDoc toString(){
37     return "(boolean)" + value ; //$NON-NLS-1$
38
}
39
40 public int typeID() {
41     return T_boolean;
42 }
43 }
44
Popular Tags