Dresden OCL Toolkit

tudresden.ocl.injection
Class Instrumentor

java.lang.Object
  extended bytudresden.ocl.injection.Instrumentor
All Implemented Interfaces:
InjectionConsumer

public final class Instrumentor
extends Object
implements InjectionConsumer


Field Summary
static String BACKUP_SUFFIX
           
static String CHANGED_CHECKER
           
private  InstrumentorClass class_state
          Holds several properties of the class currently worked on.
private  ArrayList class_state_stack
          Collects the class states of outer classes, when operating on a inner class.
private  boolean clean
           
private  InstrumentorConfig config
           
private  boolean delayinsertions
           
private  boolean discardnextfeature
           
private  String identityhashcode
           
protected  String lineSeparator
           
private  String m_sFileDocComment
          The last file level doccomment that was read.
static String OCL_AUTHOR
          All generated class features get this string as author.
private  Writer output
           
 
Constructor Summary
Instrumentor(Writer output, InstrumentorConfig config)
           
 
Method Summary
private  boolean isCollection(JavaFeature jf)
          Returns, whether the type of the given java feature is a collection or not.
private  boolean isWeaklyTyped(JavaFeature jf)
          Returns, whether the type of the given java feature can be typed by element-type tags or not.
 void onAttributeHeader(JavaAttribute ja)
          Encountered the header of a java attribute.
 void onBehaviourHeader(JavaBehaviour jb)
          Encountered the header of a java method.
 void onClass(JavaClass jc)
          Encountered a class header.
 void onClassEnd(JavaClass jc)
          Encountered the end of a class.
 void onClassFeature(JavaFeature jf, String doccomment)
          Called for attributes and methods.
 boolean onDocComment(String doccomment)
          Encountered a java documentation comment.
 void onFileDocComment(String doccomment)
          Encountered a java documentation comment.
 void onFileEnd()
          Encountered the end of the input stream.
 void onImport(String importname)
          Encountered an import statement.
 void onPackage(JavaFile javafile)
          Encountered a package statement.
private  void writeBackup(JavaFeature jf)
           
private  void writeCall(JavaMethod jm)
           
private  void writeChangedChecker()
           
private  void writeChangedCheckerCall()
           
private  void writeDefaultConstructor(JavaClass jc)
          See Java Language Specification 8.6.7 "Default Constructor"
private  void writeWrapper(JavaBehaviour jb)
           
private  void writeWrapper(JavaConstructor jc)
           
private  void writeWrapper(JavaMethod jm)
           
private  void writeWrapperHeader(JavaBehaviour jb)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

output

private final Writer output

delayinsertions

private final boolean delayinsertions

clean

private final boolean clean

config

private final InstrumentorConfig config

identityhashcode

private final String identityhashcode

class_state

private InstrumentorClass class_state
Holds several properties of the class currently worked on.


class_state_stack

private ArrayList class_state_stack
Collects the class states of outer classes, when operating on a inner class.

See Also:
class_state

lineSeparator

protected String lineSeparator

m_sFileDocComment

private String m_sFileDocComment
The last file level doccomment that was read.


discardnextfeature

private boolean discardnextfeature

OCL_AUTHOR

public static final String OCL_AUTHOR
All generated class features get this string as author. Must not contain spaces, line breaks or askerics.

See Also:
Injector.findDocTag(java.lang.String, java.lang.String), Constant Field Values

BACKUP_SUFFIX

public static final String BACKUP_SUFFIX
See Also:
Constant Field Values

CHANGED_CHECKER

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

Instrumentor

public Instrumentor(Writer output,
                    InstrumentorConfig config)
Method Detail

onPackage

public void onPackage(JavaFile javafile)
               throws InjectorParseException
Description copied from interface: InjectionConsumer
Encountered a package statement. This method is guaranteed to be called at most once.

Specified by:
onPackage in interface InjectionConsumer
Throws:
InjectorParseException
See Also:
JavaFile.getPackageName()

onImport

public void onImport(String importname)
Description copied from interface: InjectionConsumer
Encountered an import statement. Imports are also saved in JavaFile.imports. This information may be used for mapping type names to types.

Specified by:
onImport in interface InjectionConsumer
See Also:
JavaFile.findType(String)

onClass

public void onClass(JavaClass jc)
Description copied from interface: InjectionConsumer
Encountered a class header. Is also called for inner classes.

Specified by:
onClass in interface InjectionConsumer

onClassEnd

public void onClassEnd(JavaClass jc)
                throws IOException,
                       InjectorParseException
Description copied from interface: InjectionConsumer
Encountered the end of a class.

Specified by:
onClassEnd in interface InjectionConsumer
Throws:
IOException
InjectorParseException
See Also:
InjectionConsumer.onClass(JavaClass)

onBehaviourHeader

public void onBehaviourHeader(JavaBehaviour jb)
                       throws IOException
Description copied from interface: InjectionConsumer
Encountered the header of a java method. Is called additionally to InjectionConsumer.onClassFeature(JavaFeature, String).

Specified by:
onBehaviourHeader in interface InjectionConsumer
Throws:
IOException

onAttributeHeader

public void onAttributeHeader(JavaAttribute ja)
Description copied from interface: InjectionConsumer
Encountered the header of a java attribute. Is called additionally to InjectionConsumer.onClassFeature(JavaFeature, String).

Specified by:
onAttributeHeader in interface InjectionConsumer

onClassFeature

public void onClassFeature(JavaFeature jf,
                           String doccomment)
                    throws IOException,
                           InjectorParseException
Description copied from interface: InjectionConsumer
Called for attributes and methods. Is called additionally to InjectionConsumer.onBehaviourHeader(JavaBehaviour).

Specified by:
onClassFeature in interface InjectionConsumer
Throws:
IOException
InjectorParseException

onDocComment

public boolean onDocComment(String doccomment)
                     throws IOException
Description copied from interface: InjectionConsumer
Encountered a java documentation comment. Is called for comments on class level only, i.e. inside a class, but outside of methods and attributes.

Specified by:
onDocComment in interface InjectionConsumer
Returns:
if false is returned, the next class feature is ignored.
Throws:
IOException

onFileDocComment

public void onFileDocComment(String doccomment)
                      throws IOException
Description copied from interface: InjectionConsumer
Encountered a java documentation comment. Is called for comments on file level only, i.e. outside of any classes.

Specified by:
onFileDocComment in interface InjectionConsumer
Throws:
IOException

onFileEnd

public void onFileEnd()
Description copied from interface: InjectionConsumer
Encountered the end of the input stream.

Specified by:
onFileEnd in interface InjectionConsumer

writeCall

private final void writeCall(JavaMethod jm)
                      throws IOException
Throws:
IOException

isCollection

private final boolean isCollection(JavaFeature jf)
                            throws InjectorParseException
Returns, whether the type of the given java feature is a collection or not. May cause problems, as described in findType's documentation.

Throws:
InjectorParseException
See Also:
JavaFile.findType(String)

isWeaklyTyped

private final boolean isWeaklyTyped(JavaFeature jf)
                             throws InjectorParseException
Returns, whether the type of the given java feature can be typed by element-type tags or not. Return the same as isCollection(JavaFeature), except for arrays, where it returns false. May cause problems, as described in findType's documentation.

Throws:
InjectorParseException
See Also:
JavaFile.findType(String)

writeBackup

private final void writeBackup(JavaFeature jf)
                        throws IOException,
                               InjectorParseException
Throws:
IOException
InjectorParseException

writeChangedCheckerCall

private final void writeChangedCheckerCall()
                                    throws IOException
Throws:
IOException

writeChangedChecker

private final void writeChangedChecker()
                                throws IOException,
                                       InjectorParseException
Throws:
IOException
InjectorParseException

writeWrapperHeader

private final void writeWrapperHeader(JavaBehaviour jb)
                               throws IOException
Throws:
IOException

writeWrapper

private final void writeWrapper(JavaBehaviour jb)
                         throws IOException
Throws:
IOException

writeWrapper

private final void writeWrapper(JavaConstructor jc)
                         throws IOException
Throws:
IOException

writeWrapper

private final void writeWrapper(JavaMethod jm)
                         throws IOException
Throws:
IOException

writeDefaultConstructor

private final void writeDefaultConstructor(JavaClass jc)
                                    throws IOException
See Java Language Specification 8.6.7 "Default Constructor"

Throws:
IOException

Dresden OCL Toolkit

Submit a bug
Developed at the Dresden University of Technology.
This software is published under the GNU Lesser General Public License.