oracle.jdeveloper.jot
Interface JotVariableDeclaration
- All Superinterfaces:
- JotElement, JotHasModifiers
- All Known Subinterfaces:
- JotFieldDeclaration, JotLocalVariableDeclaration
- public interface JotVariableDeclaration
- extends JotHasModifiers, JotElement
The JotVariableDeclaration interface represents a variable declaration.
A variable declaration can be either a declaration of a member field
or a declaration of a local variable. Each variable declaration
contains one or more variables. For example, the following declaration
int x contains a single variable named x, while
the declaration
AbstractButton button1 = new JButton(), button2 = new JRadioButton();
contains two variables, button1 and button2.
A JotVariableDeclaration will always contain at least one
JotVariable. If the last variable is removed from the declaration, the
declaration is automatically removed from the containing class and marked as
invalid. Attempting to modify the invalid declaration will result in a
JotException.
Each variable declaration has an associated type. Each variable is either this type
or an array type based on the declaration type. For example, in the declaration
int x[];, the declaration has type int, while the
variable has type int[].
- Since:
- 5.0
- See Also:
JotVariable,
"Section 14.4 of the Java Language Specification"
| Methods inherited from interface oracle.jdeveloper.jot.JotElement |
getElementName, getElementType, getEndOffset, getID, getJotWorkArea, getParent, getStartOffset, isExistent, isReadOnly, isStructureKnown, setParent |
getType
public JotType getType()
- Retrieves the base type of this variable declaration.
- Returns:
- a
JotType representing this declaration's
type.
setType
public void setType(java.lang.String newType)
throws JotException
- Sets the base type of this variable declaration.
- Parameters:
newType - the new type for this declaration.
- Throws:
JotException - if this declaration's type cannot be modified.
getVariables
public JotVariable[] getVariables()
- Retrieves the variables contained in this declaration.
- Returns:
- an array of
JotVariables representing this
declarations's variables. This declaration will contains at least
one variable as long as it is valid.
addVariable
public JotVariable addVariable(JotVariable marker,
boolean before,
java.lang.String varName)
throws JotException
- Adds a new variable to this declaration.
- Parameters:
marker - an existing variable in this declaration to position relative to, or
null to position at the beginning or end.before - whether to position the new variable before or after the existing
variable; or, if the marker variable is null, whether to position the new
variable at the beginning or the end of this declaration.varName - the name of the new variable.
- Returns:
- a
JotVariable representing the new variable.
- Throws:
JotException - if this declaration cannot be modified.
addVariable
public JotVariable addVariable(java.lang.String varName)
throws JotException
- Adds a new variable to the end of this declaration.
- Parameters:
varName - the name of the new variable.
- Returns:
- a
JotVariable representing the new variable.
- Throws:
JotException - if this declaration cannot be modified.
removeVariable
public void removeVariable(JotVariable var)
throws JotException
- Removes a variable from this declaration. If the variable removed is the last variable
in this declaration, this declaration will automatically be removed from its
containing class.
- Throws:
JotException - if the variable cannot be removed from this declaration.
getAsFieldDeclaration
public JotFieldDeclaration getAsFieldDeclaration()
getAsLocalVariableDeclaration
public JotLocalVariableDeclaration getAsLocalVariableDeclaration()
Copyright ©1997, 2003, Oracle. All rights reserved.