mChaRM.PremChaRM
Class OJSubClass

java.lang.Object
  |
  +--openjava.mop.OJClass
        |
        +--mChaRM.PremChaRM.OJSubClass
All Implemented Interfaces:
OJMember

public class OJSubClass
extends OJClass

This class represents the structure of a class and allow to write to disk the code it contains. In particulary it contains methods to create the classes and to get some info about them. The difference with OJClass is that the last one don't allow to write a code of a new class, but it allow to modify current class of "ojc" compilation, OJSubClass permit to create a new Java class.

Author:
Valentina Cordì (1996s081@educ.disi.unige.it), Maurizio Mazza (1996s065@educ.disi.unige.it), Roberto Montagna (1996s063@educ.disi.unige.it)

Field Summary
 java.util.Vector constructors
          This field contains the constructors.
 java.util.Vector fstLineConstr
          This field contains, if present, the invocation of costructor in first line of constructor.
 
Fields inherited from interface openjava.mop.OJMember
DECLARED, PUBLIC
 
Constructor Summary
OJSubClass(java.lang.String name, java.lang.String extendsName, java.lang.String[] imports)
          This constructor have to be used if class have no interfaces.
OJSubClass(java.lang.String name, java.lang.String extendsName, java.lang.String[] interfaceName, java.lang.String[] imports)
          This constructor have to be used if class have some interfaces.
 
Method Summary
 void addNewConstructor(OJMethod constructor)
          This method add Constructor to the class
 void addNewFields(OJField field)
          This method add field to the class
 void addNewFields(java.util.Vector fields)
          This method add fields to the class
 void addNewMethods(OJMethod method)
          Add method to the class
 void addNewMethods(java.util.Vector methods)
          Add methods to the class
 boolean DeleteFields(OJField field)
          This method delete field to the class
 boolean DeleteFields(java.util.Vector fields)
          This method delete fields to the class
 boolean DeleteMethods(OJMethod method)
          Delete method to the class
 boolean DeleteMethods(java.util.Vector methods)
          Delete methods to the class
protected  void finalize()
           
 java.lang.String[] getInterfacesStr()
          This method return name of inmpleted interface.
 java.lang.String getName()
          This method return name of this class.
 OJClass getSuperClass()
          This method return the superclass of this class.
 void printAllFields()
          This method print all fields calling printField method for each field.
 void printAllMethods()
          This method print all methods to the output file calling printMethod method for each OJMethod.
 void printConstructor()
          This method print the constructor of the class to the output file (with the exception it throws).
 void printField(OJField field)
          This method print the specified field (whith its modifiers and type) to the output file.
 void printHeader()
          This method print the initial part of the class.
 void printImports()
          This method print all imports int the output file.
 void printMethod(OJMethod method)
          This method print the specified method to the output file.
 void printOutputClass()
          This method print the whole class.
 void setImports(java.lang.String[] newImports)
          This method set the imports of this class.
 
Methods inherited from class openjava.mop.OJClass
addClass, addConstructor, addField, addInterface, addMethod, arrayForClasses, expandAllocation, expandArrayAccess, expandArrayAllocation, expandAssignmentExpression, expandCastedExpression, expandCastExpression, expandExpression, expandFieldRead, expandFieldWrite, expandMethodCall, expandTypeName, expandVariableDeclaration, forClass, forName, forObject, forParseTree, getAcceptableConstructor, getAcceptableMethod, getAllClasses, getAllField, getAllFields, getAllMethod, getAllMethods, getAllMethods, getByteCode, getClasses, getClasses, getClassLoader, getCompatibleJavaClass, getComponentType, getConstructor, getConstructor, getConstructors, getConstructors, getDeclaredClasses, getDeclaredConstructor, getDeclaredConstructors, getDeclaredField, getDeclaredFields, getDeclaredMethod, getDeclaredMethods, getDeclaringClass, getDeclSuffixRule, getEnvironment, getField, getField, getFields, getFields, getInheritableClasses, getInheritableClasses, getInheritableConstructors, getInheritableFields, getInheritableFields, getInheritableMethods, getInheritableMethods, getInheritedClasses, getInheritedFields, getInheritedMethods, getInterfaces, getMetaInfo, getMetaInfoElements, getMetaInfoKeys, getMethod, getMethod, getMethods, getMethods, getModifiers, getPackage, getResource, getResourceAsStream, getSigners, getSimpleName, getSourceCode, getSuffix, getSuperclass, getTypeSuffixRule, isAlterable, isArray, isAssignableFrom, isExecutable, isInSamePackage, isInstance, isInterface, isPrimitive, isPrimitiveWrapper, isRegisteredKeyword, isRegisteredModifier, makeCopy, makeExpression, makeExpression, makeStatement, makeStatement, makeStatementList, makeStatementList, newInstance, primitiveWrapper, putMetaInfo, removeClass, removeConstructor, removeField, removeMethod, resolveException, resolveException, setDeclaringClass, setInterfaces, setName, setSuperclass, signature, toClasses, toString, translateDefinition, translateDefinition, unwrappedPrimitive, waitTranslation, writeMetaInfo
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

constructors

public java.util.Vector constructors
This field contains the constructors. Its value is set by addNewConstructor method.

fstLineConstr

public java.util.Vector fstLineConstr
This field contains, if present, the invocation of costructor in first line of constructor.
Constructor Detail

OJSubClass

public OJSubClass(java.lang.String name,
                  java.lang.String extendsName,
                  java.lang.String[] imports)
           throws java.lang.ClassNotFoundException
This constructor have to be used if class have no interfaces.
Parameters:
name - name of the class
extendsname - name of class to extend.

OJSubClass

public OJSubClass(java.lang.String name,
                  java.lang.String extendsName,
                  java.lang.String[] interfaceName,
                  java.lang.String[] imports)
           throws java.lang.ClassNotFoundException
This constructor have to be used if class have some interfaces.
Parameters:
name - name of the class.
extendsname - name of class to extend.
interfaceName - name of interface that are implemented by this class.
Method Detail

getInterfacesStr

public java.lang.String[] getInterfacesStr()
This method return name of inmpleted interface.

getName

public java.lang.String getName()
This method return name of this class.
Overrides:
getName in class OJClass

setImports

public void setImports(java.lang.String[] newImports)
This method set the imports of this class.
Parameters:
newImports - array of imports to set

addNewFields

public void addNewFields(java.util.Vector fields)
This method add fields to the class
Parameters:
fields - vector of fields to add

addNewFields

public void addNewFields(OJField field)
This method add field to the class
Parameters:
field - field to add

DeleteFields

public boolean DeleteFields(OJField field)
This method delete field to the class
Parameters:
field - field to delete

DeleteFields

public boolean DeleteFields(java.util.Vector fields)
This method delete fields to the class
Parameters:
fields - vector of field to delete

addNewMethods

public void addNewMethods(java.util.Vector methods)
Add methods to the class
Parameters:
methods - vector of methods to add

addNewMethods

public void addNewMethods(OJMethod method)
Add method to the class
Parameters:
method - method to add

DeleteMethods

public boolean DeleteMethods(OJMethod method)
Delete method to the class
Parameters:
method - method to delete

DeleteMethods

public boolean DeleteMethods(java.util.Vector methods)
Delete methods to the class
Parameters:
methods - vector of methods to delete

addNewConstructor

public void addNewConstructor(OJMethod constructor)
This method add Constructor to the class
Parameters:
plParams - constructor parameters
strException - constructor exception

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

printHeader

public void printHeader()
This method print the initial part of the class. In particullary it prints imports calling PrintImports, then prints the declaration of the class and finally it prints extends clause and implements clause

getSuperClass

public OJClass getSuperClass()
This method return the superclass of this class.

printImports

public void printImports()
This method print all imports int the output file.

printOutputClass

public void printOutputClass()
This method print the whole class. It calls in order : PrintHeader, printAllFields and printAllMethods

printField

public void printField(OJField field)
This method print the specified field (whith its modifiers and type) to the output file.
Parameters:
field - field to be printed.

printAllFields

public void printAllFields()
This method print all fields calling printField method for each field.

printConstructor

public void printConstructor()
This method print the constructor of the class to the output file (with the exception it throws). In the output class the constructor simply consist of a call to super() with the given parameters.

printMethod

public void printMethod(OJMethod method)
This method print the specified method to the output file.
Parameters:
method - method to print.

printAllMethods

public void printAllMethods()
This method print all methods to the output file calling printMethod method for each OJMethod.