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;

Postfix expression AST node type.
 PostfixExpression:
    Expression PostfixOperator
 

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

Postfix operators (typesafe enumeration).
 PostfixOperator:
    ++  INCREMENT
    --  DECREMENT
 
 
 	public static class Operator {

The token for the operator.
 
 		private String token;

Creates a new postfix 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.;
 		}

Postfix increment "++" operator.
 
 		public static final Operator INCREMENT = new Operator("++");//$NON-NLS-1$
 		
Postfix decrement "--" operator.
 
 		public static final Operator DECREMENT = 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 postfix 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 postfix operator, or null if none
		public static Operator toOperator(String token) {
			return (Operator.get(token);
		}
	}

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

Since:
3.0
		new SimplePropertyDescriptor(PostfixExpression.class"operator"PostfixExpression.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(PostfixExpression.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);
	}

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

Creates a new AST node for an postfix 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) {
		PostfixExpression result = new PostfixExpression(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) {
			acceptChild(visitorgetOperand());
		}
		visitor.endVisit(this);
	}

Returns the operator of this postfix expression.

Returns:
the operator
		return this.;
	}

Sets the operator of this postfix expression.

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

Returns the operand of this postfix 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 postfix 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