com.togethersoft.modules.qa.utils
Class PluginImpl

java.lang.Object
  |
  +--com.togethersoft.modules.qa.utils.PluginImpl
All Implemented Interfaces:
Plugin
Direct Known Subclasses:
AuditPluginImpl, MetricsPluginImpl

public abstract class PluginImpl
extends java.lang.Object
implements Plugin

Plugin implementation - abstract class serving as ancestor for AuditPluginImpl and MetricsPluginImpl


Field Summary
protected  com.togethersoft.openapi.sci.SciClass currCls
          stores the class that is now processed
protected  com.togethersoft.openapi.sci.SciMember currMbr
          stores the member that is now processed
private  javax.swing.JPanel emptyOptionsPane
          Empty options pane.
protected  int level
          nesting level - used internally for the needs of tracing
static int PROC_ATTRS
          specifies that we are processing attributes
static int PROC_OPERS
          specifies that we are processing operations
protected  int procGoal
          Defines wheather we are processing operations (PROC_OPERS), attributes(PROC_ATTRS) or both (PROC_OPERS | PROC_ATTRS)
protected  boolean stopIter
          This flag is used to stop processing.
protected static boolean trace
          trace flag - if you set it to true, default implementation would print debuggung information to the console
 
Constructor Summary
PluginImpl()
           
 
Method Summary
 boolean canProcessByteCode()
          Determines whether plugin can process byte code or not.
 javax.swing.JComponent createOptionsPane()
          Creates additional option pane
protected  void examineExpression(com.togethersoft.openapi.sci.SciExpression expr)
          Is called for each expression.
 java.lang.String getAbbreviation()
          Gets the abbreviated name of plugin.
 boolean getDefaultChoice()
          Determines whether plugin must be chosen by default or not.
 java.lang.String getGroupName()
          Used for grouping of plugin.
 javax.swing.JComponent getOptionsPane()
          returns options panel created earlier by createOptionsPane
abstract  java.lang.String getPropertiesFileName()
          Returns properties file name
 boolean getProperty(java.lang.String propName, boolean defaultValue)
          Retrieves boolean property from plugin properties file.
 int getProperty(java.lang.String propName, int defaultValue)
          Retrieves int property from plugin properties file.
 java.lang.String getProperty(java.lang.String propName, java.lang.String defaultValue)
          Retrieves String property from plugin properties file.
 java.lang.String getTitle()
          Gets the plugin title.
 java.lang.String indent(int level)
          used internally for the needs of tracing
 boolean isByteCode(com.togethersoft.openapi.sci.SciObject obj)
          Is set to true, if the processing unit is in form of byte codes, otherwise is set to false
 boolean isDefaultPkg(com.togethersoft.openapi.sci.SciObject obj)
          Is set to true, if current package is the root package otherwise is set to false
 void load()
          Is called upon plugin creation to perform any additional actions
 boolean prepare()
          Called after user presses the 'Start' button, before processing to carry out some additional work if need.
protected  boolean process(com.togethersoft.openapi.sci.SciObject obj)
          if object obj corresponds to class, sets currCls to this class, currMbr to null and calls processClass(obj)
protected  void processAttrib(com.togethersoft.openapi.sci.SciAttribute attr)
          Is called for each attribute.
Calls processConceptVar method
protected  void processAttribs(com.togethersoft.openapi.sci.SciClass cls)
          Is invoked for each class.
protected  void processCaseStmt(com.togethersoft.openapi.sci.SciCaseStatement cs)
          Is called for each case statement.
protected  void processCatchStmt(com.togethersoft.openapi.sci.SciCatchBlockStatement cs)
          Is called for each catch statement.
protected  void processClass(com.togethersoft.openapi.sci.SciClass cls)
          Is invoked by each class
If procGoal & PROC_ATTRS !
protected  void processCodeBlock(com.togethersoft.openapi.sci.SciCodeBlock cb)
          Is called for each code block.
protected  void processCompStmt(com.togethersoft.openapi.sci.SciCompoundStatement cs)
          Is called for each compound statement.
protected  void processConceptVar(com.togethersoft.openapi.sci.SciVariable var)
          Is called for each atribute, parameter, or local variable.
protected  void processDeclStmt(com.togethersoft.openapi.sci.SciDeclarationStatement ds)
          Is called for each declaration statement Default implementation calls processLocalVar for each declaration in statement.
protected  void processExpression(com.togethersoft.openapi.sci.SciExpression expr)
          Is called for each expression, including expressions in function calls, conditional or loop statements and so on Default implementation calls examineExpression, then calls processExpression for each expression's operand
protected  void processExprStmt(com.togethersoft.openapi.sci.SciExpressionStatement es)
          Is called for each expression.
protected  void processIfStmt(com.togethersoft.openapi.sci.SciIfStatement is)
          Is called for each if statement.
protected  void processInitValue(com.togethersoft.openapi.sci.SciExpression expr)
          Is called for each initialization part of class attribute or local variable.
protected  void processLocalVar(com.togethersoft.openapi.sci.SciVariable var)
          Is called for each local variable.
protected  void processLoopStmt(com.togethersoft.openapi.sci.SciLoopStatement ls)
          Is called for each loop statement (i.e.
protected  void processOper(com.togethersoft.openapi.sci.SciOperation opr)
          Is called for each operation.
Default implementation calls processParam for each parameter of given operation (if any), processThrowSpec for each exception in the throw list of operation (if any) and then calls processCodeBlock for the body of operation
protected  void processOpers(com.togethersoft.openapi.sci.SciClass cls)
          Is invoked for each class.
protected  void processParam(com.togethersoft.openapi.sci.SciParameter param)
          Is called for each parameter of the operation.
Default implementation calls processConceptVar for this parameter
protected  void processReturnStmt(com.togethersoft.openapi.sci.SciReturnStatement rs)
          Is called for each return statement.
protected  void processStatement(com.togethersoft.openapi.sci.SciStatement stmt)
          Is called for each statement within code block.
protected  void processSwitchStmt(com.togethersoft.openapi.sci.SciSwitchStatement ss)
          Is called for each switch statement.
protected  void processThrowSpec(com.togethersoft.openapi.sci.SciThrowSpecifier thr)
          Is called for each exception in the operation throw list.
protected  void processThrowStmt(com.togethersoft.openapi.sci.SciThrowStatement ts)
          Is called for each throw statement.
protected  void processTryStmt(com.togethersoft.openapi.sci.SciTryStatement ts)
          Is called for each try-catch statement; Default implementation calls processStatement for the try part and for each of catch parts
 void putProperty(java.lang.String propName, boolean value)
          Puts boolean property from plugin properties file.
 void putProperty(java.lang.String propName, int value)
          Puts int property from plugin properties file.
 void putProperty(java.lang.String propName, java.lang.String value)
          Puts String property from plugin properties file.
 void restoreOptions()
          Is used to restore options from the properties file.
 boolean storeOptions()
          Is invoked when user presses 'Start' button.
 void traceAttr(com.togethersoft.openapi.sci.SciAttribute attr)
          traces attribute
 void traceExpr(com.togethersoft.openapi.sci.SciExpression expr)
          traces expression
 void traceOper(com.togethersoft.openapi.sci.SciOperation opr)
          traces operation
 void traceStmt(com.togethersoft.openapi.sci.SciStatement stmt)
          traces statement
 void traceVar(java.lang.String kind, com.togethersoft.openapi.sci.SciVariable var)
          traces variable
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface com.togethersoft.modules.qa.api.Plugin
getDescriptionFileName
 

Field Detail

emptyOptionsPane

private javax.swing.JPanel emptyOptionsPane
Empty options pane.

currCls

protected com.togethersoft.openapi.sci.SciClass currCls
stores the class that is now processed

currMbr

protected com.togethersoft.openapi.sci.SciMember currMbr
stores the member that is now processed

stopIter

protected boolean stopIter
This flag is used to stop processing. If any method sets it to true, processing is stopped

level

protected int level
nesting level - used internally for the needs of tracing

trace

protected static boolean trace
trace flag - if you set it to true, default implementation would print debuggung information to the console

procGoal

protected int procGoal
Defines wheather we are processing operations (PROC_OPERS), attributes(PROC_ATTRS) or both (PROC_ATTRS | PROC_OPERS)

PROC_ATTRS

public static final int PROC_ATTRS
specifies that we are processing attributes

PROC_OPERS

public static final int PROC_OPERS
specifies that we are processing operations
Constructor Detail

PluginImpl

public PluginImpl()
Method Detail

load

public void load()
Description copied from interface: Plugin
Is called upon plugin creation to perform any additional actions
Specified by:
load in interface Plugin

getTitle

public java.lang.String getTitle()
Gets the plugin title. This title is displayed in the plugins list and results table.
Specified by:
getTitle in interface Plugin
Returns:
The plugin title

getGroupName

public java.lang.String getGroupName()
Used for grouping of plugin. Gets the name of plugin group.
Specified by:
getGroupName in interface Plugin
Returns:
the name of plugin group.

getAbbreviation

public java.lang.String getAbbreviation()
Gets the abbreviated name of plugin. Abbreviation is displayed in the plugin list and results table.
Specified by:
getAbbreviation in interface Plugin
Returns:
the abbreviated name of plugin.

getDefaultChoice

public boolean getDefaultChoice()
Determines whether plugin must be chosen by default or not.
Specified by:
getDefaultChoice in interface Plugin
Returns:
true if plugin must be chosen by default, otherwise false.

createOptionsPane

public javax.swing.JComponent createOptionsPane()
Creates additional option pane
Specified by:
createOptionsPane in interface Plugin
Returns:
option pane (JComponent descendant)

getOptionsPane

public javax.swing.JComponent getOptionsPane()
returns options panel created earlier by createOptionsPane
Specified by:
getOptionsPane in interface Plugin
Returns:
options panel (JComponent descendant)

restoreOptions

public void restoreOptions()
Description copied from interface: Plugin
Is used to restore options from the properties file.
Specified by:
restoreOptions in interface Plugin

storeOptions

public boolean storeOptions()
Is invoked when user presses 'Start' button. Stores options selected with user in class variables and in the properties file. If returns false, further processing is stopped.
Specified by:
storeOptions in interface Plugin
Returns:
true if options are stored successfuly, otherwise false

prepare

public boolean prepare()
Called after user presses the 'Start' button, before processing to carry out some additional work if need. If returns false, further processing is stopped.
Specified by:
prepare in interface Plugin
Returns:
true to proceed, or false to stop further processing

canProcessByteCode

public boolean canProcessByteCode()
Determines whether plugin can process byte code or not.
Specified by:
canProcessByteCode in interface Plugin
Returns:
true if plugin can process byte code, otherwise false

getPropertiesFileName

public abstract java.lang.String getPropertiesFileName()
Returns properties file name
Specified by:
getPropertiesFileName in interface Plugin
Returns:
properties file name

getProperty

public java.lang.String getProperty(java.lang.String propName,
                                    java.lang.String defaultValue)
Retrieves String property from plugin properties file.
Parameters:
propName - property name
defaultValue - default value

getProperty

public int getProperty(java.lang.String propName,
                       int defaultValue)
Retrieves int property from plugin properties file.
Parameters:
propName - property name
defaultValue - default value

getProperty

public boolean getProperty(java.lang.String propName,
                           boolean defaultValue)
Retrieves boolean property from plugin properties file.
Parameters:
propName - property name
defaultValue - default value

putProperty

public void putProperty(java.lang.String propName,
                        java.lang.String value)
Puts String property from plugin properties file.
Parameters:
propName - property name
value - value to store

putProperty

public void putProperty(java.lang.String propName,
                        int value)
Puts int property from plugin properties file.
Parameters:
propName - property name
value - value to store

putProperty

public void putProperty(java.lang.String propName,
                        boolean value)
Puts boolean property from plugin properties file.
Parameters:
propName - property name
value - value to store

indent

public java.lang.String indent(int level)
used internally for the needs of tracing

traceAttr

public void traceAttr(com.togethersoft.openapi.sci.SciAttribute attr)
traces attribute
Parameters:
attr - attribute to trace

traceOper

public void traceOper(com.togethersoft.openapi.sci.SciOperation opr)
traces operation
Parameters:
opr - attribute to trace

traceStmt

public void traceStmt(com.togethersoft.openapi.sci.SciStatement stmt)
traces statement
Parameters:
stmt - statement to trace

traceExpr

public void traceExpr(com.togethersoft.openapi.sci.SciExpression expr)
traces expression
Parameters:
expr - expression to trace

traceVar

public void traceVar(java.lang.String kind,
                     com.togethersoft.openapi.sci.SciVariable var)
traces variable
Parameters:
expr - variable to trace

isByteCode

public boolean isByteCode(com.togethersoft.openapi.sci.SciObject obj)
Is set to true, if the processing unit is in form of byte codes, otherwise is set to false

isDefaultPkg

public boolean isDefaultPkg(com.togethersoft.openapi.sci.SciObject obj)
Is set to true, if current package is the root package otherwise is set to false

process

protected boolean process(com.togethersoft.openapi.sci.SciObject obj)
if object obj corresponds to class, sets currCls to this class, currMbr to null and calls processClass(obj)
Parameters:
obj - object to process
Returns:
true to proceed, or false to stop further processing Default implementation always returns true

processClass

protected void processClass(com.togethersoft.openapi.sci.SciClass cls)
Is invoked by each class
If procGoal & PROC_ATTRS != 0
calls processAttribs(cls); If procGoal & PROC_OPERS != 0
calls processOpers(cls) If stopIter flag is set, stops processing
Parameters:
cls - class to process

processAttribs

protected void processAttribs(com.togethersoft.openapi.sci.SciClass cls)
Is invoked for each class. Processes its attributes.
Default implementation calls processAttrib for each class attribute. Before calling processAttrib it sets currMbr to the current atribute. If stopIter flag is set, stops processing
Parameters:
cls - class to process

processAttrib

protected void processAttrib(com.togethersoft.openapi.sci.SciAttribute attr)
Is called for each attribute.
Calls processConceptVar method
Parameters:
attr - attribute

processOpers

protected void processOpers(com.togethersoft.openapi.sci.SciClass cls)
Is invoked for each class. Processes its operations.
Default implementation calls processOper method for each operation. Before calling processOper, it sets currMbr to the current operation If stopIter flag is set, stops processing
Parameters:
cls - class to process

processOper

protected void processOper(com.togethersoft.openapi.sci.SciOperation opr)
Is called for each operation.
Default implementation calls processParam for each parameter of given operation (if any), processThrowSpec for each exception in the throw list of operation (if any) and then calls processCodeBlock for the body of operation
Parameters:
opr - operation

processParam

protected void processParam(com.togethersoft.openapi.sci.SciParameter param)
Is called for each parameter of the operation.
Default implementation calls processConceptVar for this parameter
Parameters:
param - parameter of the operation

processThrowSpec

protected void processThrowSpec(com.togethersoft.openapi.sci.SciThrowSpecifier thr)
Is called for each exception in the operation throw list.
Parameters:
thr - throw specifier

processCodeBlock

protected void processCodeBlock(com.togethersoft.openapi.sci.SciCodeBlock cb)
Is called for each code block. Goes through all statements within given code block and calls processStatement for each statement.
Parameters:
cb - code block

processStatement

protected void processStatement(com.togethersoft.openapi.sci.SciStatement stmt)
Is called for each statement within code block. Examines kind of statement and calls
processCaseStmt,
processCatchStmt,
processSwitchStmt,
processCompStmt,
processDeclStmt,
processExprStmt,
processIfStmt,
processLoopStmt,
processReturnStmt,
processThrowStmt or
processTryStmt
depending on the kind of statement
Parameters:
stmt - statement

processCaseStmt

protected void processCaseStmt(com.togethersoft.openapi.sci.SciCaseStatement cs)
Is called for each case statement. Default implementation calls processExpression(cs)
Parameters:
cs - case statement

processCatchStmt

protected void processCatchStmt(com.togethersoft.openapi.sci.SciCatchBlockStatement cs)
Is called for each catch statement. Default implementation calls processCodeBlock for the statement body
Parameters:
cs - catch statement

processCompStmt

protected void processCompStmt(com.togethersoft.openapi.sci.SciCompoundStatement cs)
Is called for each compound statement. Default implementation calls processCodeBlock for the statement body
Parameters:
cs - catch statement

processDeclStmt

protected void processDeclStmt(com.togethersoft.openapi.sci.SciDeclarationStatement ds)
Is called for each declaration statement Default implementation calls processLocalVar for each declaration in statement.
Parameters:
ds - declaration statement

processExprStmt

protected void processExprStmt(com.togethersoft.openapi.sci.SciExpressionStatement es)
Is called for each expression. For each declaration in statement calls processExpression for this expression.
Parameters:
es - expression

processIfStmt

protected void processIfStmt(com.togethersoft.openapi.sci.SciIfStatement is)
Is called for each if statement. Calls processExpression for condition expression, processCodeBlock for then and else branches.
Parameters:
is - if statement

processLoopStmt

protected void processLoopStmt(com.togethersoft.openapi.sci.SciLoopStatement ls)
Is called for each loop statement (i.e. for, while or do... while statement) Default implementation calls processStatement for the initialization part and iteration part of for, processExpression for the repeat and exit conditions, and processCodeBlock for the loop body.
Parameters:
ls - loop statement

processReturnStmt

protected void processReturnStmt(com.togethersoft.openapi.sci.SciReturnStatement rs)
Is called for each return statement. Default implementation calls processExpression
Parameters:
rs - return statement

processSwitchStmt

protected void processSwitchStmt(com.togethersoft.openapi.sci.SciSwitchStatement ss)
Is called for each switch statement. Default implementation calls processExpression for the switch expression and processCodeBlock for the code block
Parameters:
switch - switch statement

processThrowStmt

protected void processThrowStmt(com.togethersoft.openapi.sci.SciThrowStatement ts)
Is called for each throw statement. Default implementation calls processExpression
Parameters:
ts - throw statement

processTryStmt

protected void processTryStmt(com.togethersoft.openapi.sci.SciTryStatement ts)
Is called for each try-catch statement; Default implementation calls processStatement for the try part and for each of catch parts
Parameters:
ts - try statement

processLocalVar

protected void processLocalVar(com.togethersoft.openapi.sci.SciVariable var)
Is called for each local variable. Default implementation calls processConceptVar
Parameters:
var - local variable

processConceptVar

protected void processConceptVar(com.togethersoft.openapi.sci.SciVariable var)
Is called for each atribute, parameter, or local variable. Default implementation calls processInitValue for the initialisation part.
Parameters:
var - atribute, parameter, or local variable

processInitValue

protected void processInitValue(com.togethersoft.openapi.sci.SciExpression expr)
Is called for each initialization part of class attribute or local variable. Default implementation calls processExpression

processExpression

protected void processExpression(com.togethersoft.openapi.sci.SciExpression expr)
Is called for each expression, including expressions in function calls, conditional or loop statements and so on Default implementation calls examineExpression, then calls processExpression for each expression's operand
Parameters:
expr - expression

examineExpression

protected void examineExpression(com.togethersoft.openapi.sci.SciExpression expr)
Is called for each expression. Just for overriding - default implementation does nothing.
Parameters:
expr - expression