Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2010 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 
 package org.eclipse.jdt.core.dom;
 
 import java.util.List;

Conditional expression AST node type.
 ConditionalExpression:
    Expression ? Expression : Expression
 

Since:
2.0
Noinstantiate:
This class is not intended to be instantiated by clients.
 
 public class ConditionalExpression extends Expression {

The "expression" structural property of this node type (child type: Expression).

Since:
3.0
 
 	public static final ChildPropertyDescriptor EXPRESSION_PROPERTY =
 		new ChildPropertyDescriptor(ConditionalExpression.class"expression"Expression.class); //$NON-NLS-1$
 
The "thenExpression" structural property of this node type (child type: Expression).

Since:
3.0
 
 		new ChildPropertyDescriptor(ConditionalExpression.class"thenExpression"Expression.class); //$NON-NLS-1$
 
The "elseExpression" structural property of this node type (child type: Expression).

Since:
3.0
 
 		new ChildPropertyDescriptor(ConditionalExpression.class"elseExpression"Expression.class); //$NON-NLS-1$
 
A list of property descriptors (element type: StructuralPropertyDescriptor), or null if uninitialized.
 
 	private static final List PROPERTY_DESCRIPTORS;
 
 	static {
 		List properyList = new ArrayList(4);
 	}

Returns a list of structural property descriptors for this node type. Clients must not modify the result.

Parameters:
apiLevel the API level; one of the AST.JLS* constants
Returns:
a list of property descriptors (element type: StructuralPropertyDescriptor)
Since:
3.0
 
 	public static List propertyDescriptors(int apiLevel) {
 	}

The condition expression; lazily initialized; defaults to an unspecified, but legal, expression.
 
 	private Expression conditionExpression = null;

The "then" expression; lazily initialized; defaults to an unspecified, but legal, expression.
 
 	private Expression thenExpression = null;

The "else" expression; lazily initialized; defaults to an unspecified, but legal, expression.
 
 	private Expression elseExpression = null;

Creates a new unparented conditional expression node owned by the given AST. By default, the condition, "then", and "else" expresssions are unspecified, but legal.

N.B. This constructor is package-private.

Parameters:
ast the AST that is to own this node
		super(ast);
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	final List internalStructuralPropertiesForType(int apiLevel) {
		return propertyDescriptors(apiLevel);
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor propertyboolean getASTNode child) {
		if (property == ) {
			if (get) {
				return getExpression();
else {
				return null;
			}
		}
		if (property == ) {
			if (get) {
else {
				return null;
			}
		}
		if (property == ) {
			if (get) {
else {
				return null;
			}
		}
		// allow default implementation to flag the error
		return super.internalGetSetChildProperty(propertygetchild);
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	final int getNodeType0() {
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	ASTNode clone0(AST target) {
		return result;
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	final boolean subtreeMatch0(ASTMatcher matcherObject other) {
		// dispatch to correct overloaded match method
		return matcher.match(thisother);
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	void accept0(ASTVisitor visitor) {
		boolean visitChildren = visitor.visit(this);
		if (visitChildren) {
			// visit children in normal left to right reading order
		}
		visitor.endVisit(this);
	}

Returns the condition of this conditional expression.

Returns:
the condition node
		if (this. == null) {
			// lazy init must be thread-safe for readers
			synchronized (this) {
				if (this. == null) {
					this. = new SimpleName(this.);
				}
			}
		}
		return this.;
	}

Sets the condition of this conditional expression.

Parameters:
expression the condition node
Throws:
java.lang.IllegalArgumentException if:
  • the node belongs to a different AST
  • the node already has a parent
  • a cycle in would be created
	public void setExpression(Expression expression) {
		if (expression == null) {
		}
		ASTNode oldChild = this.;
		preReplaceChild(oldChildexpression);
		this. = expression;
		postReplaceChild(oldChildexpression);
	}

Returns the "then" part of this conditional expression.

Returns:
the "then" expression node
		if (this. == null) {
			// lazy init must be thread-safe for readers
			synchronized (this) {
				if (this. == null) {
					this. = new SimpleName(this.);
				}
			}
		}
		return this.;
	}

Sets the "then" part of this conditional expression.

Parameters:
expression the "then" expression node
Throws:
java.lang.IllegalArgumentException if:
  • the node belongs to a different AST
  • the node already has a parent
  • a cycle in would be created
	public void setThenExpression(Expression expression) {
		if (expression == null) {
		}
		ASTNode oldChild = this.;
		preReplaceChild(oldChildexpression);
		this. = expression;
	}

Returns the "else" part of this conditional expression.

Returns:
the "else" expression node
		if (this. == null) {
			// lazy init must be thread-safe for readers
			synchronized (this) {
				if (this. == null) {
					this. = new SimpleName(this.);
				}
			}
		}
		return this.;
	}

Sets the "else" part of this conditional expression.

Parameters:
expression the "else" expression node
Throws:
java.lang.IllegalArgumentException if:
  • the node belongs to a different AST
  • the node already has a parent
  • a cycle in would be created
	public void setElseExpression(Expression expression) {
		if (expression == null) {
		}
		ASTNode oldChild = this.;
		preReplaceChild(oldChildexpression);
		this. = expression;
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	int memSize() {
		// treat Code as free
		return  + 3 * 4;
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	int treeSize() {
		return
			+ (this. == null ? 0 : getExpression().treeSize())
			+ (this. == null ? 0 : getThenExpression().treeSize())
			+ (this. == null ? 0 : getElseExpression().treeSize());
	}
New to GrepCode? Check out our FAQ X