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;
 import java.util.Map;

Prefix expression AST node type.
 PrefixExpression:
    PrefixOperator Expression
 

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

Prefix operators (typesafe enumeration).
 PrefixOperator:
    ++  INCREMENT
    --  DECREMENT
    +  PLUS
    -  MINUS
    ~  COMPLEMENT
    !  NOT
 
 
 	public static class Operator {

The token for the operator.
 
 		private String token;

Creates a new prefix operator with the given token.

Note: this constructor is private. The only instances ever created are the ones for the standard operators.

Parameters:
token the character sequence for the operator
 
 		private Operator(String token) {
 			this. = token;
 		}

Returns the character sequence for the operator.

Returns:
the character sequence for the operator
 
 		public String toString() {
 			return this.;
 		}

Prefix increment "++" operator.
 
 		public static final Operator INCREMENT = new Operator("++");//$NON-NLS-1$
 		
Prefix decrement "--" operator.
 
 		public static final Operator DECREMENT = new Operator("--");//$NON-NLS-1$
 		
Unary plus "+" operator.
 
 		public static final Operator PLUS = new Operator("+");//$NON-NLS-1$
 		
Unary minus "-" operator.
 
 		public static final Operator MINUS = new Operator("-");//$NON-NLS-1$
 		
Bitwise complement "~" operator.
 
 		public static final Operator COMPLEMENT = new Operator("~");//$NON-NLS-1$
 		
Logical complement "!" operator.
 
 		public static final Operator NOT = new Operator("!");//$NON-NLS-1$
 
Map from token to operator (key type: String; value type: Operator).
 
 		private static final Map CODES;
 		static {
 			 = new HashMap(20);
 			Operator[] ops = {
 					,
 					,
				};
			for (int i = 0; i < ops.lengthi++) {
				.put(ops[i].toString(), ops[i]);
			}
		}

Returns the prefix operator corresponding to the given string, or null if none.

toOperator is the converse of toString: that is, Operator.toOperator(op.toString()) == op for all operators op.

Parameters:
token the character sequence for the operator
Returns:
the prefix operator, or null if none
		public static Operator toOperator(String token) {
			return (Operator.get(token);
		}
	}

The "operator" structural property of this node type (type: PrefixExpression.Operator).

Since:
3.0
		new SimplePropertyDescriptor(PrefixExpression.class"operator"PrefixExpression.Operator.class); //$NON-NLS-1$
The "operand" structural property of this node type (child type: Expression).

Since:
3.0
	public static final ChildPropertyDescriptor OPERAND_PROPERTY =
		new ChildPropertyDescriptor(PrefixExpression.class"operand"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 propertyList = new ArrayList(3);
		createPropertyList(PrefixExpression.classpropertyList);
	}

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 operator; defaults to an unspecified prefix operator.
The operand; lazily initialized; defaults to an unspecified, but legal, simple name.
	private Expression operand = null;

Creates a new AST node for an prefix expression owned by the given AST. By default, the node has unspecified (but legal) operator and operand.

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 Object internalGetSetObjectProperty(SimplePropertyDescriptor propertyboolean getObject value) {
		if (property == ) {
			if (get) {
				return getOperator();
else {
				return null;
			}
		}
		// allow default implementation to flag the error
		return super.internalGetSetObjectProperty(propertygetvalue);
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor propertyboolean getASTNode child) {
		if (property == ) {
			if (get) {
				return getOperand();
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) {
		PrefixExpression result = new PrefixExpression(target);
		result.setOperand((ExpressiongetOperand().clone(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
			acceptChild(visitorgetOperand());
		}
		visitor.endVisit(this);
	}

Returns the operator of this prefix expression.

Returns:
the operator
		return this.;
	}

Sets the operator of this prefix expression.

Parameters:
operator the operator
Throws:
java.lang.IllegalArgumentException if the argument is incorrect
	public void setOperator(PrefixExpression.Operator operator) {
		if (operator == null) {
		}
		this. = operator;
	}

Returns the operand of this prefix expression.

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

Sets the operand of this prefix expression.

Parameters:
expression the operand 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 setOperand(Expression expression) {
		if (expression == null) {
		}
		ASTNode oldChild = this.;
		preReplaceChild(oldChildexpression);
		this. = expression;
		postReplaceChild(oldChildexpression);
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	int memSize() {
		// treat Operator as free
		return  + 2 * 4;
	}
	/* (omit javadoc for this method)
	 * Method declared on ASTNode.
	 */
	int treeSize() {
		return
			+ (this. == null ? 0 : getOperand().treeSize());
	}
New to GrepCode? Check out our FAQ X