Dresden OCL Toolkit

tudresden.ocl.injection.reverseeng
Class AnalysisConsumer

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

public class AnalysisConsumer
extends Object
implements InjectionConsumer

InjectionConsumer used to check for presence of element-type tags in a JavaFile.

After processing of a Java source file, m_lcdCollections will contain a list of all collections in the source file, together with their respective element-type tag. In addition, each element of the list stores information that can be used to identifiy the exact comment where to place the element-type tag when saving the modified file. m_lmdMaps will contain a list of similar entries for each map in the analysed file.

Note that this scheme only work if the Java Source code is not modified externally between analysis and externalisation.

Version:
0.1
Author:
sz9 (Steffen Zschaler)
See Also:
CollectionDescriptor, MapDescriptor

Field Summary
private  int m_cComments
          The number of doc comments in the current file so far.
private  List m_ladFeatures
          All features found in the current file whether collections or maps.
private  List m_lcdCollections
          Collection attributes found in the current file.
private  List m_lmdMaps
          Map attributes found in the current file.
private  int m_nStatus
           
private  String m_sCurrentComment
          The last doc comment parsed so far.
private  String m_sFileName
          Name of source file being analysed without trailing extension.
static int STATUS_COLLECTIONSANDMAPS
          File contains collections and maps which are complete.
static int STATUS_COLLECTIONSANDMAPS_INCOMPL
          File contains collections and maps, some of which are incomplete.
static int STATUS_COLLECTIONSONLY
          File contains only collections which are complete.
static int STATUS_COLLECTIONSONLY_INCOMPL
          File contains only collections, some of which are incomplete.
static int STATUS_MAPSONLY
          File contains only maps which are complete.
static int STATUS_MAPSONLY_INCOMPL
          File contains only maps, some of which are incomplete.
private static int STATUS_MASK_COLLECTIONS
           
private static int STATUS_MASK_INCOMPL
           
private static int STATUS_MASK_MAPS
           
private static int STATUS_MASK_NONE
           
static int STATUS_NORMALFILE
          Normal Java file: no collections, no maps.
 
Constructor Summary
AnalysisConsumer(String sFileName)
          Creates new AnalysisConsumer
 
Method Summary
static AnalysisConsumer analyse(File fToAnalyse)
           
 List getAllFeatures()
           
 List getCollections()
           
 String getFileName()
           
 List getMaps()
           
 int getStatus()
           
 boolean hasIncompleteElements()
           
static void main(String[] args)
           
 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 cc)
          Encountered a class header.
 void onClassEnd(JavaClass cc)
          Encountered the end of a class.
 void onClassFeature(JavaFeature cf, String doccomment)
          Called for attributes and methods.
 boolean onDocComment(String doccomment)
          Encountered a java 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.
 void updateStatus()
          Update the status of the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_MASK_NONE

private static final int STATUS_MASK_NONE
See Also:
Constant Field Values

STATUS_MASK_COLLECTIONS

private static final int STATUS_MASK_COLLECTIONS
See Also:
Constant Field Values

STATUS_MASK_MAPS

private static final int STATUS_MASK_MAPS
See Also:
Constant Field Values

STATUS_MASK_INCOMPL

private static final int STATUS_MASK_INCOMPL
See Also:
Constant Field Values

STATUS_NORMALFILE

public static final int STATUS_NORMALFILE
Normal Java file: no collections, no maps.

See Also:
Constant Field Values

STATUS_COLLECTIONSONLY

public static final int STATUS_COLLECTIONSONLY
File contains only collections which are complete.

See Also:
Constant Field Values

STATUS_COLLECTIONSONLY_INCOMPL

public static final int STATUS_COLLECTIONSONLY_INCOMPL
File contains only collections, some of which are incomplete.

See Also:
Constant Field Values

STATUS_MAPSONLY

public static final int STATUS_MAPSONLY
File contains only maps which are complete.

See Also:
Constant Field Values

STATUS_MAPSONLY_INCOMPL

public static final int STATUS_MAPSONLY_INCOMPL
File contains only maps, some of which are incomplete.

See Also:
Constant Field Values

STATUS_COLLECTIONSANDMAPS

public static final int STATUS_COLLECTIONSANDMAPS
File contains collections and maps which are complete.

See Also:
Constant Field Values

STATUS_COLLECTIONSANDMAPS_INCOMPL

public static final int STATUS_COLLECTIONSANDMAPS_INCOMPL
File contains collections and maps, some of which are incomplete.

See Also:
Constant Field Values

m_cComments

private int m_cComments
The number of doc comments in the current file so far.


m_sCurrentComment

private String m_sCurrentComment
The last doc comment parsed so far.


m_lcdCollections

private List m_lcdCollections
Collection attributes found in the current file.


m_lmdMaps

private List m_lmdMaps
Map attributes found in the current file.


m_ladFeatures

private List m_ladFeatures
All features found in the current file whether collections or maps.


m_nStatus

private int m_nStatus

m_sFileName

private String m_sFileName
Name of source file being analysed without trailing extension.

Constructor Detail

AnalysisConsumer

public AnalysisConsumer(String sFileName)
Creates new AnalysisConsumer

Parameters:
sFileName - name of source file being analysed.
Method Detail

onPackage

public void onPackage(JavaFile javafile)
Encountered a package statement. Ignored.

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

onImport

public void onImport(String importname)
Encountered an import statement. Ignored.

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

onClass

public void onClass(JavaClass cc)
Encountered a class header. Ignored.

Specified by:
onClass in interface InjectionConsumer

onClassEnd

public void onClassEnd(JavaClass cc)
                throws IOException
Encountered the end of a class. Ignored.

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

onBehaviourHeader

public void onBehaviourHeader(JavaBehaviour jb)
                       throws IOException
Encountered the header of a java method. Ignored.

Specified by:
onBehaviourHeader in interface InjectionConsumer
Throws:
IOException

onAttributeHeader

public void onAttributeHeader(JavaAttribute ja)
                       throws IOException
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
Throws:
IOException

onClassFeature

public void onClassFeature(JavaFeature cf,
                           String doccomment)
                    throws InjectorParseException,
                           IOException
Called for attributes and methods.

If an attribute, checks whether a collection. If so, creates a new entry in m_lCollections.

This method relies on the compiled versions of all classes of the system to be analysed to be available in the classpath.

Specified by:
onClassFeature in interface InjectionConsumer
Throws:
InjectorParseException
IOException

onDocComment

public boolean onDocComment(String doccomment)
                     throws IOException
Encountered a java comment.

If this is a doc comment, it is saved temporarily in m_sCurrentComment, so that onClassFeature can use it. Also, m_cComments is increased.

Specified by:
onDocComment in interface InjectionConsumer
Returns:
Always true, to indicate that the next feature should be parsed.
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()
Encountered the end of the input stream. Ignored.

Specified by:
onFileEnd in interface InjectionConsumer

hasIncompleteElements

public boolean hasIncompleteElements()

getStatus

public int getStatus()

updateStatus

public void updateStatus()
Update the status of the file.


getCollections

public List getCollections()

getMaps

public List getMaps()

getAllFeatures

public List getAllFeatures()

getFileName

public String getFileName()

main

public static void main(String[] args)

analyse

public static AnalysisConsumer analyse(File fToAnalyse)
                                throws IOException,
                                       InjectorParseException
Throws:
IOException
InjectorParseException

Dresden OCL Toolkit

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