Skip navigation links
oracle.javatools.parser.java.v2.model
Interface SourceVariable
- All Superinterfaces:
- Element, JavaElement, JavaHasAnnotations, JavaHasName, JavaHasType, JavaVariable, SourceElement, SourceHasModifiers, SourceHasName, SourceHasType
- All Known Subinterfaces:
- SourceCatchParameter, SourceEnumConstant, SourceFieldVariable, SourceFormalParameter, SourceLocalVariable, SourceMemberVariable
-
public interface SourceVariable
- extends SourceElement, SourceHasModifiers, SourceHasName, SourceHasType, JavaVariable
A SourceVariable is the syntactic (aka symbolic) representation of a java variable, including: field variables, enum constant variables, local variables, and formal parameters.
Methods inherited from interface oracle.javatools.parser.java.v2.model.SourceElement |
addSelf, addSelf, addSelfAfter, addSelfBefore, clearBinding, cloneSelf, compile, getBinding, getChildren, getChildren, getCompiledObject, getContainedElements, getEndOffset, getOwningFile, getOwningSourceFile, getParent, getSiblingAfter, getSiblingBefore, getSiblings, getSiblings, getStartOffset, getSymbolKind, getText, print, print, reformatSelf, removeSelf, replaceSelf, resolve, setBinding, setContext, visitSelf |
Methods inherited from interface oracle.javatools.parser.java.v2.model.JavaHasName |
getName |
Methods inherited from interface oracle.javatools.parser.java.v2.model.JavaElement |
getElementKind, getFile, getModifiers, getOwner, getSourceElement, isDeprecated, isFinal, isHidden, isSourceElement, isSynthetic, printCompiledInfo |
EMPTY_ARRAY
static final SourceVariable[] EMPTY_ARRAY
PRINT_FIELD_NAME
static final int PRINT_FIELD_NAME
- "name[]"
- See Also:
- Constant Field Values
PRINT_DECLARATION
static final int PRINT_DECLARATION
- "type name"
- See Also:
- Constant Field Values
PRINT_TYPE
static final int PRINT_TYPE
- "type"
- See Also:
- Constant Field Values
getInitializer
SourceExpression getInitializer()
- Gets the initializer, null if none.
-
- Returns:
- This variable's initializer. Null if none was declared.
setInitializer
void setInitializer(SourceExpression expr)
- Unlinks the current initializer, if any, and links the input element.
-
- Throws:
java.lang.IllegalStateException
- if the input element is already linked.
getOwningDeclaration
SourceVariableDeclaration getOwningDeclaration()
- Gets the owning variable declaration, null if this is a formal parameter.
-
- Returns:
- The owning variable declaration.
Field variables (SRC_FIELD_VARIABLE) return SrcFieldDeclaration's.
Formal parameters (SRC_FORMAL_PARAMETER) return null.
Local variables (SRC_LOCAL_VARIABLE) return SrcLocalsDeclaration's.
separateSelf
void separateSelf()
- Extracts sibling variables so that this is the only variable on its variable declaration. Sibling variables before will be extracted into a new variable declaration that occurs before. Sibling variables after will be extracted into a new variable declaration that occurs after.
For example, suppose we tell "f2" to separate itself:
int f0 = 0, f1 = 1, f2 = 2, f3 = 3, f4 = 4;
Then, the result will be:
int f0 = 0, f1 = 1;
int f2 = 2;
int f3 = 3, f4 = 4;
Skip navigation links
Copyright © 1997, 2013, Oracle. All rights reserved.