com.legstar.coxb.gen
Class CoxbBindingGenerator

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by com.legstar.coxb.gen.CoxbBindingGenerator

public class CoxbBindingGenerator
extends org.apache.tools.ant.Task

This class implements an ant task to generate COXB binding data from JAXB cobol annotated instances. The generated binding code is faster than alternative reflection methods also available in legstar-coxbrt. Another advantage of binding classes is that they can bind to a different object than the original JAXB object which served to generate it.

Author:
Fady Moussallam

Nested Class Summary
static class CoxbBindingGenerator.JaxbRootClass
          Represent a simple inner element for the ant task.
 
Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
CoxbBindingGenerator()
          No args constructor.
CoxbBindingGenerator(CoxbGenModel context)
          Constructor from a set of options.
 
Method Summary
 void addJaxbRootClass(String className)
          Add a JAXB root class name holder object.
 void addUnmarshalChoiceStrategy(UnmarshalChoiceStrategy unmarshalChoiceStrategy)
          Add a choice strategy to inject in generated bindings.
protected  void checkInput()
          Checks that properties set are valid.
 CoxbBindingGenerator.JaxbRootClass createJaxbRootClass()
          Creates a JAXB root class name holder object.
static File createOutputFolder(CoxbGenModel coxbGenModel)
          Create the folder which will receive the generated classes.
 void execute()
          The ant method.
 String getAlternativeFactoryName()
          Alternate factory to used rather than the JAXB one.
 String getAlternativePackageName()
          Optional runtime alternative to the Jaxb package name used at generation time.
 String getCoxbPackageName()
          The package name used for COXB classes.
 File getJaxbBinDir()
          The location where JAXB classes live.
 File getJaxbDir()
          Deprecated. Use getJaxbBinDir instead
 String getJaxbPackageName()
          The package name used for JAXB classes.
 String getJaxbRootClassName()
          This is an alternative to jaxbRootClassNames used when a single class is to be bound.
 List<String> getJaxbRootClassNames()
          List of JAXB root class names to process.
protected  Object getObjectFactory(String packageName)
          Loads the object factory class using the current class loader assuming the JAXB classes are available in the current classpath and returns a new instance of it.
protected  Object getRootObject(Object jaxbObjectFactory, String rootObjectName)
          Returns a new instance of the requested JAXB object.
 File getTargetDir()
          The current target directory.
 List<UnmarshalChoiceStrategy> getUnmarshalChoiceStrategies()
          Unmarshal choice strategies to inject in generated bindings.
 File getXsdFile()
          The XML schema file.
 boolean isJsonTransformers()
          True if Host to JSON transformers generation is turned on.
 boolean isXmlTransformers()
          True if Host to XML transformers generation is turned on.
 void setAlternativeFactoryName(String targetFactoryName)
          Alternate factory to used rather than the JAXB one.
 void setAlternativePackageName(String alternativePackageName)
          Optional runtime alternative to the Jaxb package name used at generation time.
 void setCoxbPackageName(String coxbPackageName)
          The package name used for COXB classes.
 void setJaxbBinDir(File jaxbBinDir)
          The location where JAXB classes live.
 void setJaxbDir(File jaxbDir)
          Deprecated. Use setJaxbBinDir instead
 void setJaxbPackageName(String jaxbPackageName)
          The package name used for JAXB classes.
 void setJaxbRootClassName(String objectName)
          A JAXB root class name to set.
 void setJsonTransformers(boolean jsonTransformers)
          True if Host to JSON transformers generation is turned on.
 void setTargetDir(File targetDir)
          The current target directory.
 void setUnmarshalChoiceStrategies(List<UnmarshalChoiceStrategy> _unmarshalChoiceStrategies)
          Unmarshal choice strategies to inject in generated bindings.
 void setXmlTransformers(boolean xmlTransformers)
          True if Host to XML transformers generation is turned on.
 void setXsdFile(File xsdFile)
          The XML schema file.
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoxbBindingGenerator

public CoxbBindingGenerator()
No args constructor.


CoxbBindingGenerator

public CoxbBindingGenerator(CoxbGenModel context)
Constructor from a set of options.

Parameters:
context - options set
Method Detail

execute

public void execute()
The ant method. Generates COXB binding code.

Overrides:
execute in class org.apache.tools.ant.Task

checkInput

protected void checkInput()
Checks that properties set are valid.


createOutputFolder

public static File createOutputFolder(CoxbGenModel coxbGenModel)
                               throws CoxbGenException
Create the folder which will receive the generated classes.

Folder includes the COXB package path if any. When the COXB package path is provided, the output is cleaned from any previous generation artifacts.

Parameters:
coxbGenModel - the generation model
Returns:
the generation folder
Throws:
CoxbGenException - if generation folder cannot be determined

getObjectFactory

protected Object getObjectFactory(String packageName)
Loads the object factory class using the current class loader assuming the JAXB classes are available in the current classpath and returns a new instance of it.

Parameters:
packageName - the package containing a JAXB Object Factory
Returns:
a JAXB Object factory

getRootObject

protected Object getRootObject(Object jaxbObjectFactory,
                               String rootObjectName)
Returns a new instance of the requested JAXB object.

Parameters:
jaxbObjectFactory - an instance of a JAXB Object Factory
rootObjectName - the JAXB root object name (non qualified)
Returns:
an instance of the JAXB root object

getJaxbRootClassName

public String getJaxbRootClassName()
This is an alternative to jaxbRootClassNames used when a single class is to be bound.

Returns:
Returns the JAXB root class name.

setJaxbRootClassName

public void setJaxbRootClassName(String objectName)
A JAXB root class name to set.

Parameters:
objectName - The JAXB root class name to set.

getXsdFile

public File getXsdFile()
The XML schema file.

Returns:
the XML schema file

setXsdFile

public void setXsdFile(File xsdFile)
The XML schema file.

Parameters:
xsdFile - the XML schema file to set

getTargetDir

public File getTargetDir()
The current target directory.

Returns:
the current target directory

setTargetDir

public void setTargetDir(File targetDir)
The current target directory.

Parameters:
targetDir - the target directory to set

getJaxbDir

public File getJaxbDir()
Deprecated. Use getJaxbBinDir instead

Returns:
the location where JAXB classes live

setJaxbDir

public void setJaxbDir(File jaxbDir)
Deprecated. Use setJaxbBinDir instead

Parameters:
jaxbDir - the JAXB location to set

getJaxbBinDir

public File getJaxbBinDir()
The location where JAXB classes live.

Returns:
the location where JAXB classes live

setJaxbBinDir

public void setJaxbBinDir(File jaxbBinDir)
The location where JAXB classes live.

Parameters:
jaxbBinDir - the JAXB location to set

getJaxbPackageName

public String getJaxbPackageName()
The package name used for JAXB classes.

Returns:
the package name used for JAXB classes

setJaxbPackageName

public void setJaxbPackageName(String jaxbPackageName)
The package name used for JAXB classes.

Parameters:
jaxbPackageName - the JAXB classes package name to set

getCoxbPackageName

public String getCoxbPackageName()
The package name used for COXB classes.

Returns:
the package name for generated binding classes

setCoxbPackageName

public void setCoxbPackageName(String coxbPackageName)
The package name used for COXB classes.

Parameters:
coxbPackageName - package name for generated binding classes to set

isXmlTransformers

public boolean isXmlTransformers()
True if Host to XML transformers generation is turned on.

Returns:
true if Host to XML transformers generation is turned on

setXmlTransformers

public void setXmlTransformers(boolean xmlTransformers)
True if Host to XML transformers generation is turned on.

Parameters:
xmlTransformers - true if Host to XML transformers generation is turned on

isJsonTransformers

public boolean isJsonTransformers()
True if Host to JSON transformers generation is turned on.

Returns:
true if Host to JSON transformers generation is turned on

setJsonTransformers

public void setJsonTransformers(boolean jsonTransformers)
True if Host to JSON transformers generation is turned on.

Parameters:
jsonTransformers - true if Host to JSON transformers generation is turned on

getAlternativePackageName

public String getAlternativePackageName()
Optional runtime alternative to the Jaxb package name used at generation time.

Returns:
the optional runtime alternative to the Jaxb package name used at generation time

setAlternativePackageName

public void setAlternativePackageName(String alternativePackageName)
Optional runtime alternative to the Jaxb package name used at generation time.

Parameters:
alternativePackageName - the optional runtime alternative to the Jaxb package name used at generation time

getAlternativeFactoryName

public String getAlternativeFactoryName()
Alternate factory to used rather than the JAXB one.

Returns:
the alternate factory to used rather than the JAXB one.

setAlternativeFactoryName

public void setAlternativeFactoryName(String targetFactoryName)
Alternate factory to used rather than the JAXB one.

Parameters:
targetFactoryName - the alternate factory to used rather than the JAXB one

addJaxbRootClass

public void addJaxbRootClass(String className)
Add a JAXB root class name holder object.

Parameters:
className - the class name to add

createJaxbRootClass

public CoxbBindingGenerator.JaxbRootClass createJaxbRootClass()
Creates a JAXB root class name holder object.

Returns:
a JAXB root class name holder object

getJaxbRootClassNames

public List<String> getJaxbRootClassNames()
List of JAXB root class names to process.

Returns:
the list of jaxb root class names to process

getUnmarshalChoiceStrategies

public List<UnmarshalChoiceStrategy> getUnmarshalChoiceStrategies()
Unmarshal choice strategies to inject in generated bindings.

Returns:
the unmarshal choice strategies to inject in generated bindings

setUnmarshalChoiceStrategies

public void setUnmarshalChoiceStrategies(List<UnmarshalChoiceStrategy> _unmarshalChoiceStrategies)
Unmarshal choice strategies to inject in generated bindings.

Parameters:
_unmarshalChoiceStrategies - the unmarshal choice strategies to inject in generated bindings to set

addUnmarshalChoiceStrategy

public void addUnmarshalChoiceStrategy(UnmarshalChoiceStrategy unmarshalChoiceStrategy)
Add a choice strategy to inject in generated bindings.

Parameters:
unmarshalChoiceStrategy - a choice strategy to inject in generated bindings


Copyright © 2015 LegSem. All Rights Reserved.