org.jomc.tools
Class ClassFileProcessor

Package class diagram package ClassFileProcessor
java.lang.Object
  extended by org.jomc.tools.JomcTool
      extended by org.jomc.tools.ClassFileProcessor

public class ClassFileProcessor
extends JomcTool

Processes class files.

Use Cases:

Version:
$JOMC: ClassFileProcessor.java 4200 2012-01-25 09:46:13Z schulte2005 $
Author:
Christian Schulte
See Also:
JomcTool.getModules()

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jomc.tools.JomcTool
JomcTool.Listener
 
Constructor Summary
ClassFileProcessor()
          Creates a new ClassFileProcessor instance.
ClassFileProcessor(ClassFileProcessor tool)
          Creates a new ClassFileProcessor instance taking a ClassFileProcessor instance to initialize the instance with.
 
Method Summary
 void commitModelObjects(Implementation implementation, javax.xml.bind.Marshaller marshaller, org.apache.bcel.classfile.JavaClass javaClass)
          Commits model objects of a given implementation of the modules of the instance to a given class file.
 void commitModelObjects(Implementation implementation, ModelContext context, File classesDirectory)
          Commits model objects of a given implementation of the modules of the instance to class files.
 void commitModelObjects(ModelContext context, File classesDirectory)
          Commits model objects of the modules of the instance to class files.
 void commitModelObjects(Module module, ModelContext context, File classesDirectory)
          Commits model objects of a given module of the modules of the instance to class files.
 void commitModelObjects(Specification specification, javax.xml.bind.Marshaller marshaller, org.apache.bcel.classfile.JavaClass javaClass)
          Commits model objects of a given specification of the modules of the instance to a given class file.
 void commitModelObjects(Specification specification, ModelContext context, File classesDirectory)
          Commits model objects of a given specification of the modules of the instance to class files.
<T extends ModelObject>
T
decodeModelObject(javax.xml.bind.Unmarshaller unmarshaller, byte[] bytes, Class<T> type)
          Decodes a model object from a byte array.
 byte[] encodeModelObject(javax.xml.bind.Marshaller marshaller, javax.xml.bind.JAXBElement<? extends ModelObject> modelObject)
          Encodes a model object to a byte array.
 byte[] getClassfileAttribute(org.apache.bcel.classfile.JavaClass clazz, String attributeName)
          Gets an attribute from a java class.
 void setClassfileAttribute(org.apache.bcel.classfile.JavaClass clazz, String attributeName, byte[] data)
          Adds or updates an attribute in a java class.
 void transformModelObjects(Implementation implementation, javax.xml.bind.Marshaller marshaller, javax.xml.bind.Unmarshaller unmarshaller, org.apache.bcel.classfile.JavaClass javaClass, List<Transformer> transformers)
          Transforms model objects of a given implementation of the modules of the instance.
 void transformModelObjects(Implementation implementation, ModelContext context, File classesDirectory, List<Transformer> transformers)
          Transforms model objects of class files of a given implementation of the modules of the instance.
 void transformModelObjects(ModelContext context, File classesDirectory, List<Transformer> transformers)
          Transforms model objects of class files of the modules of the instance.
 void transformModelObjects(Module module, ModelContext context, File classesDirectory, List<Transformer> transformers)
          Transforms model objects of class files of a given module of the modules of the instance.
 void transformModelObjects(Specification specification, javax.xml.bind.Marshaller marshaller, javax.xml.bind.Unmarshaller unmarshaller, org.apache.bcel.classfile.JavaClass javaClass, List<Transformer> transformers)
          Transforms model objects of a given specification of the modules of the instance.
 void transformModelObjects(Specification specification, ModelContext context, File classesDirectory, List<Transformer> transformers)
          Transforms model objects of class files of a given specification of the modules of the instance.
 ModelValidationReport validateModelObjects(Implementation implementation, ModelContext context)
          Validates model objects of class files of a given implementation of the modules of the instance.
 ModelValidationReport validateModelObjects(Implementation implementation, ModelContext context, File classesDirectory)
          Validates model objects of class files of a given implementation of the modules of the instance.
 ModelValidationReport validateModelObjects(Implementation implementation, javax.xml.bind.Unmarshaller unmarshaller, org.apache.bcel.classfile.JavaClass javaClass)
          Validates model objects of a given implementation of the modules of the instance.
 ModelValidationReport validateModelObjects(ModelContext context)
          Validates model objects of class files of the modules of the instance.
 ModelValidationReport validateModelObjects(ModelContext context, File classesDirectory)
          Validates model objects of class files of the modules of the instance.
 ModelValidationReport validateModelObjects(Module module, ModelContext context)
          Validates model objects of class files of a given module of the modules of the instance.
 ModelValidationReport validateModelObjects(Module module, ModelContext context, File classesDirectory)
          Validates model objects of class files of a given module of the modules of the instance.
 ModelValidationReport validateModelObjects(Specification specification, ModelContext context)
          Validates model objects of class files of a given specification of the modules of the instance.
 ModelValidationReport validateModelObjects(Specification specification, ModelContext context, File classesDirectory)
          Validates model objects of class files of a given specification of the modules of the instance.
 ModelValidationReport validateModelObjects(Specification specification, javax.xml.bind.Unmarshaller unmarshaller, org.apache.bcel.classfile.JavaClass javaClass)
          Validates model objects of a given specification of the modules of the instance.
 
Methods inherited from class org.jomc.tools.JomcTool
getBooleanString, getCsvString, getDefaultLogLevel, getDefaultTemplateProfile, getDisplayLanguage, getHtmlString, getImplementedJavaTypeNames, getIndentation, getIndentation, getInputEncoding, getIsoDate, getIsoDateTime, getIsoTime, getJavaClasspathLocation, getJavaClasspathLocation, getJavadocComment, getJavadocComment, getJavaGetterMethodName, getJavaGetterMethodName, getJavaGetterMethodName, getJavaIdentifier, getJavaInterfaceNames, getJavaMethodParameterName, getJavaMethodParameterName, getJavaMethodParameterName, getJavaMethodParameterName, getJavaModifierName, getJavaModifierName, getJavaModifierName, getJavaPackageName, getJavaPackageName, getJavaPackageName, getJavaScriptString, getJavaSetterMethodName, getJavaSetterMethodName, getJavaSetterMethodName, getJavaString, getJavaTypeName, getJavaTypeName, getJavaTypeName, getJavaTypeName, getJavaTypeName, getJavaTypeName, getLineSeparator, getListeners, getLocale, getLogLevel, getLongDate, getLongDateTime, getLongTime, getMediumDate, getMediumDateTime, getMediumTime, getModel, getModules, getOutputEncoding, getShortDate, getShortDateTime, getShortTime, getSqlString, getTemplateEncoding, getTemplateLocation, getTemplateParameters, getTemplateProfile, getVelocityContext, getVelocityEngine, getVelocityTemplate, getXmlString, getYears, isJavaDefaultPackage, isJavaDefaultPackage, isJavaPrimitiveType, isLoggable, log, setDefaultLogLevel, setDefaultTemplateProfile, setIndentation, setInputEncoding, setLineSeparator, setLocale, setLogLevel, setModel, setOutputEncoding, setTemplateEncoding, setTemplateLocation, setTemplateProfile, setVelocityEngine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFileProcessor

public ClassFileProcessor()
Creates a new ClassFileProcessor instance.


ClassFileProcessor

public ClassFileProcessor(ClassFileProcessor tool)
                   throws IOException
Creates a new ClassFileProcessor instance taking a ClassFileProcessor instance to initialize the instance with.

Parameters:
tool - The instance to initialize the new instance with.
Throws:
NullPointerException - if tool is null.
IOException - if copying tool fails.
Method Detail

commitModelObjects

public final void commitModelObjects(ModelContext context,
                                     File classesDirectory)
                              throws IOException
Commits model objects of the modules of the instance to class files.

Parameters:
context - The model context to use for committing the model objects.
classesDirectory - The directory holding the class files.
Throws:
NullPointerException - if context or classesDirectory is null.
IOException - if committing model objects fails.
See Also:
commitModelObjects(org.jomc.model.Module, org.jomc.modlet.ModelContext, java.io.File)

commitModelObjects

public final void commitModelObjects(Module module,
                                     ModelContext context,
                                     File classesDirectory)
                              throws IOException
Commits model objects of a given module of the modules of the instance to class files.

Parameters:
module - The module to process.
context - The model context to use for committing the model objects.
classesDirectory - The directory holding the class files.
Throws:
NullPointerException - if module, context or classesDirectory is null.
IOException - if committing model objects fails.
See Also:
commitModelObjects(org.jomc.model.Specification, org.jomc.modlet.ModelContext, java.io.File), commitModelObjects(org.jomc.model.Implementation, org.jomc.modlet.ModelContext, java.io.File)

commitModelObjects

public final void commitModelObjects(Specification specification,
                                     ModelContext context,
                                     File classesDirectory)
                              throws IOException
Commits model objects of a given specification of the modules of the instance to class files.

Parameters:
specification - The specification to process.
context - The model context to use for committing the model objects.
classesDirectory - The directory holding the class files.
Throws:
NullPointerException - if specification, context or classesDirectory is null.
IOException - if committing model objects fails.
See Also:
commitModelObjects(org.jomc.model.Specification, javax.xml.bind.Marshaller, org.apache.bcel.classfile.JavaClass)

commitModelObjects

public final void commitModelObjects(Implementation implementation,
                                     ModelContext context,
                                     File classesDirectory)
                              throws IOException
Commits model objects of a given implementation of the modules of the instance to class files.

Parameters:
implementation - The implementation to process.
context - The model context to use for committing the model objects.
classesDirectory - The directory holding the class files.
Throws:
NullPointerException - if implementation, context or classesDirectory is null.
IOException - if committing model objects fails.
See Also:
commitModelObjects(org.jomc.model.Implementation, javax.xml.bind.Marshaller, org.apache.bcel.classfile.JavaClass)

commitModelObjects

public void commitModelObjects(Specification specification,
                               javax.xml.bind.Marshaller marshaller,
                               org.apache.bcel.classfile.JavaClass javaClass)
                        throws IOException
Commits model objects of a given specification of the modules of the instance to a given class file.

Parameters:
specification - The specification to process.
marshaller - The marshaller to use for committing the model objects.
javaClass - The java class to commit to.
Throws:
NullPointerException - if specification, marshaller or javaClass is null.
IOException - if committing model objects fails.

commitModelObjects

public void commitModelObjects(Implementation implementation,
                               javax.xml.bind.Marshaller marshaller,
                               org.apache.bcel.classfile.JavaClass javaClass)
                        throws IOException
Commits model objects of a given implementation of the modules of the instance to a given class file.

Parameters:
implementation - The implementation to process.
marshaller - The marshaller to use for committing the model objects.
javaClass - The java class to commit to.
Throws:
NullPointerException - if implementation, marshaller or javaClass is null.
IOException - if committing model objects fails.

validateModelObjects

public final ModelValidationReport validateModelObjects(ModelContext context)
                                                 throws IOException
Validates model objects of class files of the modules of the instance.

Parameters:
context - The model context to use for validating model objects.
Returns:
The report of the validation.
Throws:
NullPointerException - if context is null.
IOException - if validating model objects fails.
See Also:
validateModelObjects(org.jomc.model.Module, org.jomc.modlet.ModelContext)

validateModelObjects

public final ModelValidationReport validateModelObjects(Module module,
                                                        ModelContext context)
                                                 throws IOException
Validates model objects of class files of a given module of the modules of the instance.

Parameters:
module - The module to process.
context - The model context to use for validating model objects.
Returns:
The report of the validation.
Throws:
NullPointerException - if module or context is null.
IOException - if validating model objects fails.
See Also:
validateModelObjects(org.jomc.model.Specification, org.jomc.modlet.ModelContext), validateModelObjects(org.jomc.model.Implementation, org.jomc.modlet.ModelContext)

validateModelObjects

public final ModelValidationReport validateModelObjects(Specification specification,
                                                        ModelContext context)
                                                 throws IOException
Validates model objects of class files of a given specification of the modules of the instance.

Parameters:
specification - The specification to process.
context - The model context to use for validating model objects.
Returns:
The report of the validation.
Throws:
NullPointerException - if specification or context is null.
IOException - if validating model objects fails.
See Also:
validateModelObjects(org.jomc.model.Specification, javax.xml.bind.Unmarshaller, org.apache.bcel.classfile.JavaClass)

validateModelObjects

public final ModelValidationReport validateModelObjects(Implementation implementation,
                                                        ModelContext context)
                                                 throws IOException
Validates model objects of class files of a given implementation of the modules of the instance.

Parameters:
implementation - The implementation to process.
context - The model context to use for validating model objects.
Returns:
The report of the validation.
Throws:
NullPointerException - if implementation or context is null.
IOException - if validating model objects fails.
See Also:
validateModelObjects(org.jomc.model.Implementation, javax.xml.bind.Unmarshaller, org.apache.bcel.classfile.JavaClass)

validateModelObjects

public final ModelValidationReport validateModelObjects(ModelContext context,
                                                        File classesDirectory)
                                                 throws IOException
Validates model objects of class files of the modules of the instance.

Parameters:
context - The model context to use for validating model objects.
classesDirectory - The directory holding the class files.
Returns:
The report of the validation.
Throws:
NullPointerException - if context or classesDirectory is null.
IOException - if validating model objects fails.
See Also:
validateModelObjects(org.jomc.model.Module, org.jomc.modlet.ModelContext, java.io.File)

validateModelObjects

public final ModelValidationReport validateModelObjects(Module module,
                                                        ModelContext context,
                                                        File classesDirectory)
                                                 throws IOException
Validates model objects of class files of a given module of the modules of the instance.

Parameters:
module - The module to process.
context - The model context to use for validating model objects.
classesDirectory - The directory holding the class files.
Returns:
The report of the validation.
Throws:
NullPointerException - if module, context or classesDirectory is null.
IOException - if validating model objects fails.
See Also:
validateModelObjects(org.jomc.model.Specification, org.jomc.modlet.ModelContext, java.io.File), validateModelObjects(org.jomc.model.Implementation, org.jomc.modlet.ModelContext, java.io.File)

validateModelObjects

public final ModelValidationReport validateModelObjects(Specification specification,
                                                        ModelContext context,
                                                        File classesDirectory)
                                                 throws IOException
Validates model objects of class files of a given specification of the modules of the instance.

Parameters:
specification - The specification to process.
context - The model context to use for validating model objects.
classesDirectory - The directory holding the class files.
Returns:
The report of the validation.
Throws:
NullPointerException - if specification, context or classesDirectory is null.
IOException - if validating model objects fails.
See Also:
validateModelObjects(org.jomc.model.Specification, javax.xml.bind.Unmarshaller, org.apache.bcel.classfile.JavaClass)

validateModelObjects

public final ModelValidationReport validateModelObjects(Implementation implementation,
                                                        ModelContext context,
                                                        File classesDirectory)
                                                 throws IOException
Validates model objects of class files of a given implementation of the modules of the instance.

Parameters:
implementation - The implementation to process.
context - The model context to use for validating model objects.
classesDirectory - The directory holding the class files.
Returns:
The report of the validation.
Throws:
NullPointerException - if implementation, context or classesDirectory is null.
IOException - if validating model objects fails.
See Also:
validateModelObjects(org.jomc.model.Implementation, javax.xml.bind.Unmarshaller, org.apache.bcel.classfile.JavaClass)

validateModelObjects

public ModelValidationReport validateModelObjects(Specification specification,
                                                  javax.xml.bind.Unmarshaller unmarshaller,
                                                  org.apache.bcel.classfile.JavaClass javaClass)
                                           throws IOException
Validates model objects of a given specification of the modules of the instance.

Parameters:
specification - The specification to process.
unmarshaller - The unmarshaller to use for validating model objects.
javaClass - The java class to validate.
Returns:
The report of the validation.
Throws:
NullPointerException - if specification, unmarshaller or javaClass is null.
IOException - if validating model objects fails.

validateModelObjects

public ModelValidationReport validateModelObjects(Implementation implementation,
                                                  javax.xml.bind.Unmarshaller unmarshaller,
                                                  org.apache.bcel.classfile.JavaClass javaClass)
                                           throws IOException
Validates model objects of a given implementation of the modules of the instance.

Parameters:
implementation - The implementation to process.
unmarshaller - The unmarshaller to use for validating model objects.
javaClass - The java class to validate.
Returns:
The report of the validation.
Throws:
NullPointerException - if implementation, unmarshaller or javaClass is null.
IOException - if validating model objects fails.

transformModelObjects

public final void transformModelObjects(ModelContext context,
                                        File classesDirectory,
                                        List<Transformer> transformers)
                                 throws IOException
Transforms model objects of class files of the modules of the instance.

Parameters:
context - The model context to use for transforming model objects.
classesDirectory - The directory holding the class files.
transformers - The transformers to use for transforming model objects.
Throws:
NullPointerException - if context, classesDirectory or transformers is null.
IOException - if transforming model objects fails.
See Also:
transformModelObjects(org.jomc.model.Module, org.jomc.modlet.ModelContext, java.io.File, java.util.List)

transformModelObjects

public final void transformModelObjects(Module module,
                                        ModelContext context,
                                        File classesDirectory,
                                        List<Transformer> transformers)
                                 throws IOException
Transforms model objects of class files of a given module of the modules of the instance.

Parameters:
module - The module to process.
context - The model context to use for transforming model objects.
classesDirectory - The directory holding the class files.
transformers - The transformers to use for transforming the model objects.
Throws:
NullPointerException - if module, context, classesDirectory or transformers is null.
IOException - if transforming model objects fails.
See Also:
transformModelObjects(org.jomc.model.Specification, org.jomc.modlet.ModelContext, java.io.File, java.util.List), transformModelObjects(org.jomc.model.Implementation, org.jomc.modlet.ModelContext, java.io.File, java.util.List)

transformModelObjects

public final void transformModelObjects(Specification specification,
                                        ModelContext context,
                                        File classesDirectory,
                                        List<Transformer> transformers)
                                 throws IOException
Transforms model objects of class files of a given specification of the modules of the instance.

Parameters:
specification - The specification to process.
context - The model context to use for transforming model objects.
classesDirectory - The directory holding the class files.
transformers - The transformers to use for transforming the model objects.
Throws:
NullPointerException - if specification, context, classesDirectory or transformers is null.
IOException - if transforming model objects fails.
See Also:
transformModelObjects(org.jomc.model.Specification, javax.xml.bind.Marshaller, javax.xml.bind.Unmarshaller, org.apache.bcel.classfile.JavaClass, java.util.List)

transformModelObjects

public final void transformModelObjects(Implementation implementation,
                                        ModelContext context,
                                        File classesDirectory,
                                        List<Transformer> transformers)
                                 throws IOException
Transforms model objects of class files of a given implementation of the modules of the instance.

Parameters:
implementation - The implementation to process.
context - The model context to use for transforming model objects.
classesDirectory - The directory holding the class files.
transformers - The transformers to use for transforming the model objects.
Throws:
NullPointerException - if implementation, context, classesDirectory or transformers is null.
IOException - if transforming model objects fails.
See Also:
transformModelObjects(org.jomc.model.Implementation, javax.xml.bind.Marshaller, javax.xml.bind.Unmarshaller, org.apache.bcel.classfile.JavaClass, java.util.List)

transformModelObjects

public void transformModelObjects(Specification specification,
                                  javax.xml.bind.Marshaller marshaller,
                                  javax.xml.bind.Unmarshaller unmarshaller,
                                  org.apache.bcel.classfile.JavaClass javaClass,
                                  List<Transformer> transformers)
                           throws IOException
Transforms model objects of a given specification of the modules of the instance.

Parameters:
specification - The specification to process.
marshaller - The marshaller to use for transforming model objects.
unmarshaller - The unmarshaller to use for transforming model objects.
javaClass - The java class to transform model objects of.
transformers - The transformers to use for transforming the model objects.
Throws:
NullPointerException - if specification, marshaller, unmarshaller, javaClass or transformers is null.
IOException - if transforming model objects fails.

transformModelObjects

public void transformModelObjects(Implementation implementation,
                                  javax.xml.bind.Marshaller marshaller,
                                  javax.xml.bind.Unmarshaller unmarshaller,
                                  org.apache.bcel.classfile.JavaClass javaClass,
                                  List<Transformer> transformers)
                           throws IOException
Transforms model objects of a given implementation of the modules of the instance.

Parameters:
implementation - The implementation to process.
marshaller - The marshaller to use for transforming model objects.
unmarshaller - The unmarshaller to use for transforming model objects.
javaClass - The java class to transform model object of.
transformers - The transformers to use for transforming the model objects.
Throws:
NullPointerException - if implementation, marshaller, unmarshaller, javaClass or transformers is null.
IOException - if transforming model objects fails.

getClassfileAttribute

public byte[] getClassfileAttribute(org.apache.bcel.classfile.JavaClass clazz,
                                    String attributeName)
                             throws IOException
Gets an attribute from a java class.

Parameters:
clazz - The java class to get an attribute from.
attributeName - The name of the attribute to get.
Returns:
The value of attribute attributeName of clazz or null, if no such attribute exists.
Throws:
NullPointerException - if clazz or attributeName is null.
IOException - if getting the attribute fails.
See Also:
JavaClass.getAttributes()

setClassfileAttribute

public void setClassfileAttribute(org.apache.bcel.classfile.JavaClass clazz,
                                  String attributeName,
                                  byte[] data)
                           throws IOException
Adds or updates an attribute in a java class.

Parameters:
clazz - The class to update an attribute of.
attributeName - The name of the attribute to update.
data - The new data of the attribute to update the clazz with.
Throws:
NullPointerException - if clazz or attributeName is null.
IOException - if updating the class file fails.
See Also:
JavaClass.getAttributes()

encodeModelObject

public byte[] encodeModelObject(javax.xml.bind.Marshaller marshaller,
                                javax.xml.bind.JAXBElement<? extends ModelObject> modelObject)
                         throws IOException
Encodes a model object to a byte array.

Parameters:
marshaller - The marshaller to use for encoding the object.
modelObject - The model object to encode.
Returns:
GZIP compressed XML document of modelObject.
Throws:
NullPointerException - if marshaller or modelObject is null.
IOException - if encoding modelObject fails.
See Also:
decodeModelObject(javax.xml.bind.Unmarshaller, byte[], java.lang.Class)

decodeModelObject

public <T extends ModelObject> T decodeModelObject(javax.xml.bind.Unmarshaller unmarshaller,
                                                   byte[] bytes,
                                                   Class<T> type)
                                        throws IOException
Decodes a model object from a byte array.

Type Parameters:
T - The type of the encoded model object.
Parameters:
unmarshaller - The unmarshaller to use for decoding the object.
bytes - The encoded model object to decode.
type - The class of the type of the encoded model object.
Returns:
Model object decoded from bytes.
Throws:
NullPointerException - if unmarshaller, bytes or type is null.
IOException - if decoding bytes fails.
See Also:
encodeModelObject(javax.xml.bind.Marshaller, javax.xml.bind.JAXBElement)


Copyright © 2005-2012 The JOMC Project. All Rights Reserved.Get JOMC at SourceForge.net. Fast, secure and Free Open Source software downloads
Please note that this documentation is maintained by non-native english speaking authors. As such, you may encounter phrases or wordings which seem imprecise or may even have a totally different meaning to native english speaking readers than what the individual author was trying to express. If you are a native english speaking reader and find any such phrases or wordings we kindly ask you to send an email to the corresponding author and help us improve this documentation in order to avoid misunderstandings. You will find the authors' email addresses at the top of each class. Please accept our apologies for any inconvenience caused.