1 /*******************************************************************************
2 * Copyright (c) 2000, 2008 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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
12 package net.sourceforge.phpdt.core.dom;
14 import java.util.ArrayList;
15 import java.util.List;
18 * Boolean literal node.
27 * @noinstantiate This class is not intended to be instantiated by clients.
29 public class BooleanLiteral extends Expression {
32 * The "booleanValue" structural property of this node type.
35 public static final SimplePropertyDescriptor BOOLEAN_VALUE_PROPERTY =
36 new SimplePropertyDescriptor(BooleanLiteral.class, "booleanValue", boolean.class, MANDATORY); //$NON-NLS-1$
39 * A list of property descriptors (element type:
40 * {@link StructuralPropertyDescriptor}),
41 * or null if uninitialized.
43 private static final List PROPERTY_DESCRIPTORS;
46 List properyList = new ArrayList(2);
47 createPropertyList(BooleanLiteral.class, properyList);
48 addProperty(BOOLEAN_VALUE_PROPERTY, properyList);
49 PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
53 * Returns a list of structural property descriptors for this node type.
54 * Clients must not modify the result.
56 * @param apiLevel the API level; one of the
57 * <code>AST.JLS*</code> constants
59 * @return a list of property descriptors (element type:
60 * {@link StructuralPropertyDescriptor})
63 public static List propertyDescriptors(int apiLevel) {
64 return PROPERTY_DESCRIPTORS;
68 * The boolean; defaults to the literal for <code>false</code>.
70 private boolean value = false;
73 * Creates a new unparented boolean literal node owned by the given AST.
75 * N.B. This constructor is package-private.
78 * @param ast the AST that is to own this node
80 BooleanLiteral(AST ast) {
84 /* (omit javadoc for this method)
85 * Method declared on ASTNode.
87 final List internalStructuralPropertiesForType(int apiLevel) {
88 return propertyDescriptors(apiLevel);
91 /* (omit javadoc for this method)
92 * Method declared on ASTNode.
94 final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean newValue) {
95 if (property == BOOLEAN_VALUE_PROPERTY) {
97 return booleanValue();
99 setBooleanValue(newValue);
103 // allow default implementation to flag the error
104 return super.internalGetSetBooleanProperty(property, get, newValue);
107 /* (omit javadoc for this method)
108 * Method declared on ASTNode.
110 final int getNodeType0() {
111 return BOOLEAN_LITERAL;
114 /* (omit javadoc for this method)
115 * Method declared on ASTNode.
117 ASTNode clone0(AST target) {
118 BooleanLiteral result = new BooleanLiteral(target);
119 result.setSourceRange(this.getStartPosition(), this.getLength());
120 result.setBooleanValue(booleanValue());
124 /* (omit javadoc for this method)
125 * Method declared on ASTNode.
127 final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
128 // dispatch to correct overloaded match method
129 return matcher.match(this, other);
132 /* (omit javadoc for this method)
133 * Method declared on ASTNode.
135 void accept0(ASTVisitor visitor) {
137 visitor.endVisit(this);
141 * Returns the boolean value of this boolean literal node.
143 * @return <code>true</code> for the boolean literal spelled
144 * <code>"true"</code>, and <code>false</code> for the boolean literal
145 * spelled <code>"false"</code>.
147 public boolean booleanValue() {
152 * Sets the boolean value of this boolean literal node.
154 * @param value <code>true</code> for the boolean literal spelled
155 * <code>"true"</code>, and <code>false</code> for the boolean literal
156 * spelled <code>"false"</code>.
158 public void setBooleanValue(boolean value) {
159 preValueChange(BOOLEAN_VALUE_PROPERTY);
161 postValueChange(BOOLEAN_VALUE_PROPERTY);
164 /* (omit javadoc for this method)
165 * Method declared on ASTNode.
168 return BASE_NODE_SIZE + 1 * 4;
171 /* (omit javadoc for this method)
172 * Method declared on ASTNode.