Extension SDK 9.0.5

oracle.jdeveloper.jot
Interface JotCodeBlock

All Superinterfaces:
JotCodeElement, JotElement
All Known Subinterfaces:
JotBlockStatement

public interface JotCodeBlock
extends JotCodeElement

A JotCodeBlock instance represents a code block. Code blocks can contain block elements.

Since:
5.0
See Also:
JotBlockElement, "Section 14.2 of the Java Language Specification"

Method Summary
 void addBlankLine()
          Adds a blank line at the end of the code block.
 void addBlankLine(JotBlockElement marker, boolean before)
          Adds a blank line to the code block.
 JotBlockStatement addBlock()
          Adds a new block statement to the end of this code block.
 JotBlockStatement addBlock(JotBlockElement marker, boolean before)
          Adds a new block statement to this code block.
 JotBlockElement addBlockElement(JotBlockElement marker, boolean before, java.lang.String text)
          Adds an arbitrary block element to this code block.
 JotBlockElement addBlockElement(java.lang.String text)
          Adds an arbitrary block element to this code block.
 JotBlockElement[] addBlockElements(JotBlockElement marker, boolean before, java.lang.String text)
          Adds arbitrary block elements to this code block.
 JotBlockElement[] addBlockElements(java.lang.String text)
          Adds arbitrary block elements to this code block.
 JotBreak addBreak()
          Adds a new break statement to the end of this block statement.
 JotBreak addBreak(JotBlockElement marker, boolean before)
          Adds a new break statement to this code block.
 JotCase addCase(JotBlockElement marker, boolean before, java.lang.String label)
          Adds a new case statement to this code block.
 JotCase addCase(java.lang.String label)
          Adds a new case statement to the end of this code block.
 void addComment(JotBlockElement marker, boolean before, JotComment comment)
          Adds a comment to this file.
 JotContinue addContinue()
          Adds a new continue statement to the end of this code block.
 JotContinue addContinue(JotBlockElement marker, boolean before)
          Adds a new continue statement to this code block.
 JotDo addDo(JotBlockElement marker, boolean before, java.lang.String condition)
          Adds a new do statement to this code block.
 JotDo addDo(java.lang.String condition)
          Adds a new do statement to the end of this code block.
 JotExpressionStatement addExpressionStatement(JotBlockElement marker, boolean before, JotStatementExpression exp)
          Adds a new expression statement to this code block based on a specific expression.
 JotExpressionStatement addExpressionStatement(JotBlockElement marker, boolean before, java.lang.String exp)
          Adds a new expression statement to this code block.
 JotExpressionStatement addExpressionStatement(JotStatementExpression exp)
          Adds a new expression statement to the end of this code block based on a specific expression.
 JotExpressionStatement addExpressionStatement(java.lang.String exp)
          Adds a new expression statement to the end of this code block.
 JotFor addFor()
          Adds a new for statement to the end of this code block.
 JotFor addFor(JotBlockElement marker, boolean before)
          Adds a new for statement to this code block.
 JotIf addIf(JotBlockElement marker, boolean before, java.lang.String exp)
          Adds a new if statement to this code block.
 JotIf addIf(java.lang.String exp)
          Adds a new if statement to the end of this code block.
 JotLocalClass addLocalClass(JotBlockElement marker, boolean before, java.lang.String cName)
          Adds a new local class declaration to this block.
 JotLocalClass addLocalClass(java.lang.String cName)
          Adds a new local class declaration to the end of this block.
 JotReturn addReturn(JotBlockElement marker, boolean before, java.lang.String exp)
          Adds a new return statement to this code block.
 JotReturn addReturn(java.lang.String exp)
          Adds a new return statement to the end of this code block.
 JotSwitch addSwitch(JotBlockElement marker, boolean before, java.lang.String exp)
          Adds a new switch statement to this code block.
 JotSwitch addSwitch(java.lang.String exp)
          Adds a new switch statement to the end of this code block.
 JotSynchronized addSynchronized(JotBlockElement marker, boolean before, java.lang.String exp)
          Adds a new synchronized statement to this code block.
 JotSynchronized addSynchronized(java.lang.String exp)
          Adds a new synchronized statement to the end of this code block.
 JotThrow addThrow(JotBlockElement marker, boolean before, java.lang.String exp)
          Adds a new throw statement to this code block.
 JotThrow addThrow(java.lang.String exp)
          Adds a new throw statement to the end of this code block.
 JotTry addTry()
          Adds a new try statement to the end of this code block.
 JotTry addTry(JotBlockElement marker, boolean before)
          Adds a new try statement to this code block.
 JotLocalVariable addVariable(JotBlockElement marker, boolean before, java.lang.String vType, java.lang.String vName)
          Creates a new variable declaration in this block and adds a variable to it.
 JotLocalVariable addVariable(java.lang.String vType, java.lang.String vName)
          Creates a new variable declaration in this block and adds a variable to it.
 JotLocalVariableDeclaration addVariableDeclaration(JotBlockElement marker, boolean before, java.lang.String vType)
          Adds a new variable declaration to this block.
 JotLocalVariableDeclaration addVariableDeclaration(java.lang.String vType)
          Adds a new variable declaration to the end of this block.
 JotWhile addWhile(JotBlockElement marker, boolean before, java.lang.String condition)
          Adds a new while statement to this code block.
 JotWhile addWhile(java.lang.String condition)
          Adds a new while statement to the end of this code block.
 JotAssignment createAssignment(java.lang.String variable, java.lang.String value)
          Creates a new assignment.
 JotComment createComment(int type, java.lang.String text)
          Creates a new comment.
 JotMethodCall createMethodCall(java.lang.String object, java.lang.String method)
          Creates a new method call.
 JotNestedExpression createNestedMethodCall(JotMethodCall firstCall, JotMethodCall secondCall)
          Creates a new nested method call.
 JotBlockElement[] getBlockElements()
          Retrieves all the block elements that are children of this block.
 JotComment getComment(JotBlockElement marker, boolean before)
          Retrieves the nearest comment to a member.
 JotComment[] getComments()
          Retrieves all the class-level comments.
 int getComparableLocation(JotBlockElement element)
          Retrieves the position of an element in the list of elements.
 int getComparableLocation(JotStatementExpression stmtExp)
          Retrieves the position of an expression in the list of elements.
 void removeAllBlockElements()
          Removes all block elements from this block.
 void removeBlockElement(JotBlockElement element)
          Removes a block element from this block.
 void removeComment(JotComment comment)
          Removes an existing comment.
 void setText(java.lang.String text)
          Sets the text of this code block.
 
Methods inherited from interface oracle.jdeveloper.jot.JotCodeElement
addPrecedingComment, childrenContainErrors, delete, getContainingJotFile, getLeftWhitespace, getLength, getRightWhitespace, isInError, isSource, setLeftWhitespace, setRightWhitespace
 
Methods inherited from interface oracle.jdeveloper.jot.JotElement
getChildren, getContainedElements, getElementName, getElementType, getEndOffset, getID, getJotWorkArea, getParent, getStartOffset, isExistent, isReadOnly, isStructureKnown, setParent
 

Method Detail

getBlockElements

public JotBlockElement[] getBlockElements()
                                   throws JotInvalidElementException
Retrieves all the block elements that are children of this block.

Returns:
an array of JotBlockElements that represent the children of this block
Throws:
JotInvalidElementException

getComparableLocation

public int getComparableLocation(JotBlockElement element)
                          throws JotInvalidElementException
Retrieves the position of an element in the list of elements.

Parameters:
element - the element whose position is desired.
Returns:
the index of the element, or -1 if the element is not a current member of this block.
Throws:
JotInvalidElementException

getComparableLocation

public int getComparableLocation(JotStatementExpression stmtExp)
                          throws JotInvalidElementException
Retrieves the position of an expression in the list of elements. The expression must be contained in a expression statement in the block; conditional expressions in a for statement, for example, are not checked.

Parameters:
stmtExp - the expression whose position is desired.
Returns:
the index of the statement containing the expression, or -1 if the expression is not contained by a statement in the block.
Throws:
JotInvalidElementException

addBlock

public JotBlockStatement addBlock(JotBlockElement marker,
                                  boolean before)
                           throws JotInvalidElementException
Adds a new block statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the new block should be positioned at the beginning or end of this block.
before - whether to position the new block before or after the existing marker element; or if marker is null, whether to position the new block at the beginning or the end of this block.
Returns:
the JotBlockStatement representing the new block.
Throws:
JotInvalidElementException

addBlock

public JotBlockStatement addBlock()
                           throws JotInvalidElementException
Adds a new block statement to the end of this code block.

Returns:
the JotBlockStatement representing the new block.
Throws:
JotInvalidElementException

addBreak

public JotBreak addBreak(JotBlockElement marker,
                         boolean before)
                  throws JotInvalidElementException
Adds a new break statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the break statement should be positioned at the beginning or end of this block.
before - whether to position the break statement before or after the existing marker element; or if marker is null, whether to position the break statement at the beginning or the end of this block.
Returns:
the JotBreak representing the break statement.
Throws:
JotInvalidElementException

addBreak

public JotBreak addBreak()
                  throws JotInvalidElementException
Adds a new break statement to the end of this block statement.

Returns:
the JotBreak representing the break statement.
Throws:
JotInvalidElementException

addContinue

public JotContinue addContinue(JotBlockElement marker,
                               boolean before)
                        throws JotInvalidElementException
Adds a new continue statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the continue statement should be positioned at the beginning or end of this block.
before - whether to position the continue statement before or after the existing marker element; or if marker is null, whether to position the continue statement at the beginning or the end of this block.
Returns:
the JotContinue representing the continue statement.
Throws:
JotInvalidElementException

addContinue

public JotContinue addContinue()
                        throws JotInvalidElementException
Adds a new continue statement to the end of this code block.

Returns:
the JotContinue representing the continue statement.
Throws:
JotInvalidElementException

addReturn

public JotReturn addReturn(JotBlockElement marker,
                           boolean before,
                           java.lang.String exp)
                    throws JotInvalidElementException
Adds a new return statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the return statement should be positioned at the beginning or end of this block.
before - whether to position the return statement before or after the existing marker element; or if marker is null, whether to position the return statement at the beginning or the end of this block.
exp - the return expression; null create return without a value;
Returns:
the JotReturn representing the return statement.
Throws:
JotInvalidElementException

addReturn

public JotReturn addReturn(java.lang.String exp)
                    throws JotInvalidElementException
Adds a new return statement to the end of this code block.

Parameters:
exp - the return expression; null create return without a value;
Returns:
the JotReturn representing the return statement.
Throws:
JotInvalidElementException

addThrow

public JotThrow addThrow(JotBlockElement marker,
                         boolean before,
                         java.lang.String exp)
                  throws JotInvalidElementException
Adds a new throw statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the throw statement should be positioned at the beginning or end of this block.
before - whether to position the throw statement before or after the existing marker element; or if marker is null, whether to position the throw statement at the beginning or the end of this block.
exp - the value being thrown.
Returns:
the JotThrow representing the throw statement.
Throws:
JotInvalidElementException

addThrow

public JotThrow addThrow(java.lang.String exp)
                  throws JotInvalidElementException
Adds a new throw statement to the end of this code block.

Parameters:
exp - the value being thrown.
Returns:
the JotThrow representing the throw statement.
Throws:
JotInvalidElementException

addDo

public JotDo addDo(JotBlockElement marker,
                   boolean before,
                   java.lang.String condition)
            throws JotInvalidElementException
Adds a new do statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the do statement should be positioned at the beginning or end of this block.
before - whether to position the do statement before or after the existing marker element; or if marker is null, whether to position the do statement at the beginning or the end of this block.
condition - the conditional expression.
Returns:
the JotDo representing the do statement.
Throws:
JotInvalidElementException

addDo

public JotDo addDo(java.lang.String condition)
            throws JotInvalidElementException
Adds a new do statement to the end of this code block.

Parameters:
condition - the conditional expression.
Returns:
the JotDo representing the do statement.
Throws:
JotInvalidElementException

addWhile

public JotWhile addWhile(JotBlockElement marker,
                         boolean before,
                         java.lang.String condition)
                  throws JotInvalidElementException
Adds a new while statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the while statement should be positioned at the beginning or end of this block.
before - whether to position the while statement before or after the existing marker element; or if marker is null, whether to position the while statement at the beginning or the end of this block.
condition - the conditional expression.
Returns:
the JotWhile representing the while statement.
Throws:
JotInvalidElementException

addWhile

public JotWhile addWhile(java.lang.String condition)
                  throws JotInvalidElementException
Adds a new while statement to the end of this code block.

Parameters:
condition - the conditional expression.
Returns:
the JotWhile representing the while statement.
Throws:
JotInvalidElementException

addIf

public JotIf addIf(JotBlockElement marker,
                   boolean before,
                   java.lang.String exp)
            throws JotInvalidElementException
Adds a new if statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the if statement should be positioned at the beginning or end of this block.
before - whether to position the if statement before or after the existing marker element; or if marker is null, whether to position the if statement at the beginning or the end of this block.
exp - the conditional expression.
Returns:
the JotIf representing the if statement.
Throws:
JotInvalidElementException

addIf

public JotIf addIf(java.lang.String exp)
            throws JotInvalidElementException
Adds a new if statement to the end of this code block.

Parameters:
exp - the conditional expression.
Returns:
the JotIf representing the if statement.
Throws:
JotInvalidElementException

addFor

public JotFor addFor(JotBlockElement marker,
                     boolean before)
              throws JotInvalidElementException
Adds a new for statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the for statement should be positioned at the beginning or end of this block.
before - whether to position the for statement before or after the existing marker element; or if marker is null, whether to position the for statement at the beginning or the end of this block.
Returns:
the JotFor representing the for statement.
Throws:
JotInvalidElementException

addFor

public JotFor addFor()
              throws JotInvalidElementException
Adds a new for statement to the end of this code block.

Returns:
the JotFor representing the for statement.
Throws:
JotInvalidElementException

addSwitch

public JotSwitch addSwitch(JotBlockElement marker,
                           boolean before,
                           java.lang.String exp)
                    throws JotInvalidElementException
Adds a new switch statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the switch statement should be positioned at the beginning or end of this block.
before - whether to position the switch statement before or after the existing marker element; or if marker is null, whether to position the switch statement at the beginning or the end of this block.
exp - the expression being switched on.
Returns:
the JotSwitch representing the switch statement.
Throws:
JotInvalidElementException

addSwitch

public JotSwitch addSwitch(java.lang.String exp)
                    throws JotInvalidElementException
Adds a new switch statement to the end of this code block.

Parameters:
exp - the expression being switched on.
Returns:
the JotSwitch representing the switch statement.
Throws:
JotInvalidElementException

addSynchronized

public JotSynchronized addSynchronized(JotBlockElement marker,
                                       boolean before,
                                       java.lang.String exp)
                                throws JotInvalidElementException
Adds a new synchronized statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the synchronized statement should be positioned at the beginning or end of this block.
before - whether to position the synchronized statement before or after the existing marker element; or if marker is null, whether to position the synchronized statement at the beginning or the end of this block.
exp - the expression being synchronized on.
Returns:
the JotSynchronized representing the synchronized statement.
Throws:
JotInvalidElementException

addSynchronized

public JotSynchronized addSynchronized(java.lang.String exp)
                                throws JotInvalidElementException
Adds a new synchronized statement to the end of this code block.

Parameters:
exp - the expression being synchronized on.
Returns:
the JotSynchronized representing the synchronized statement.
Throws:
JotInvalidElementException

addExpressionStatement

public JotExpressionStatement addExpressionStatement(JotBlockElement marker,
                                                     boolean before,
                                                     java.lang.String exp)
                                              throws JotInvalidElementException
Adds a new expression statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the expression statement should be positioned at the beginning or end of this block.
before - whether to position the expression statement before or after the existing marker element; or if marker is null, whether to position the expression statement at the beginning or the end of this block.
exp - the expression being wrapped.
Returns:
the JotExpressionStatement representing the expression statement.
Throws:
JotInvalidElementException

addExpressionStatement

public JotExpressionStatement addExpressionStatement(java.lang.String exp)
                                              throws JotInvalidElementException
Adds a new expression statement to the end of this code block.

Parameters:
exp - the expression being wrapped.
Returns:
the JotExpressionStatement representing the expression statement.
Throws:
JotInvalidElementException

addExpressionStatement

public JotExpressionStatement addExpressionStatement(JotBlockElement marker,
                                                     boolean before,
                                                     JotStatementExpression exp)
                                              throws JotInvalidElementException
Adds a new expression statement to this code block based on a specific expression.

Parameters:
marker - an existing element to position relative to, or null if the expression statement should be positioned at the beginning or end of this block.
before - whether to position the expression statement before or after the existing marker element; or if marker is null, whether to position the expression statement at the beginning or the end of this block.
exp - the statement expression to wrap.
Returns:
the JotExpressionStatement representing the expression statement.
Throws:
JotInvalidElementException

addExpressionStatement

public JotExpressionStatement addExpressionStatement(JotStatementExpression exp)
                                              throws JotInvalidElementException
Adds a new expression statement to the end of this code block based on a specific expression.

Parameters:
exp - the statement expression to wrap.
Returns:
the JotExpressionStatement representing the expression statement.
Throws:
JotInvalidElementException

addTry

public JotTry addTry(JotBlockElement marker,
                     boolean before)
              throws JotInvalidElementException
Adds a new try statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the try statement should be positioned at the beginning or end of this block.
before - whether to position the try statement before or after the existing marker element; or if marker is null, whether to position the try statement at the beginning or the end of this block.
Returns:
the JotTry representing the try statement.
Throws:
JotInvalidElementException

addTry

public JotTry addTry()
              throws JotInvalidElementException
Adds a new try statement to the end of this code block.

Returns:
the JotTry representing the try statement.
Throws:
JotInvalidElementException

addCase

public JotCase addCase(JotBlockElement marker,
                       boolean before,
                       java.lang.String label)
                throws JotInvalidElementException
Adds a new case statement to this code block.

Parameters:
marker - an existing element to position relative to, or null if the case statement should be positioned at the beginning or end of this block.
before - whether to position the case statement before or after the existing marker element; or if marker is null, whether to position the case statement at the beginning or the end of this block.
label - the case label; or null to create the default case.
Returns:
the JotSwitch representing the case statement. If this code block is not associated with a switch statement, null will be returned.
Throws:
JotInvalidElementException

addCase

public JotCase addCase(java.lang.String label)
                throws JotInvalidElementException
Adds a new case statement to the end of this code block.

Parameters:
label - the case label; or null to create the default case.
Returns:
the JotSwitch representing the case statement. If this code block is not associated with a switch statement, null will be returned.
Throws:
JotInvalidElementException

addVariableDeclaration

public JotLocalVariableDeclaration addVariableDeclaration(JotBlockElement marker,
                                                          boolean before,
                                                          java.lang.String vType)
                                                   throws JotInvalidElementException
Adds a new variable declaration to this block. Individual variables can be added to the declaration by calling JotLocalVariableDeclaration.addLocalVariable().

Parameters:
marker - an existing element to position relative to, or null if the variable declaration should be positioned at the beginning or end of this block.
before - whether to position the variable declaration before or after the existing marker element; or if marker is null, whether to position the variable declaration at the beginning or the end of this block.
vType - the type of the variable.
Returns:
a JotLocalVariableDeclaration representing the new variable declaration.
Throws:
JotInvalidElementException
See Also:
JotLocalVariableDeclaration.addVariable()

addVariableDeclaration

public JotLocalVariableDeclaration addVariableDeclaration(java.lang.String vType)
                                                   throws JotInvalidElementException
Adds a new variable declaration to the end of this block. Individual variables can be added to the declaration by calling JotLocalVariableDeclaration.addLocalVariable().

Parameters:
vType - the type of the variable.
Returns:
a JotLocalVariableDeclaration representing the new variable declaration.
Throws:
JotInvalidElementException
See Also:
JotLocalVariableDeclaration.addVariable()

addVariable

public JotLocalVariable addVariable(JotBlockElement marker,
                                    boolean before,
                                    java.lang.String vType,
                                    java.lang.String vName)
                             throws JotInvalidElementException
Creates a new variable declaration in this block and adds a variable to it. This is equivalent to calling addVariableDeclaration( marker, before, vType).addVariable( vName ).

Parameters:
marker - an existing element to position relative to, or null if the variable declaration should be positioned at the beginning or end of this block.
before - whether to position the variable declaration before or after the existing marker element; or if marker is null, whether to position the variable declaration at the beginning or the end of this block.
vType - the type of the variable.
vName - the name of the variable.
Returns:
the JotLocalVariable representing the new variable.
Throws:
JotInvalidElementException

addVariable

public JotLocalVariable addVariable(java.lang.String vType,
                                    java.lang.String vName)
                             throws JotInvalidElementException
Creates a new variable declaration in this block and adds a variable to it. This is equivalent to calling addVariableDeclaration( vType).addVariable( vName ).

Parameters:
vType - the type of the variable.
vName - the name of the variable.
Returns:
the JotLocalVariable representing the new variable.
Throws:
JotInvalidElementException

addLocalClass

public JotLocalClass addLocalClass(JotBlockElement marker,
                                   boolean before,
                                   java.lang.String cName)
                            throws JotInvalidElementException
Adds a new local class declaration to this block.

Parameters:
marker - an existing element to position relative to, or null if the local class declaration should be positioned at the beginning or end of this block.
before - whether to position the local class declaration before or after the existing marker element; or if marker is null, whether to position the local class declaration at the beginning or the end of this block.
cName - the name of the new local class.
Returns:
a JotLocalClass instance representing the new local class declaration.
Throws:
JotInvalidElementException

addLocalClass

public JotLocalClass addLocalClass(java.lang.String cName)
                            throws JotInvalidElementException
Adds a new local class declaration to the end of this block.

Parameters:
cName - the name of the new local class.
Returns:
a JotLocalClass instance representing the new local class declaration.
Throws:
JotInvalidElementException

addBlockElement

public JotBlockElement addBlockElement(JotBlockElement marker,
                                       boolean before,
                                       java.lang.String text)
                                throws JotException,
                                       JotInvalidElementException
Adds an arbitrary block element to this code block. The specified block element is assumed to be syntactically correct and should include a semi-colon or other relevant terminator.

Parameters:
marker - an existing element to position relative to, or null if the block element should be positioned at the beginning or end of this block.
before - whether to position the block element before or after the existing marker element; or if marker is null, whether to position the block element at the beginning or the end of this block.
text - the text of the new block element.
Throws:
JotException - if the text is not parsable into a block element.
JotInvalidElementException

addBlockElement

public JotBlockElement addBlockElement(java.lang.String text)
                                throws JotException,
                                       JotInvalidElementException
Adds an arbitrary block element to this code block. The specified block element is assumed to be syntactically correct and should include a semi-colon or other relevant terminator.

Parameters:
text - the text of the new block element.
Throws:
JotException - if the text is not parsable into a block element.
JotInvalidElementException

addBlockElements

public JotBlockElement[] addBlockElements(JotBlockElement marker,
                                          boolean before,
                                          java.lang.String text)
                                   throws JotException,
                                          JotInvalidElementException
Adds arbitrary block elements to this code block. The specified block elements are assumed to be syntactically correct and should include a semi-colon or other relevant terminator.

Parameters:
marker - an existing element to position relative to, or null if the block elements should be positioned at the beginning or end of this block.
before - whether to position the block elements before or after the existing marker element; or if marker is null, whether to position the block elements at the beginning or the end of this block.
text - the text of the new block elements.
Throws:
JotException - if the text is not parsable into block elements.
JotInvalidElementException

addBlockElements

public JotBlockElement[] addBlockElements(java.lang.String text)
                                   throws JotException,
                                          JotInvalidElementException
Adds arbitrary block elements to this code block. The specified block elements are assumed to be syntactically correct and should include a semi-colon or other relevant terminator.

Parameters:
text - the text of the new block elements.
Throws:
JotException - if the text is not parsable into block elements.
JotInvalidElementException

setText

public void setText(java.lang.String text)
             throws JotException,
                    JotInvalidElementException
Sets the text of this code block. Any existing block elements are removed. The braces delineating this code block should be omitted; and braces included in the block text are assumed to indicate child block.

Parameters:
text - the new text of this code block.
Throws:
JotException - if the text passed in does not represent parsable block text.
JotInvalidElementException

removeBlockElement

public void removeBlockElement(JotBlockElement element)
                        throws JotInvalidElementException
Removes a block element from this block. If the element does not currently exist as a child of this block, it is ignored.

Parameters:
element - the existing element to remove.
Throws:
JotInvalidElementException

removeAllBlockElements

public void removeAllBlockElements()
                            throws JotInvalidElementException
Removes all block elements from this block.

Throws:
JotInvalidElementException

createMethodCall

public JotMethodCall createMethodCall(java.lang.String object,
                                      java.lang.String method)
                               throws JotInvalidElementException
Creates a new method call. This method call should then be added to the code block by calling addExpressionStatement or added to a nested method call by calling createNestedMethodCall.

Parameters:
object - the object on which the method call is being made.
method - the name of the method being invoked.
Returns:
the JotMethodCall representing the method call.
Throws:
JotInvalidElementException
See Also:
addExpressionStatement(JotBlockElement, boolean, JotStatementExpression), createNestedMethodCall(JotMethodCall, JotMethodCall)

createNestedMethodCall

public JotNestedExpression createNestedMethodCall(JotMethodCall firstCall,
                                                  JotMethodCall secondCall)
                                           throws JotInvalidElementException
Creates a new nested method call. A nested method call consists of two method calls connected with the '.' operator; for example, foo().bar().

Parameters:
firstCall - the first method call.
secondCall - the second method call.
Returns:
the JotNestedExpression representing the nested method call.
Throws:
JotInvalidElementException
See Also:
createMethodCall(String, String)

createAssignment

public JotAssignment createAssignment(java.lang.String variable,
                                      java.lang.String value)
                               throws JotInvalidElementException
Creates a new assignment. This assignment should then be added to the code block by calling addExpressionStatement.

Parameters:
variable - the variable (or left side) of the assignment.
value - the expression being assigned to the variable.
Returns:
the JotAssignment representing the assignment.
Throws:
JotInvalidElementException
See Also:
addExpressionStatement(JotBlockElement, boolean, JotStatementExpression)

addBlankLine

public void addBlankLine(JotBlockElement marker,
                         boolean before)
                  throws JotInvalidElementException
Adds a blank line to the code block.

Parameters:
marker - an existing element to position relative to, or null if the blank line should be positioned at the beginning or end of this block.
before - whether to position the blank line before or after the existing marker element; or if marker is null, whether to position the blank line at the beginning or the end of this block.
Throws:
JotInvalidElementException

addBlankLine

public void addBlankLine()
                  throws JotInvalidElementException
Adds a blank line at the end of the code block.

Throws:
JotInvalidElementException

createComment

public JotComment createComment(int type,
                                java.lang.String text)
                         throws JotInvalidElementException
Creates a new comment. The comment then needs to be added to the file.

Parameters:
type - the type of comment to create. Valid types are either JotComment.BLOCK, JotComment.LINE, or JotComment.DOC.
text - the text of the comment. The comment characters should be omitted.
Returns:
the newly created comment.
Throws:
JotInvalidElementException
See Also:
#addComment(JotMember, boolean, JotComment)

addComment

public void addComment(JotBlockElement marker,
                       boolean before,
                       JotComment comment)
                throws JotInvalidElementException
Adds a comment to this file.

Parameters:
marker - an existing element to position relative to, or null if the comment should be positioned at the beginning or end of this block.
before - whether to position the comment before or after the existing marker element; or if marker is null, whether to position the comment at the beginning or the end of this block. ie. If the marker is null and you wish the comment to be placed at the top of this block specify true; specify false for the bottom position.
comment - the comment to add.
Throws:
JotInvalidElementException

removeComment

public void removeComment(JotComment comment)
                   throws JotInvalidElementException
Removes an existing comment.

Parameters:
comment - the comment to remove.
Throws:
JotInvalidElementException

getComments

public JotComment[] getComments()
                         throws JotInvalidElementException
Retrieves all the class-level comments.

Returns:
an array of comments.
Throws:
JotInvalidElementException

getComment

public JotComment getComment(JotBlockElement marker,
                             boolean before)
                      throws JotInvalidElementException
Retrieves the nearest comment to a member.

Parameters:
marker - an existing element locate the comment relative to
before - whether to look for the comment before or after the existing element.
Returns:
the nearest comment, or null if no comment can be found at the specified location.
Throws:
JotInvalidElementException

Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.