com.legstar.coxb.gen
Class CoxbGenModel

java.lang.Object
  extended by com.legstar.codegen.models.AbstractPropertiesModel
      extended by com.legstar.codegen.models.AbstractAntBuildModel
          extended by com.legstar.coxb.gen.CoxbGenModel
All Implemented Interfaces:
IAntBuildModel

public class CoxbGenModel
extends AbstractAntBuildModel

A model usable for Binding classes generation. Groups all the data needed to generate a set of binding classes and an intermediary set of jaxb classes from a COBOL-annotated XML schema. Gathers all parameters that are needed during the lifetime of the generation process. This allows more parameters to be added without too much impact on other classes.


Field Summary
static String COXB_COXBBINDIR
          COXB binaries directory.
static String COXB_COXBSRCDIR
          COXB source directory.
static String COXB_GENERATOR_NAME
          This generator name.
static String COXB_IS_COMPILE_TRANSFORMERS
          Compile Transformers.
static String COXB_ISJSONTRANSFORMERS
          Generate JSON Transformers.
static String COXB_ISXMLTRANSFORMERS
          Generate XML Transformers.
static String COXB_JAXB_ALTERNATIVEFACTORYNAME
          JAXB alternate object factory.
static String COXB_JAXB_ALTERNATIVEPACKAGENAME
          JAXB alternate package name.
static String COXB_JAXBBINDIR
          JAXB binaries directory.
static String COXB_JAXBROOTCLASSNAMES
          JAXB root class names.
static String COXB_JAXBSRCDIR
          JAXB source directory.
static String COXB_PACKAGENAME
          COXB package name.
static String COXB_UNMARSHAL_CHOICE_STRATEGIES
          Unmarshal choice strategies.
static String COXB_VELOCITY_MACRO_NAME
          This velocity template.
static String COXB_XSDFILE
          XML Schema file.
static boolean DEFAULT_IS_COMPILE_TRANSFORMERS
          Default value for transformers compilation.
static boolean DEFAULT_ISJSONTRANSFORMERS
          Default value for JSON transformers generation.
static boolean DEFAULT_ISXMLTRANSFORMERS
          Default value for XML transformers generation.
static String DEFAULT_JAXB_PACKAGENAME
          When XML Schema does not contain a target namespace, JAXB uses this default package name.
 
Fields inherited from class com.legstar.codegen.models.AbstractAntBuildModel
ANT_FILE_PREFIX, ANT_FILE_SUFFIX
 
Constructor Summary
CoxbGenModel()
          A no-Arg constructor.
CoxbGenModel(Properties props)
          Construct from a properties file.
 
Method Summary
 void addJaxbRootClassName(String className)
          Adds a jaxb root class name to generate a binding class for.
 void addUnmarshalChoiceStrategy(UnmarshalChoiceStrategy unmarshalChoiceStrategy)
          Add a choice strategy to inject in generated bindings.
 void generateBuild(File scriptFile)
          Creates an ant build script file ready for binding generation.
 String getAlternativeFactoryName()
           
 String getAlternativePackageName()
           
 File getCoxbBinDir()
           
 String getCoxbPackageName()
           
 File getCoxbSrcDir()
           
protected  DocumentBuilder getDocBuilder()
          Creates a DOM document builder if none has already been created.
 String getElementNamePrefix()
           
 String getElementNameSuffix()
           
 File getJaxbBinDir()
           
 String getJaxbClassIncludes()
          Turn the JAXB package name into an include statement that we can used as an includes property for a javac ant step.
 JaxbGenModel getJaxbGenModel()
           
 String getJaxbPackageName()
           
 String getJaxbPackageNameFromXsd(File xsdFile)
          Extracts the JAXB package name from the XML schema targetNamespace.
 List<String> getJaxbRootClassNames()
           
 File getJaxbSrcDir()
          This is not strictly needed for binding generation but is useful when this model is also used for JAXB classes generation.
 long getSerializableUid()
           
 String getTypeNamePrefix()
           
 String getTypeNameSuffix()
           
 List<UnmarshalChoiceStrategy> getUnmarshalChoiceStrategies()
          Unmarshal choice strategies to inject in generated bindings.
 File getXsdFile()
           
 boolean isCompileTransformers()
           
 boolean isEciCompatible()
          Whether the ECI naming conventions should be used.
 boolean isGenerateIsSetMethod()
           
 boolean isJsonTransformers()
           
 boolean isNoPackageInfo()
          Prevents generation of JAXB package-info.java which does not compile under JDK 1.5.
 boolean isXmlTransformers()
           
 void setAlternativeFactoryName(String targetFactoryName)
           
 void setAlternativePackageName(String alternativePackageName)
           
 void setCompileTransformers(boolean compileTransformers)
           
 void setCoxbBinDir(File coxbBinDir)
           
 void setCoxbPackageName(String coxbPackageName)
           
 void setCoxbSrcDir(File targetDir)
           
 void setEciCompatible(boolean eciCompatible)
          Whether the ECI naming conventions should be used.
 void setElementNamePrefix(String elementNamePrefix)
           
 void setElementNameSuffix(String elementNameSuffix)
           
 void setGenerateIsSetMethod(boolean generateIsSetMethod)
           
 void setJaxbBinDir(File jaxbBinDir)
           
 void setJaxbGenModel(JaxbGenModel jaxbGenModel)
           
 void setJaxbPackageName(String jaxbPackageName)
          The package name used for JAXB classes.
 void setJaxbRootClassNames(List<String> jaxbRootClassNames)
           
 void setJaxbSrcDir(File jaxbSrcDir)
           
 void setJsonTransformers(boolean jsonTransformers)
           
 void setNoPackageInfo(boolean noPackageInfo)
          Prevents generation of JAXB package-info.java which does not compile under JDK 1.5.
 void setSerializableUid(long serializableUid)
           
 void setTypeNamePrefix(String typeNamePrefix)
           
 void setTypeNameSuffix(String typeNameSuffix)
           
 void setUnmarshalChoiceStrategies(List<UnmarshalChoiceStrategy> unmarshalChoiceStrategies)
          Unmarshal choice strategies to inject in generated bindings.
 void setXmlTransformers(boolean xmlTransformers)
           
 void setXsdFile(File xsdFile)
           
 Properties toProperties()
           
protected  List<String> toStringList(List<UnmarshalChoiceStrategy> unmarshalChoiceStrategies)
          Helper to serialize the list unmarshal choice strategies to a properties file.
protected  List<UnmarshalChoiceStrategy> toUnmarshalChoiceStrategies(List<String> stringList)
          Helper to deserialize a list of unmarshal choice strategies from a properties file.
 
Methods inherited from class com.legstar.codegen.models.AbstractAntBuildModel
generateBuild, generateBuild, getProbeFile, getProductLocation, setProbeFile, setProductLocation
 
Methods inherited from class com.legstar.codegen.models.AbstractPropertiesModel
getBoolean, getFile, getInt, getLong, getString, getStringList, getURI, putBoolean, putFile, putInt, putLong, putString, putStringList, putURI, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COXB_GENERATOR_NAME

public static final String COXB_GENERATOR_NAME
This generator name.

See Also:
Constant Field Values

COXB_VELOCITY_MACRO_NAME

public static final String COXB_VELOCITY_MACRO_NAME
This velocity template.

See Also:
Constant Field Values

DEFAULT_ISXMLTRANSFORMERS

public static final boolean DEFAULT_ISXMLTRANSFORMERS
Default value for XML transformers generation.

See Also:
Constant Field Values

DEFAULT_ISJSONTRANSFORMERS

public static final boolean DEFAULT_ISJSONTRANSFORMERS
Default value for JSON transformers generation.

See Also:
Constant Field Values

DEFAULT_IS_COMPILE_TRANSFORMERS

public static final boolean DEFAULT_IS_COMPILE_TRANSFORMERS
Default value for transformers compilation.

See Also:
Constant Field Values

DEFAULT_JAXB_PACKAGENAME

public static final String DEFAULT_JAXB_PACKAGENAME
When XML Schema does not contain a target namespace, JAXB uses this default package name.

See Also:
Constant Field Values

COXB_PACKAGENAME

public static final String COXB_PACKAGENAME
COXB package name.

See Also:
Constant Field Values

COXB_JAXB_ALTERNATIVEFACTORYNAME

public static final String COXB_JAXB_ALTERNATIVEFACTORYNAME
JAXB alternate object factory.

See Also:
Constant Field Values

COXB_JAXB_ALTERNATIVEPACKAGENAME

public static final String COXB_JAXB_ALTERNATIVEPACKAGENAME
JAXB alternate package name.

See Also:
Constant Field Values

COXB_ISJSONTRANSFORMERS

public static final String COXB_ISJSONTRANSFORMERS
Generate JSON Transformers.

See Also:
Constant Field Values

COXB_ISXMLTRANSFORMERS

public static final String COXB_ISXMLTRANSFORMERS
Generate XML Transformers.

See Also:
Constant Field Values

COXB_IS_COMPILE_TRANSFORMERS

public static final String COXB_IS_COMPILE_TRANSFORMERS
Compile Transformers.

See Also:
Constant Field Values

COXB_XSDFILE

public static final String COXB_XSDFILE
XML Schema file.

See Also:
Constant Field Values

COXB_JAXBROOTCLASSNAMES

public static final String COXB_JAXBROOTCLASSNAMES
JAXB root class names.

See Also:
Constant Field Values

COXB_JAXBSRCDIR

public static final String COXB_JAXBSRCDIR
JAXB source directory.

See Also:
Constant Field Values

COXB_JAXBBINDIR

public static final String COXB_JAXBBINDIR
JAXB binaries directory.

See Also:
Constant Field Values

COXB_COXBSRCDIR

public static final String COXB_COXBSRCDIR
COXB source directory.

See Also:
Constant Field Values

COXB_COXBBINDIR

public static final String COXB_COXBBINDIR
COXB binaries directory.

See Also:
Constant Field Values

COXB_UNMARSHAL_CHOICE_STRATEGIES

public static final String COXB_UNMARSHAL_CHOICE_STRATEGIES
Unmarshal choice strategies.

See Also:
Constant Field Values
Constructor Detail

CoxbGenModel

public CoxbGenModel()
A no-Arg constructor.


CoxbGenModel

public CoxbGenModel(Properties props)
Construct from a properties file.

Parameters:
props - the property file
Method Detail

generateBuild

public void generateBuild(File scriptFile)
                   throws CodeGenMakeException
Creates an ant build script file ready for binding generation.

Parameters:
scriptFile - the script file that must be created
Throws:
CodeGenMakeException - if generation fails

addJaxbRootClassName

public void addJaxbRootClassName(String className)
Adds a jaxb root class name to generate a binding class for.

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

getXsdFile

public File getXsdFile()
Returns:
the XML schema file

setXsdFile

public void setXsdFile(File xsdFile)
Parameters:
xsdFile - the XML schema file to set

getCoxbSrcDir

public File getCoxbSrcDir()
Returns:
the current target directory

setCoxbSrcDir

public void setCoxbSrcDir(File targetDir)
Parameters:
targetDir - the target directory to set

getJaxbBinDir

public File getJaxbBinDir()
Returns:
the location where JAXB classes live

setJaxbBinDir

public void setJaxbBinDir(File jaxbBinDir)
Parameters:
jaxbBinDir - the JAXB location to set

getJaxbPackageName

public String getJaxbPackageName()
                          throws CoxbGenException
Returns:
the package name used for JAXB classes
Throws:
CoxbGenException - if pacakage could not le extracted from XML schema

setJaxbPackageName

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

Parameters:
jaxbPackageName - the JAXB classes package name to set

isGenerateIsSetMethod

public boolean isGenerateIsSetMethod()
Returns:
if IsSet Methods should be generated

setGenerateIsSetMethod

public void setGenerateIsSetMethod(boolean generateIsSetMethod)
Parameters:
generateIsSetMethod - if IsSet Methods should be generated

getSerializableUid

public long getSerializableUid()
Returns:
the serialization unique ID. (All JAXB classes must be serializable for LegStar)

setSerializableUid

public void setSerializableUid(long serializableUid)
Parameters:
serializableUid - the serialization unique ID. (All JAXB classes must be serializable for LegStar)

getTypeNamePrefix

public String getTypeNamePrefix()
Returns:
the prefix to add to type names

setTypeNamePrefix

public void setTypeNamePrefix(String typeNamePrefix)
Parameters:
typeNamePrefix - the prefix to add to type names

getTypeNameSuffix

public String getTypeNameSuffix()
Returns:
the suffix to add to type names

setTypeNameSuffix

public void setTypeNameSuffix(String typeNameSuffix)
Parameters:
typeNameSuffix - the suffix to add to type names

getElementNamePrefix

public String getElementNamePrefix()
Returns:
the prefix to add to element names

setElementNamePrefix

public void setElementNamePrefix(String elementNamePrefix)
Parameters:
elementNamePrefix - the prefix to add to element names

getElementNameSuffix

public String getElementNameSuffix()
Returns:
the suffix to add to element names

setElementNameSuffix

public void setElementNameSuffix(String elementNameSuffix)
Parameters:
elementNameSuffix - the suffix to add to element names

isEciCompatible

public boolean isEciCompatible()
Whether the ECI naming conventions should be used.

Returns:
Whether the ECI naming conventions should be used

setEciCompatible

public void setEciCompatible(boolean eciCompatible)
Whether the ECI naming conventions should be used.

Parameters:
eciCompatible - whether the ECI naming conventions should be used

isNoPackageInfo

public boolean isNoPackageInfo()
Prevents generation of JAXB package-info.java which does not compile under JDK 1.5.

Returns:
true if we should not generate package-info.java

setNoPackageInfo

public void setNoPackageInfo(boolean noPackageInfo)
Prevents generation of JAXB package-info.java which does not compile under JDK 1.5.

Parameters:
noPackageInfo - true if we should not generate package-info.java

getCoxbPackageName

public String getCoxbPackageName()
                          throws CoxbGenException
Returns:
the package name for generated binding classes
Throws:
CoxbGenException - if package name cannot be extracted from XML Schema

setCoxbPackageName

public void setCoxbPackageName(String coxbPackageName)
Parameters:
coxbPackageName - package name for generated binding classes to set

getAlternativePackageName

public String getAlternativePackageName()
Returns:
the optional runtime alternative to the Jaxb package name used at generation time

setAlternativePackageName

public void setAlternativePackageName(String alternativePackageName)
Parameters:
alternativePackageName - the optional runtime alternative to the Jaxb package name used at generation time

getAlternativeFactoryName

public String getAlternativeFactoryName()
Returns:
the alternate factory to used rather than the JAXB one.

setAlternativeFactoryName

public void setAlternativeFactoryName(String targetFactoryName)
Parameters:
targetFactoryName - the alternate factory to used rather than the JAXB one

getJaxbSrcDir

public File getJaxbSrcDir()
This is not strictly needed for binding generation but is useful when this model is also used for JAXB classes generation.

Returns:
the location where JAXB classes sources live

setJaxbSrcDir

public void setJaxbSrcDir(File jaxbSrcDir)
Parameters:
jaxbSrcDir - the location where JAXB classes sources live to set

getJaxbRootClassNames

public List<String> getJaxbRootClassNames()
Returns:
the set of Jaxb root class names to generated binding classes for

setJaxbRootClassNames

public void setJaxbRootClassNames(List<String> jaxbRootClassNames)
Parameters:
jaxbRootClassNames - the set of Jaxb root class names to generated binding classes for to set

getCoxbBinDir

public File getCoxbBinDir()
Returns:
the target directory where binary files will be created

setCoxbBinDir

public void setCoxbBinDir(File coxbBinDir)
Parameters:
coxbBinDir - the target directory where binary files will be created to set

getJaxbGenModel

public JaxbGenModel getJaxbGenModel()
Returns:
the JAXB binding customization

setJaxbGenModel

public void setJaxbGenModel(JaxbGenModel jaxbGenModel)
Parameters:
jaxbGenModel - the JAXB binding customization to set

isXmlTransformers

public boolean isXmlTransformers()
Returns:
true if Host to XML transformers generation is turned on

setXmlTransformers

public void setXmlTransformers(boolean xmlTransformers)
Parameters:
xmlTransformers - true if Host to XML transformers generation is turned on

isJsonTransformers

public boolean isJsonTransformers()
Returns:
true if Host to JSON transformers generation is turned on

setJsonTransformers

public void setJsonTransformers(boolean jsonTransformers)
Parameters:
jsonTransformers - true if Host to JSON transformers generation is turned on

isCompileTransformers

public boolean isCompileTransformers()
Returns:
true if transformers compilation is turned on

setCompileTransformers

public void setCompileTransformers(boolean compileTransformers)
Parameters:
compileTransformers - true if transformers compilation is turned on

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

getJaxbPackageNameFromXsd

public String getJaxbPackageNameFromXsd(File xsdFile)
                                 throws CoxbGenException
Extracts the JAXB package name from the XML schema targetNamespace.

We delegate code to XJC which already knows how to turn a targetnamespace into a package name.

Parameters:
xsdFile - the XML schema file
Returns:
the package name
Throws:
CoxbGenException - if package name cannot be retrieved from XSD

getJaxbClassIncludes

public String getJaxbClassIncludes()
                            throws CoxbGenException
Turn the JAXB package name into an include statement that we can used as an includes property for a javac ant step.

Returns:
an include statement for javac
Throws:
CoxbGenException - if JAXB pacakge name does not exist

getDocBuilder

protected DocumentBuilder getDocBuilder()
                                 throws CoxbGenException
Creates a DOM document builder if none has already been created.

Returns:
an instance of a DOM builder
Throws:
CoxbGenException - if DOM builder cannot be created

toProperties

public Properties toProperties()
Overrides:
toProperties in class AbstractAntBuildModel
Returns:
a properties file holding the values of this object fields

toStringList

protected List<String> toStringList(List<UnmarshalChoiceStrategy> unmarshalChoiceStrategies)
Helper to serialize the list unmarshal choice strategies to a properties file.

Parameters:
unmarshalChoiceStrategies - the list of unmarshal choice strategies
Returns:
a list of strings

toUnmarshalChoiceStrategies

protected List<UnmarshalChoiceStrategy> toUnmarshalChoiceStrategies(List<String> stringList)
Helper to deserialize a list of unmarshal choice strategies from a properties file.

Parameters:
stringList - a list of strings
Returns:
a list of unmarshal choice strategies


Copyright © 2015 LegSem. All Rights Reserved.