01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.compiler.impl;
11:
12: public class BooleanConstant extends Constant {
13:
14: private boolean value;
15:
16: private static final BooleanConstant TRUE = new BooleanConstant(
17: true);
18: private static final BooleanConstant FALSE = new BooleanConstant(
19: false);
20:
21: public static BooleanConstant fromValue(boolean value) {
22: return value ? BooleanConstant.TRUE : BooleanConstant.FALSE;
23: }
24:
25: private BooleanConstant(boolean value) {
26: this .value = value;
27: }
28:
29: public boolean booleanValue() {
30: return value;
31: }
32:
33: public String stringValue() {
34: //spec 15.17.11
35: return String.valueOf(this .value);
36: }
37:
38: public String toString() {
39: return "(boolean)" + value; //$NON-NLS-1$
40: }
41:
42: public int typeID() {
43: return T_boolean;
44: }
45: }
|