Rational Developer for Power Systems Software
V7.6

com.ibm.etools.iseries.edit.sql.SQLStatements
Class SQLStatement

java.lang.Object
  extended by com.ibm.etools.iseries.edit.sql.SQLStatements.SQLStatement
All Implemented Interfaces:
ISQLItem

public class SQLStatement
extends Object
implements ISQLItem


Field Summary
static String Copyright
           
static String EOL
           
 
Constructor Summary
protected SQLStatement(SQLStatement statement)
          Constructor which allows creating a statement from another statement object
protected SQLStatement(String name, Properties statementProperties)
          Constructor which allows passing in properties
protected SQLStatement(String name, Properties statementProperties, boolean isControlStatement)
          The main contructor for this class
 
Method Summary
 boolean allowsBlanksWithOperator(char c)
          Indicate whether or not this statement allows blanks around the specified operator
 void appendComment(StringBuffer comment)
          Appends a comment to the existing comment for this item
 void appendCommentChar(char c)
          Appends a character to the comment buffer for this item
 void decreaseBracketLevel()
          Used to keep track of nexted brackets
 int getBracketLevel()
          Used to retrieves the bracket leve
 int getBreakIndent(String breakKwd)
          Retreives the indent level to be used by the specified break keyword.
 StringBuffer getCommentBuffer()
          Retrieves the comment buffer for this item
 int getIndentLength()
          Retrieves the indent length for this statement
 boolean getIsBreakOnKwd()
          Retrieves whether or not the statement has broken on a keyword
 int getLabelLength()
          Retrieves the length of the label
 Vector<String> getMatchingStatement()
          Indicates the list of statements to match.
 String getName()
          Retrieves the name of the statement
 String getNextWordAfterForNeeded()
          Returns the next word after FOR needed to determin if the FOR is just a keyword or a control statement
protected  Properties getProperties()
          Retrieves the properties for the statement
 StringBuffer getStartingBuffer()
          Retrieves the starting buffer for this item.
 int getStartingBufferPosition()
          Retrieves the position in the starting buffer that the statement is at
 Vector<String> getStopAtIndentStrings()
          Retrieves the list of string to stop at when indenting for formatting
 Vector<String> getStopAtStrings()
          Retrieves the list of string to stop at when formatting
 boolean hasEnd()
          Indicates whether or not this statement has an end to match
 void increaseBracketLevel()
          Used to keep track of nested brackets
 boolean inFullSelect()
          Inidcates whether or not this statement is in a full select.
 boolean isBeginStatement()
          Indicates whether or not this statement is a begin statement
 boolean isBreakOnKwd(String kwd)
          Indicates whether the specified keyword is a break keyword for this statement
 boolean isBreakOnWordAfter(String breakKwd)
          Indicates whether or not the keyword is a for breaking on the word after
 boolean isBreakStyleAfter(String breakKwd)
          Retreives the break style for the break keyword
 boolean isCaseStatement()
          Indicates whether or not the statement is a case statement
 boolean isClause()
          Indicates whether or not this statement is a clause.
 boolean isCommit()
          Indicates whether or not this is a COMMIT statement
 boolean isControlStatement()
          Indicates whether or not the statement is a control statement.
 boolean isCreateProcedure()
          Indicates whether or not the statement is a CREATE PROCEDURE statement
 boolean isElse()
          Indicates whether or not the current statement is a ELSE statement
 boolean isEndStatement()
          Indicates whether or not this is an end statement
 boolean isFirstMultiBreakOnWord(String text)
          Indicates whether or not the word specified is part of a multi word break on keyword sequence
 boolean isFitsOnOneLine()
          Indicates whether or not the statement fits on one line
 boolean isForStatement()
          Inidcates whether or not this statement is a FOR statement
 boolean isGetDiagnosticsStatement()
          Indicates whether or not this is a get diagnsotics statement
 boolean isKeepOnOneLine()
          Indicates whether or not this statement should be kept on one line if possible
 boolean isMatchingEnd(SQLStatement end)
          Indicates whether or not the specified statement is an end statement that matches this one
 boolean isMultiWordBreakOn()
          Indicates whether or not this statement had break on keywords that consist of more than one word
 boolean isNested()
          Indicates if this is a nested case statement/clause
 boolean isNestedCase()
          Retrieves whether or not this case is nested within another statement
 boolean isNestedStatementAllowed(SQLStatement statement)
          Indicates whether or not the statement allows nested statements without semicolons
 boolean isNextWordAfterForNeeded()
          Determines whether or not the next word after FOR needs to be checked
 boolean isPredicate()
          Indicates whether or not the statement is a predicate
 boolean isReturn()
          Indicates whether or not the current statement is RETURN
 boolean isSavepoint()
          Indicates whether orn this command is a SAVEPOINT comment
 boolean isSelectStatement()
          Indicates whether or not this is a select statement
 boolean isSplitOnCommasAllowed()
          Indicates whether or not the statement allows splitting on commas
 boolean isStartMultiBreakOnWord(String text)
           
 boolean isStartOnNewLine()
          Indicates whether or not the statement needs to be started on a new line
 boolean isStatementAllowed(StringBuffer statementBuffer, ISQLItem currentItem)
          Hanldes exception scenarios where isNestedStatement allowed does not work
 boolean isStopAtAfter(String stopString)
          Indicates whether the formatter should stop before or after the "stop at string".
 boolean isStopAtIndentString(String text)
           
 boolean isStopAtString(String text)
           
 boolean isStopOnControlStatement()
          Indicates whether or not the statement should stop formatting on control statements
 boolean isStopOnStatement()
          Indicates whether or not the statement should stop formatting on statements
 boolean isTwoWordStatement()
          Indicates whether or not the statement requires two word to be correctly parsed
 boolean isUseAndOrPreference()
          Indicates whether or not the statement should use the split on and/or prefernece
 boolean isWhen()
          Indicates whether or not the current statement is a WHEN statement
 boolean isWithStatement()
          Indicates whether or not the statement is a WITH statement
 void setFitsOnOneLine(boolean value)
          Sets whether or not this statement fits on one line.
 void setIndentLength(int length)
          Sets the indent length value for this statement
 void setIsBreakOnKwd(String testKwd)
           
 void setIsClause(boolean value)
          Sets whether or not this is a clause
 void setIsNestedCase(boolean value)
          Sets whether or not this case is nested within another statement
 void setIsPredicate(boolean value)
          Sets whether or not the statment is a predicate
 void setLabelLength(int value)
          Sets the length of the label
 void setStartingBuffer(StringBuffer start)
          Sets the starting buffer for this item.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Copyright

public static final String Copyright
See Also:
Constant Field Values

EOL

public static final String EOL
See Also:
Constant Field Values
Constructor Detail

SQLStatement

protected SQLStatement(SQLStatement statement)
Constructor which allows creating a statement from another statement object

Parameters:
statement - the statement to copy

SQLStatement

protected SQLStatement(String name,
                       Properties statementProperties)
Constructor which allows passing in properties

Parameters:
name - the name of the statement
statementProperties - the properties of the statement

SQLStatement

protected SQLStatement(String name,
                       Properties statementProperties,
                       boolean isControlStatement)
The main contructor for this class

Parameters:
name - the name of the statement
statementProperties - the properties for the statement
isControlStatement - true if this is a control statement, false otherwise
Method Detail

allowsBlanksWithOperator

public boolean allowsBlanksWithOperator(char c)
Indicate whether or not this statement allows blanks around the specified operator

Parameters:
c - the operator to check
Returns:
true if the operator should get blank padded, false otherwise

appendComment

public void appendComment(StringBuffer comment)
Description copied from interface: ISQLItem
Appends a comment to the existing comment for this item

Specified by:
appendComment in interface ISQLItem
Parameters:
comment - the comment to append

appendCommentChar

public void appendCommentChar(char c)
Description copied from interface: ISQLItem
Appends a character to the comment buffer for this item

Specified by:
appendCommentChar in interface ISQLItem
Parameters:
c - the character to append

decreaseBracketLevel

public void decreaseBracketLevel()
Description copied from interface: ISQLItem
Used to keep track of nexted brackets

Specified by:
decreaseBracketLevel in interface ISQLItem

getBracketLevel

public int getBracketLevel()
Description copied from interface: ISQLItem
Used to retrieves the bracket leve

Specified by:
getBracketLevel in interface ISQLItem
Returns:
the number of open brackets that are not closed.

getBreakIndent

public int getBreakIndent(String breakKwd)
Retreives the indent level to be used by the specified break keyword. Default is 1 level of indent

Parameters:
breakKwd - The break keyword to check
Returns:
the levelof indent to use for the break keyword

getCommentBuffer

public StringBuffer getCommentBuffer()
Description copied from interface: ISQLItem
Retrieves the comment buffer for this item

Specified by:
getCommentBuffer in interface ISQLItem
Returns:
the comment buffer for this item

getIndentLength

public int getIndentLength()
Retrieves the indent length for this statement

Returns:
The number of blanks to indent this statement

getIsBreakOnKwd

public boolean getIsBreakOnKwd()
Retrieves whether or not the statement has broken on a keyword

Returns:
tru if the statment has broken on a keyword false otherwise.

getLabelLength

public int getLabelLength()
Retrieves the length of the label

Returns:
the length of the label for this statement, or 0 if there is no label

getMatchingStatement

public Vector<String> getMatchingStatement()
Indicates the list of statements to match. Use to determine correct indent

Returns:
the list of matching statements

getName

public String getName()
Retrieves the name of the statement

Specified by:
getName in interface ISQLItem
Returns:
the name of the statement

getNextWordAfterForNeeded

public String getNextWordAfterForNeeded()
Returns the next word after FOR needed to determin if the FOR is just a keyword or a control statement

Returns:
the next word needed, null if no word is needed.

getProperties

protected Properties getProperties()
Retrieves the properties for the statement

Returns:
the properties set for this statement

getStartingBuffer

public StringBuffer getStartingBuffer()
Description copied from interface: ISQLItem
Retrieves the starting buffer for this item. Used to handle when comments are placed at the top of this item.

Specified by:
getStartingBuffer in interface ISQLItem
Returns:
the starting buffer

getStartingBufferPosition

public int getStartingBufferPosition()
Description copied from interface: ISQLItem
Retrieves the position in the starting buffer that the statement is at

Specified by:
getStartingBufferPosition in interface ISQLItem
Returns:
the position in the starting statement buffer

getStopAtIndentStrings

public Vector<String> getStopAtIndentStrings()
Retrieves the list of string to stop at when indenting for formatting

Returns:
a vector of stop at indent strings

getStopAtStrings

public Vector<String> getStopAtStrings()
Retrieves the list of string to stop at when formatting

Returns:
a vector of stop at strings

hasEnd

public boolean hasEnd()
Indicates whether or not this statement has an end to match

Returns:
tru if this statement has an end, false otherwise

increaseBracketLevel

public void increaseBracketLevel()
Description copied from interface: ISQLItem
Used to keep track of nested brackets

Specified by:
increaseBracketLevel in interface ISQLItem

inFullSelect

public boolean inFullSelect()
Inidcates whether or not this statement is in a full select.

Returns:
true if in a full select, false otherwise

isBeginStatement

public boolean isBeginStatement()
Indicates whether or not this statement is a begin statement

Returns:
true if this is a BEGIN statement, false otherwise

isBreakOnKwd

public boolean isBreakOnKwd(String kwd)
Indicates whether the specified keyword is a break keyword for this statement

Parameters:
kwd - the keyword to check
Returns:
true if it is a break keyword, false otherwise.

isBreakOnWordAfter

public boolean isBreakOnWordAfter(String breakKwd)
Indicates whether or not the keyword is a for breaking on the word after

Parameters:
breakKwd - the keyword to check
Returns:
true if we are to break after the word after, false otherwise

isBreakStyleAfter

public boolean isBreakStyleAfter(String breakKwd)
Retreives the break style for the break keyword

Parameters:
breakKwd - The break keyword to check
Returns:
the levelof indent to use for the break keyword

isCaseStatement

public boolean isCaseStatement()
Indicates whether or not the statement is a case statement

Returns:

isClause

public boolean isClause()
Indicates whether or not this statement is a clause. Use to determine correct indent

Returns:
true if this is a clause, false if this is a true statement

isCommit

public boolean isCommit()
Indicates whether or not this is a COMMIT statement

Returns:
true if this is a commit statement, false otherwise.

isControlStatement

public boolean isControlStatement()
Indicates whether or not the statement is a control statement.

Returns:
true if the statement is a control statement, false otherwise.

isCreateProcedure

public boolean isCreateProcedure()
Indicates whether or not the statement is a CREATE PROCEDURE statement

Returns:
true if this is a CREATE PROCEDURE statement, false otherwise

isElse

public boolean isElse()
Indicates whether or not the current statement is a ELSE statement

Returns:
true if the statement is a ELSE, false otherwise

isEndStatement

public boolean isEndStatement()
Indicates whether or not this is an end statement

Returns:
true if this is an END, false otherwise.

isFirstMultiBreakOnWord

public boolean isFirstMultiBreakOnWord(String text)
Indicates whether or not the word specified is part of a multi word break on keyword sequence

Parameters:
text - the text to check
Returns:
true if the text starts a multi-word break on sequence

isFitsOnOneLine

public boolean isFitsOnOneLine()
Indicates whether or not the statement fits on one line

Returns:
true if the statement fits on one line, false otherwise

isForStatement

public boolean isForStatement()
Inidcates whether or not this statement is a FOR statement

Returns:
true if this statement is a for statement, false otherwise

isGetDiagnosticsStatement

public boolean isGetDiagnosticsStatement()
Indicates whether or not this is a get diagnsotics statement

Returns:
true if this is sucha statement false otherwise

isKeepOnOneLine

public boolean isKeepOnOneLine()
Indicates whether or not this statement should be kept on one line if possible

Returns:
true if the statement should be kept on one line, false otherwise.

isMatchingEnd

public boolean isMatchingEnd(SQLStatement end)
Indicates whether or not the specified statement is an end statement that matches this one

Parameters:
end - the end statement to check
Returns:
true is the specified statement matches this statement.

isMultiWordBreakOn

public boolean isMultiWordBreakOn()
Indicates whether or not this statement had break on keywords that consist of more than one word

Returns:
true if this statement had break on keywords that consist of more than one word, false otherwise

isNested

public boolean isNested()
Indicates if this is a nested case statement/clause

Returns:
return true is nested statement/clause, false otherwise

isNestedCase

public boolean isNestedCase()
Retrieves whether or not this case is nested within another statement

Returns:
true if this is a nested case, false otherwise

isNestedStatementAllowed

public boolean isNestedStatementAllowed(SQLStatement statement)
Indicates whether or not the statement allows nested statements without semicolons

Returns:
true if the statement is allowed to split on commas, false otherwise

isNextWordAfterForNeeded

public boolean isNextWordAfterForNeeded()
Determines whether or not the next word after FOR needs to be checked

Returns:
true if the next word needs to be checked, false otherwise

isPredicate

public boolean isPredicate()
Indicates whether or not the statement is a predicate

Returns:
true if the statement is a predicate, false otherwise

isReturn

public boolean isReturn()
Indicates whether or not the current statement is RETURN

Returns:
true if the statement is a RETURN, false otherwise.

isSavepoint

public boolean isSavepoint()
Indicates whether orn this command is a SAVEPOINT comment

Returns:
true if this is SAVEPOINT, false otherwise.

isSelectStatement

public boolean isSelectStatement()
Indicates whether or not this is a select statement

Returns:
true if this is a SELECT statement, false otherwise.

isSplitOnCommasAllowed

public boolean isSplitOnCommasAllowed()
Indicates whether or not the statement allows splitting on commas

Specified by:
isSplitOnCommasAllowed in interface ISQLItem
Returns:
true if the statement is allowed to split on commas, false otherwise

isStartMultiBreakOnWord

public boolean isStartMultiBreakOnWord(String text)

isStartOnNewLine

public boolean isStartOnNewLine()
Indicates whether or not the statement needs to be started on a new line

Returns:
true if the stement keyword needs to start a new line.

isStatementAllowed

public boolean isStatementAllowed(StringBuffer statementBuffer,
                                  ISQLItem currentItem)
Hanldes exception scenarios where isNestedStatement allowed does not work

Parameters:
statementBuffer - the statement buffer to check
Returns:
true if the statement is allowed, false otherwise

isStopAtAfter

public boolean isStopAtAfter(String stopString)
Indicates whether the formatter should stop before or after the "stop at string".

Parameters:
the - stop string to check the setting for
Returns:
true if the formatter is to stop at after the "stop at string", false otherwise

isStopAtIndentString

public boolean isStopAtIndentString(String text)

isStopAtString

public boolean isStopAtString(String text)

isStopOnControlStatement

public boolean isStopOnControlStatement()
Indicates whether or not the statement should stop formatting on control statements

Returns:
true if the statement should stop formatting on control statements.

isStopOnStatement

public boolean isStopOnStatement()
Indicates whether or not the statement should stop formatting on statements

Returns:
true if the statement should stop formatting on statements.

isTwoWordStatement

public boolean isTwoWordStatement()
Indicates whether or not the statement requires two word to be correctly parsed

Returns:
true if the statement requires two words, false otherwise

isUseAndOrPreference

public boolean isUseAndOrPreference()
Indicates whether or not the statement should use the split on and/or prefernece

Returns:
true if the statement is allowed to use the preference, false otherwise

isWhen

public boolean isWhen()
Indicates whether or not the current statement is a WHEN statement

Returns:
true if the statement is a WHEN, false otherwise

isWithStatement

public boolean isWithStatement()
Indicates whether or not the statement is a WITH statement

Returns:

setFitsOnOneLine

public void setFitsOnOneLine(boolean value)
Sets whether or not this statement fits on one line. Once the fits on one line is set to false, it cannot be reset to true

Parameters:
value - true if the statement fit on one line, false otherwise

setIndentLength

public void setIndentLength(int length)
Sets the indent length value for this statement

Parameters:
length - the number of blanks to indent this command

setIsBreakOnKwd

public void setIsBreakOnKwd(String testKwd)

setIsClause

public void setIsClause(boolean value)
Sets whether or not this is a clause


setIsNestedCase

public void setIsNestedCase(boolean value)
Sets whether or not this case is nested within another statement

Parameters:
value - true if this is a nested case, false otherwise

setIsPredicate

public void setIsPredicate(boolean value)
Sets whether or not the statment is a predicate

Parameters:
value - true if the statement is a predicate, false otherwise

setLabelLength

public void setLabelLength(int value)
Sets the length of the label

Parameters:
value - the length of the label for this statement

setStartingBuffer

public void setStartingBuffer(StringBuffer start)
Description copied from interface: ISQLItem
Sets the starting buffer for this item. Used to handle when comments are placed at the top of this item.

Specified by:
setStartingBuffer in interface ISQLItem
Parameters:
start - the starting buffer

toString

public String toString()
Overrides:
toString in class Object

Rational Developer for Power Systems Software
V7.6

Copyright © 2011 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.