removed unused private methods.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / core / dom / BooleanLiteral.java
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
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11
12 package net.sourceforge.phpdt.core.dom;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 /**
18  * Boolean literal node.
19  * 
20  * <pre>
21  * BooleanLiteral:
22  *              <b>true</b>
23  *              <b>false</b>
24  * </pre>
25  * 
26  * @since 2.0
27  * @noinstantiate This class is not intended to be instantiated by clients.
28  */
29 public class BooleanLiteral extends Expression {
30         
31         /**
32          * The "booleanValue" structural property of this node type.
33          * @since 3.0
34          */
35         public static final SimplePropertyDescriptor BOOLEAN_VALUE_PROPERTY = 
36                 new SimplePropertyDescriptor(BooleanLiteral.class, "booleanValue", boolean.class, MANDATORY); //$NON-NLS-1$
37         
38         /**
39          * A list of property descriptors (element type: 
40          * {@link StructuralPropertyDescriptor}),
41          * or null if uninitialized.
42          */
43         private static final List PROPERTY_DESCRIPTORS;
44         
45         static {
46                 List properyList = new ArrayList(2);
47                 createPropertyList(BooleanLiteral.class, properyList);
48                 addProperty(BOOLEAN_VALUE_PROPERTY, properyList);
49                 PROPERTY_DESCRIPTORS = reapPropertyList(properyList);
50         }
51
52         /**
53          * Returns a list of structural property descriptors for this node type.
54          * Clients must not modify the result.
55          * 
56          * @param apiLevel the API level; one of the
57          * <code>AST.JLS*</code> constants
58
59          * @return a list of property descriptors (element type: 
60          * {@link StructuralPropertyDescriptor})
61          * @since 3.0
62          */
63         public static List propertyDescriptors(int apiLevel) {
64                 return PROPERTY_DESCRIPTORS;
65         }
66                         
67         /**
68          * The boolean; defaults to the literal for <code>false</code>.
69          */
70         private boolean value = false;
71
72         /**
73          * Creates a new unparented boolean literal node owned by the given AST.
74          * <p>
75          * N.B. This constructor is package-private.
76          * </p>
77          * 
78          * @param ast the AST that is to own this node
79          */
80         BooleanLiteral(AST ast) {
81                 super(ast);
82         }
83
84         /* (omit javadoc for this method)
85          * Method declared on ASTNode.
86          */
87         final List internalStructuralPropertiesForType(int apiLevel) {
88                 return propertyDescriptors(apiLevel);
89         }
90         
91         /* (omit javadoc for this method)
92          * Method declared on ASTNode.
93          */
94         final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean newValue) {
95                 if (property == BOOLEAN_VALUE_PROPERTY) {
96                         if (get) {
97                                 return booleanValue();
98                         } else {
99                                 setBooleanValue(newValue);
100                                 return false;
101                         }
102                 }
103                 // allow default implementation to flag the error
104                 return super.internalGetSetBooleanProperty(property, get, newValue);
105         }
106         
107         /* (omit javadoc for this method)
108          * Method declared on ASTNode.
109          */
110         final int getNodeType0() {
111                 return BOOLEAN_LITERAL;
112         }
113
114         /* (omit javadoc for this method)
115          * Method declared on ASTNode.
116          */
117         ASTNode clone0(AST target) {
118                 BooleanLiteral result = new BooleanLiteral(target);
119                 result.setSourceRange(this.getStartPosition(), this.getLength());
120                 result.setBooleanValue(booleanValue());
121                 return result;
122         }
123
124         /* (omit javadoc for this method)
125          * Method declared on ASTNode.
126          */
127         final boolean subtreeMatch0(ASTMatcher matcher, Object other) {
128                 // dispatch to correct overloaded match method
129                 return matcher.match(this, other);
130         }
131
132         /* (omit javadoc for this method)
133          * Method declared on ASTNode.
134          */
135         void accept0(ASTVisitor visitor) {
136                 visitor.visit(this);
137                 visitor.endVisit(this);
138         }
139         
140         /**
141          * Returns the boolean value of this boolean literal node.
142          * 
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>.
146          */ 
147         public boolean booleanValue() {
148                 return this.value;
149         }
150                 
151         /**
152          * Sets the boolean value of this boolean literal node.
153          * 
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>.
157          */ 
158         public void setBooleanValue(boolean value) {
159                 preValueChange(BOOLEAN_VALUE_PROPERTY);
160                 this.value = value;
161                 postValueChange(BOOLEAN_VALUE_PROPERTY);
162         }
163
164         /* (omit javadoc for this method)
165          * Method declared on ASTNode.
166          */
167         int memSize() {
168                 return BASE_NODE_SIZE + 1 * 4;
169         }
170         
171         /* (omit javadoc for this method)
172          * Method declared on ASTNode.
173          */
174         int treeSize() {
175                 return memSize();
176         }
177 }
178