| 
 | Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
   oracle.jdeveloper.java.util.SourceUtils
oracle.jdeveloper.java.util.SourceUtils
public class SourceUtils
This is a collection of utilities for making changes to the Java parser v2 source model.
| Constructor Summary | |
|---|---|
| SourceUtils() | |
| Method Summary | |
|---|---|
| static SourceStatement | addAssignStatement(SourceBlock block, java.lang.String lhsName, SourceExpression rhsExpr)Adds (append) an assignment statement (=) to the block. | 
| static SourceStatement | addAssignStatement(SourceBlock block, java.lang.String lhsName, java.lang.String rhsText)Adds (append) an assignment statement (=) to the block. | 
| static void | addBlankLine(SourceBlock block)Adds (append) a blank line to the block. | 
| static void | addBlankLine(SourceClassBody body)Adds (append) a blank line to the block. | 
| static void | addBlankLine(SourceElement block, boolean before)Adds (append) a blank line before or after a source element. | 
| static SourceCatchClause | addCatchClause(SourceTryStatement tryStmt, java.lang.String catchType, java.lang.String catchName, SourceBlock catchBlock)Adds a catch clause to the block, usin gthe given catch info. | 
| static SourceClass | addClass(SourceFile file, java.lang.String name, int modifiers)Adds (append) a class to the file. | 
| static SourceMethod | addConstructor(SourceClass cls, int modifiers)Adds a constructor to the class. | 
| static SourceDocComment | addDocComment(SourceMember member, java.lang.String descText)Sets the Javadoc comment for the given member (class, method, field, ...). | 
| static SourceDocTag | addDocTag(SourceDocComment comment, java.lang.String tagNameText, java.lang.String tagText)Adds a doc tag to the given doc comment | 
| static SourceStatement | addExpressionStatement(SourceBlock block, SourceExpression expr)Adds (append) an expression as a statement to the block. | 
| static SourceStatement | addExpressionStatement(SourceBlock block, SourceExpression expr, SourceElement sibling, boolean before)Inserts an expression as a statement to the block by the specified sibling. | 
| static SourceStatement | addExpressionStatement(SourceBlock block, java.lang.String exprText)Adds (append) an expression as a statement to the block. | 
| static SourceStatement | addExpressionStatement(SourceBlock block, java.lang.String exprText, SourceElement sibling, boolean before)Inserts an expression as a statement to the block by the specified sibling. | 
| static SourceFieldDeclaration | addField(SourceClass cls, java.lang.String type, java.lang.String name, int modifiers, java.lang.String initText)Adds a field to the class with the given type, modifiers, and initializer text. | 
| static SourceFinallyClause | addFinallyClause(SourceTryStatement tryStmt, SourceBlock finallyBlock)Adds a finally clause to the try statement, using the given block | 
| static SourceIfStatement | addIfElseStatement(SourceBlock block, java.lang.String condition, SourceBlock ifBlock, SourceBlock elseBlock)Adds an if/else statement to the block, using the given condition and if/else blocks. | 
| static SourceIfStatement | addIfStatement(SourceBlock block, java.lang.String condition, SourceBlock ifBlock)Adds an if statement to the block, using the given condition and if block. | 
| static void | addImport(SourceFile file, java.lang.String importName)Adds an import to the file. | 
| static SourceClass | addInterface(SourceFile file, java.lang.String name, int modifiers)Adds (append) an interface to the file. | 
| static void | addLineComment(SourceBlock block, java.lang.String commentText)Adds (append) a line comment to the block. | 
| static void | addLineComment(SourceClassBody block, java.lang.String commentText)Adds (append) a line comment to the block. | 
| static void | addLineComment(SourceElement element, boolean before, java.lang.String commentText)Adds a line comment before or after a source element. | 
| static SourceVariableDeclaration | addLocalVariableDeclaration(SourceBlock block, java.lang.String type, java.lang.String name, SourceExpression initExpr)Adds (append) a local variable declaration to the given block. | 
| static SourceVariableDeclaration | addLocalVariableDeclaration(SourceBlock block, java.lang.String type, java.lang.String name, java.lang.String initText)Adds (append) a local variable declaration to the given block. | 
| static SourceMethod | addMainMethod(SourceClass cls)Adds (append) a "public static void main( String[] args )" method to the class. | 
| static SourceMember | addMember(SourceClass cls, SourceMember member, SourceMember sibling, boolean before)Inserts a member into the class by the specified sibling. | 
| static SourceMethod | addMethod(SourceClass cls, java.lang.String type, java.lang.String name, int modifiers)Adds (append) a method to the class. | 
| static SourceMethod | addMethod(SourceClass cls, java.lang.String type, java.lang.String name, int modifiers, SourceMember sibling, boolean before)Inserts a method into the class by the specified sibling. | 
| static SourceStatement | addMethodCallStatement(SourceBlock block, java.lang.String lhs, java.lang.String methodName, SourceExpression[] args)Adds a method call invocation as a statement to the block. | 
| static SourceStatement | addMethodCallStatement(SourceBlock block, java.lang.String lhs, java.lang.String methodName, java.lang.String[] args)Adds a method call invocation as a statement to the block. | 
| static SourceLocalVariable | addMethodParameter(SourceMethod method, java.lang.String type, java.lang.String name)Adds (append) a parameter to the method. | 
| static SourceStatement | addReturn(SourceBlock block, java.lang.String stmtText)Adds (append) a return statement to the given block. | 
| static SourceStatement | addStatement(SourceBlock block, SourceStatement stmt, SourceElement sibling, boolean before)Inserts a statement to the block by the specified sibling. | 
| static SourceStatement | addStatement(SourceBlock block, java.lang.String stmtText)Adds (append) a statement to the block. | 
| static SourceClassInitializer | addStaticClassInitializer(SourceClass cls, SourceBlock block)Adds (append) a static class initializer to the class. | 
| static void | addSuperInterface(SourceClass cls, java.lang.String fqName)Adds the given super interface to the specified class or interface. | 
| static SourceSwitchLabel | addSwitchCaseLabel(SourceBlock switchBlock, java.lang.String caseText)Add a case label to a switch block. | 
| static SourceSwitchStatement | addSwitchStatement(SourceBlock block, java.lang.String switchText, SourceBlock switchBlock)Add a switch statement to the block. | 
| static void | addThrows(SourceMethod method, java.lang.String throwName)Adds a (class) type to the throws clause of the method declaration. | 
| static SourceThrowStatement | addThrowStatement(SourceBlock block, java.lang.String throwText)Adds a throw statement to the block, using the given throw text. | 
| static SourceTryStatement | addTryCatchStatement(SourceBlock block, SourceBlock tryBlock, java.lang.String catchType, java.lang.String catchName, SourceBlock catchBlock)Adds a try/catch statement to the block, using the given catch text. | 
| static SourceWhileStatement | addWhileStatement(SourceBlock block, java.lang.String condition, SourceBlock whileBlock)Adds a while statement to the block, using the given condition and while block. | 
| static SourceExpression | createAssign(SourceBlock block, java.lang.String lhsName, java.lang.String rhsText)Adds (append) an assignment statement (=) to the block. | 
| static SourceBlock | createBlock(SourceElement element)Create a new empty block. | 
| static SourceMethod | createConstructor(SourceClass cls, int modifiers)Creates a new constructor. | 
| static SourceFieldDeclaration | createField(SourceClass cls, java.lang.String fieldText)Creates a field to the class with the given text. | 
| static SourceFieldDeclaration | createField(SourceClass cls, java.lang.String fieldText, int modifiers)Creates a field to the class with the given text, sets the given modifiers on the result. | 
| static SourceFieldDeclaration | createField(SourceClass cls, java.lang.String type, java.lang.String name, int modifiers, java.lang.String initText)Creates a field to the class with the given type, modifiers, and initializer text. | 
| static SourceLocalVariable | createLocalVariable(SourceFile file, java.lang.String type, java.lang.String name)Creates a new local variable of the given type and name. | 
| static SourceMethod | createMainMethod(SourceClass cls)Creates a "public static void main( String[] args )" method. | 
| static SourceMethod | createMethod(SourceClass cls, java.lang.String type, java.lang.String name, int modifiers)Constructs a new method. | 
| static SourceExpression | createMethodCall(SourceBlock block, java.lang.String lhs, java.lang.String methodName, SourceExpression[] args)Creates an expression that is a method invocation. | 
| static SourceExpression | createMethodCall(SourceBlock block, java.lang.String lhs, java.lang.String methodName, java.lang.String[] args)Creates an expression that is a method invocation. | 
| static SourceStatement | createReturn(SourceBlock block, java.lang.String stmtText)Creates a return statement. | 
| static SourceTryStatement | createTryCatchStatement(SourceBlock block, SourceBlock tryBlock, java.lang.String catchType, java.lang.String catchName, SourceBlock catchBlock)Creates a try/catch statement to the block, using the given catch text. | 
| static SourceMethod | getDefaultConstructor(SourceClass cls)Fetch the default constructor for this class. | 
| static SourceFactory | getFactory(SourceElement element)Fetch a factory from the element. | 
| static SourceBlock | getFinallyBlock(SourceTryStatement tryStatement)Fetch the SourceBlock for the finally clause of a try-finally. | 
| static SourceMethod | getMainMethod(SourceClass cls)Find the main method in the cls. | 
| static SourceMethod | getMethod(SourceClass cls, java.lang.String name, java.lang.String[] paramTypes)Find the method in the cls with the given name and parameter types. | 
| static SourceVariable | getMethodParameter(SourceMethod method, int index)Fetch a parameter from the method. | 
| static JavaType | getType(JavaProvider provider, java.lang.String type)Fetch a JavaType instance for the given type. | 
| static void | removeThrows(SourceMethod method, java.lang.String throwName)Removes a class (type) from the throws clause of the method declaration. | 
| static void | setSuperclass(SourceClass cls, java.lang.String fqName)Set the super class for the given class | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public SourceUtils()
| Method Detail | 
|---|
public static void addImport(SourceFile file,
                             java.lang.String importName)
public static void addLineComment(SourceBlock block,
                                  java.lang.String commentText)
commentText - should include the contents of the comment, minus the initial // line comment token
public static void addLineComment(SourceClassBody block,
                                  java.lang.String commentText)
commentText - should include the contents of the comment, minus the initial // line comment token
public static void addLineComment(SourceElement element,
                                  boolean before,
                                  java.lang.String commentText)
commentText - shoudl include the contents of the comment, minus the initial // line comment tokenpublic static void addBlankLine(SourceBlock block)
public static void addBlankLine(SourceClassBody body)
public static void addBlankLine(SourceElement block,
                                boolean before)
public static SourceClass addClass(SourceFile file,
                                   java.lang.String name,
                                   int modifiers)
name - the name of the classmodifiers - the modifiers to set on the class
public static SourceClass addInterface(SourceFile file,
                                       java.lang.String name,
                                       int modifiers)
name - the name of the interfacemodifiers - the modifiers to set on the interface
public static void setSuperclass(SourceClass cls,
                                 java.lang.String fqName)
fqName - the fully-qualified class name
public static void addSuperInterface(SourceClass cls,
                                     java.lang.String fqName)
fqName - the name of the interface to add as a super interface
public static SourceMethod addConstructor(SourceClass cls,
                                          int modifiers)
modifiers - the modifiers for the constructorpublic static SourceMethod getDefaultConstructor(SourceClass cls)
public static SourceMethod addMethod(SourceClass cls,
                                     java.lang.String type,
                                     java.lang.String name,
                                     int modifiers)
type - the fully-qualified type for the method return typename - the name of the methodmodifiers - the modifiers for the method
public static SourceMethod addMethod(SourceClass cls,
                                     java.lang.String type,
                                     java.lang.String name,
                                     int modifiers,
                                     SourceMember sibling,
                                     boolean before)
type - the fully-qualified type for the method return typename - the name of the methodmodifiers - the modifiers for the methodsibling - the sibling element to insert relative tobefore - true to insert before the sibling, false for after
public static SourceMember addMember(SourceClass cls,
                                     SourceMember member,
                                     SourceMember sibling,
                                     boolean before)
member - the member to addsibling - the sibling element to insert relative tobefore - true to insert before the sibling, false for after
public static SourceMethod createMethod(SourceClass cls,
                                        java.lang.String type,
                                        java.lang.String name,
                                        int modifiers)
type - the fully-qualified tyep for the method return typename - the name of the methodmodifiers - the modifiers for the method
public static SourceMethod createConstructor(SourceClass cls,
                                             int modifiers)
modifiers - the modifiers for the constructor
public static void addThrows(SourceMethod method,
                             java.lang.String throwName)
throwName - the fully-qualified class name to add
public static void removeThrows(SourceMethod method,
                                java.lang.String throwName)
throwName - the fully-qualified class name to removepublic static SourceMethod addMainMethod(SourceClass cls)
public static SourceMethod createMainMethod(SourceClass cls)
public static SourceMethod getMainMethod(SourceClass cls)
public static SourceMethod getMethod(SourceClass cls,
                                     java.lang.String name,
                                     java.lang.String[] paramTypes)
name - the name of the method to findparamTypes - the fully-qualified parameter types of the method
public static JavaType getType(JavaProvider provider,
                               java.lang.String type)
provider - the provider to usetype - the fully-qualified type name (class, array, primitive)
public static SourceLocalVariable addMethodParameter(SourceMethod method,
                                                     java.lang.String type,
                                                     java.lang.String name)
type - the fully-qualified type for the parametername - the name of the parameter
public static SourceClassInitializer addStaticClassInitializer(SourceClass cls,
                                                               SourceBlock block)
block - the block to use for the initializer
public static SourceDocComment addDocComment(SourceMember member,
                                             java.lang.String descText)
descText - the description to use (if any)
public static SourceDocTag addDocTag(SourceDocComment comment,
                                     java.lang.String tagNameText,
                                     java.lang.String tagText)
tagNameText - the tag name, such as "see"tagText - the tag text, such as "java.lang.String"
public static SourceFieldDeclaration addField(SourceClass cls,
                                              java.lang.String type,
                                              java.lang.String name,
                                              int modifiers,
                                              java.lang.String initText)
type - the fully-qualified type name, such as "java.lang.String"name - the name of the fieldmodifiers - the modifiers for the fieldinitText - the expression text for the initializer, or null for none
public static SourceFieldDeclaration createField(SourceClass cls,
                                                 java.lang.String type,
                                                 java.lang.String name,
                                                 int modifiers,
                                                 java.lang.String initText)
type - the fully-qualified type name, such as "java.lang.String"name - the name of the fieldmodifiers - the modifiers for the fieldinitText - the expression text for the initializer, or null for none
public static SourceFieldDeclaration createField(SourceClass cls,
                                                 java.lang.String fieldText,
                                                 int modifiers)
fieldText - the full text of the field, including the trailing semicolonmodifiers - the modifiers for the field
public static SourceFieldDeclaration createField(SourceClass cls,
                                                 java.lang.String fieldText)
fieldText - the full text of the field, including the trailing semicolon
public static SourceLocalVariable createLocalVariable(SourceFile file,
                                                      java.lang.String type,
                                                      java.lang.String name)
type - the fully-qualified class or primitivetypename - the name of the method parameter or local variable
public static SourceVariableDeclaration addLocalVariableDeclaration(SourceBlock block,
                                                                    java.lang.String type,
                                                                    java.lang.String name,
                                                                    java.lang.String initText)
type - the fully-qualified class or primitive typename - the name of the local variableinitText - the initializer text, or null for none
public static SourceVariableDeclaration addLocalVariableDeclaration(SourceBlock block,
                                                                    java.lang.String type,
                                                                    java.lang.String name,
                                                                    SourceExpression initExpr)
type - the fully-qualified class or primitive typename - the name of the local variableinitExpr - the initializer expression, or null for none
public static SourceExpression createMethodCall(SourceBlock block,
                                                java.lang.String lhs,
                                                java.lang.String methodName,
                                                java.lang.String[] args)
lhs - the expression text for the left-hand side, or null if there is nonemethodName - the name of the method being invokedargs - the arguments for the method call, or null for none
public static SourceExpression createMethodCall(SourceBlock block,
                                                java.lang.String lhs,
                                                java.lang.String methodName,
                                                SourceExpression[] args)
lhs - the expressionn text for the left-hand side, or null if there is nonemethodName - the name of the method being invokedargs - the arguments for the method call, or null for none
public static SourceStatement addMethodCallStatement(SourceBlock block,
                                                     java.lang.String lhs,
                                                     java.lang.String methodName,
                                                     java.lang.String[] args)
lhs - the expressionn text for the left-hand side, or null if there is nonemethodName - the name of the method being invokedargs - the arguments for the method call, or null for none
public static SourceStatement addMethodCallStatement(SourceBlock block,
                                                     java.lang.String lhs,
                                                     java.lang.String methodName,
                                                     SourceExpression[] args)
lhs - the expressionn text for the left-hand side, or null if there is nonemethodName - the name of the method being invokedargs - the arguments for the method call, or null for none
public static SourceExpression createAssign(SourceBlock block,
                                            java.lang.String lhsName,
                                            java.lang.String rhsText)
lhsName - the lhs name, like a variable or field namerhsText - the rhs expression, like a method call expression
public static SourceStatement addAssignStatement(SourceBlock block,
                                                 java.lang.String lhsName,
                                                 java.lang.String rhsText)
lhsName - the lhs name, like a variable or field namerhsText - the rhs expression text, like a method call expression
public static SourceStatement addAssignStatement(SourceBlock block,
                                                 java.lang.String lhsName,
                                                 SourceExpression rhsExpr)
lhsName - the lhs name, like a variable or field namerhsExpr - the rhs expression, like a method call expression
public static SourceStatement addExpressionStatement(SourceBlock block,
                                                     java.lang.String exprText)
exprText - the expression text to add to the block as a statement
public static SourceStatement addExpressionStatement(SourceBlock block,
                                                     SourceExpression expr)
expr - the expression to add to the block as a statement
public static SourceStatement addStatement(SourceBlock block,
                                           java.lang.String stmtText)
stmtText - the statement text to add to the block
public static SourceStatement addExpressionStatement(SourceBlock block,
                                                     java.lang.String exprText,
                                                     SourceElement sibling,
                                                     boolean before)
exprText - the expression text to insertsibling - the sibling element to insert relative tobefore - true to insert before the sibling, false for after
public static SourceStatement addExpressionStatement(SourceBlock block,
                                                     SourceExpression expr,
                                                     SourceElement sibling,
                                                     boolean before)
expr - the expression to insertsibling - the sibling element to insert relative tobefore - true to insert before the sibling, false for after
public static SourceStatement addStatement(SourceBlock block,
                                           SourceStatement stmt,
                                           SourceElement sibling,
                                           boolean before)
stmt - the statement to insertsibling - the sibling element to insert relative totrue - to insert before the sibling, false for after
public static SourceIfStatement addIfStatement(SourceBlock block,
                                               java.lang.String condition,
                                               SourceBlock ifBlock)
condition - the expression text for the if conditionifBlock - the block to use for the if
public static SourceWhileStatement addWhileStatement(SourceBlock block,
                                                     java.lang.String condition,
                                                     SourceBlock whileBlock)
condition - the expression text for the while conditionwhileBlock - the block to use for the while
public static SourceIfStatement addIfElseStatement(SourceBlock block,
                                                   java.lang.String condition,
                                                   SourceBlock ifBlock,
                                                   SourceBlock elseBlock)
condition - the expression text for the if conditionifBlock - the block to use for the ifelseBlock - the block to use for the else
public static SourceStatement addReturn(SourceBlock block,
                                        java.lang.String stmtText)
stmtText - should have the return contents minus the actual return keyword and the trailing semicolon
public static SourceStatement createReturn(SourceBlock block,
                                           java.lang.String stmtText)
stmtText - should have the return contents minus the actual return keyword and the trailing semicolon
public static SourceThrowStatement addThrowStatement(SourceBlock block,
                                                     java.lang.String throwText)
throwText - the throw text, such as "new Exception()"
public static SourceSwitchStatement addSwitchStatement(SourceBlock block,
                                                       java.lang.String switchText,
                                                       SourceBlock switchBlock)
switchText - the text for the switch parensswitchBlock - the block for the switch statement
public static SourceSwitchLabel addSwitchCaseLabel(SourceBlock switchBlock,
                                                   java.lang.String caseText)
caseText - the text for the case label
public static SourceTryStatement addTryCatchStatement(SourceBlock block,
                                                      SourceBlock tryBlock,
                                                      java.lang.String catchType,
                                                      java.lang.String catchName,
                                                      SourceBlock catchBlock)
block - the block to add the try/catch totryBlock - the block for the trycatchType - the catch parameter type, such as "IOException"catchName - the catch parameter name, such as "e"catchBlock - the block for the catchpublic static SourceBlock getFinallyBlock(SourceTryStatement tryStatement)
public static SourceFinallyClause addFinallyClause(SourceTryStatement tryStmt,
                                                   SourceBlock finallyBlock)
public static SourceCatchClause addCatchClause(SourceTryStatement tryStmt,
                                               java.lang.String catchType,
                                               java.lang.String catchName,
                                               SourceBlock catchBlock)
tryStmt - the try statement to add tocatchType - the catch parameter type, such as "IOException"catchName - the catch parameter name, such as "e"catchBlock - the block for the catch
public static SourceTryStatement createTryCatchStatement(SourceBlock block,
                                                         SourceBlock tryBlock,
                                                         java.lang.String catchType,
                                                         java.lang.String catchName,
                                                         SourceBlock catchBlock)
block - the block to add the try/catch totryBlock - the block for the trycatchType - the catch parameter type, such as "IOException"catchName - the catch parameter name, such as "e"catchBlock - the block for the catch
public static SourceVariable getMethodParameter(SourceMethod method,
                                                int index)
index - the parameter index (0-based) to fetchpublic static SourceFactory getFactory(SourceElement element)
public static SourceBlock createBlock(SourceElement element)
| 
 | Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||