org.apache.tuscany.sdo.generate
Class JavaGenerator

java.lang.Object
  extended by org.apache.tuscany.sdo.generate.JavaGenerator
Direct Known Subclasses:
Interface2JavaGenerator, XSD2JavaGenerator

public abstract class JavaGenerator
extends java.lang.Object

Abstract base class for static SDO code generators. See XSD2JavaGenerator and Interface2JavaGenerator for concrete generator commands. Supports the following command line options: [ -targetDirectory ] [ -javaPackage ] [ -prefix ] [ -sparsePattern | -storePattern ] [ -noInterfaces ] [ -noContainment ] [ -noNotification ] [ -arrayAccessors ] [ -generateLoader ] [ -noUnsettable ] [ -noEMF ] [ -interfaceDataObject ] Basic options: -targetDirectory Generates the Java source code in the specified directory. By default, the code is generated in the same directory as the input xsd or wsdl file. -javaPackage Overrides the Java package for the generated classes. By default the package name is derived from the targetNamespace of the XML schema being generated. For example, if the targetNamespace is "http://www.example.com/simple", the default package will be "com.example.simple". -prefix Specifies the prefix string to use for naming the generated factory. For example "-prefix Foo" will result in a factory interface with the name "FooFactory". -sparsePattern For SDO metamodels that have classes with many properties of which only a few are typically set at runtime, this option can be used to produce a space-optimized implementation (at the expense of speed). -storePattern This option can be used to generate static classes that work with a Store-based DataObject implementation. It changes the generator pattern to generate accessors which delegate to the reflective methods (as opposed to the other way around) and changes the DataObject base class to org.apache.tuscany.sdo.impl.StoreDataObjectImpl. Note that this option generates classes that require a Store implementation to be provided before they can be run. -noEMF This option is used to generate static classes that have no references to EMF classes. This feature is currently being implemented and is in a preliminary state. -interfaceDataObject This option is used to generate static interfaces that extend commonj.sdo.DataObject The following options can be used to increase performance, but with some loss of SDO functionality: -noInterfaces By default, each DataObject generates both a Java interface and a corresponding implementation class. If an SDO metamodel does not use multiple inheritance (which is always the case for XML Schema derived models), then this option can be used to eliminate the interface and to generate only an implementation class. Following are planned but not supported yet: -noNotification This option eliminates all change notification overhead in the generated classes. Changes to DataObjects generated using this option cannot be recorded, and consequently the classes cannot be used with an SDO ChangeSummary or DataGraph. -noContainment Turns off container management for containment properties. DataObject.getContainer() will always return null for data objects generated with this option, even if a containment reference is set. Setting a containment reference will also not automatically remove the target object from its previous container, if it had one, so it will need to be explicitly removed by the client. Use of this option is only recommended for scenarios where this kind of container movement/management is not necessary. -arrayAccessors Generates Java array getters/setters for multiplicity-many properties. With this option, the set of "standard" JavaBean array accessor methods (e.g., Foo[] getFoo(), Foo getFoo(int), int getFooLength(), setFoo(Foo[]), and void setFoo(int, Foo)) are generated. The normal List-returning accessor is renamed with the suffix "List" (e.g., List getFooList()). The array returned by the generated method is not a copy, but instead a pointer to the underlying storage array, so directly modifying it can have undesirable consequences and should be avoided. -generateLoader Generate a fast XML parser/loader for instances of the model. The details of this option are subject to change, but currently it generates two additional classes in a "util" package: ResourceImpl and ResourceFactoryImpl. To use the generated loader at runtime, you need to pass an option to the XMLHelper.load() method like this: Map options = new HashMap(); options.put("GENERATED_LOADER", ResourceFactoryImpl.class); XMLDocument doc = XMLHelper.INSTANCE.load(new FileInputStream("somefile.xml"), null, options); Note: this option currently only works for simple schemas without substitution groups or wildcards. -noUnsettable By default, some XML constructs result in SDO property implementations that maintain additional state information to record when the property has been set to the "default value", as opposed to being truly unset (see DataObject.isSet() and DataObject.unset()). The SDO specification allows an implementation to choose to provide this behavior or not. With this option, all generated properties will not record their unset state. The generated isSet() methods simply returns whether the current value is equal to the property's "default value".


Field Summary
protected  int genOptions
           
protected  int inputIndex
           
protected  java.lang.String javaPackage
           
static int OPTION_ARRAY_ACCESSORS
           
static int OPTION_GENERATE_LOADER
           
static int OPTION_GENERATE_SWITCH
           
static int OPTION_INTERFACE_DO
           
static int OPTION_NO_CONTAINMENT
           
static int OPTION_NO_EMF
           
static int OPTION_NO_INTERFACES
           
static int OPTION_NO_NOTIFICATION
           
static int OPTION_NO_UNSETTABLE
           
static int OPTION_SPARSE_PATTERN
           
static int OPTION_STORE_PATTERN
           
protected  java.lang.String prefix
           
protected  java.lang.String targetDirectory
           
protected  java.lang.String xsdFileName
           
 
Constructor Summary
JavaGenerator()
           
 
Method Summary
static org.eclipse.emf.codegen.ecore.genmodel.GenPackage createGenPackage(org.eclipse.emf.ecore.EPackage ePackage, java.lang.String basePackage, java.lang.String prefix, int genOptions, org.eclipse.emf.ecore.resource.ResourceSet resourceSet)
           
static org.eclipse.emf.codegen.ecore.genmodel.GenModel ecore2GenModel(org.eclipse.emf.ecore.EPackage ePackage, java.lang.String basePackage, java.lang.String prefix, int genOptions)
           
static java.lang.String extractBasePackageName(org.eclipse.emf.ecore.EPackage ePackage, java.lang.String javaPackage)
           
static void generateFromEPackage(org.eclipse.emf.ecore.EPackage ePackage, java.lang.String targetDirectory, java.lang.String basePackage, java.lang.String prefix, int genOptions)
           
static void generateFromGenModel(org.eclipse.emf.codegen.ecore.genmodel.GenModel genModel, java.lang.String targetDirectory, int genOptions)
           
static void generateFromXMLSchema(java.lang.String xsdFileName, java.lang.String targetDirectory, java.lang.String javaPackage, java.lang.String prefix, int genOptions)
          Deprecated. moved to XSD2JavaGenerator
static void generatePackages(java.util.Collection packageList, java.lang.String packageURI, java.lang.String shortName, java.lang.String targetDirectory, java.lang.String javaPackage, java.lang.String prefix, int genOptions)
           
static java.lang.String getSchemaNamespace(java.lang.String xsdFileName)
          Deprecated.  
protected  int handleArgument(java.lang.String[] args, int index)
           
static void main(java.lang.String[] args)
          Deprecated. replaced by XSD2JavaGenerator
protected static void printDiagnostic(org.eclipse.emf.common.util.Diagnostic diagnostic, java.lang.String indent)
           
protected static void printUsage()
           
protected  void processArguments(java.lang.String[] args)
           
protected abstract  void run(java.lang.String[] args)
           
static java.lang.String safeQualifiedName(java.lang.String qualifiedName)
           
static java.lang.String shortName(java.lang.String qualifiedName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPTION_NO_INTERFACES

public static int OPTION_NO_INTERFACES

OPTION_SPARSE_PATTERN

public static int OPTION_SPARSE_PATTERN

OPTION_STORE_PATTERN

public static int OPTION_STORE_PATTERN

OPTION_NO_CONTAINMENT

public static int OPTION_NO_CONTAINMENT

OPTION_NO_NOTIFICATION

public static int OPTION_NO_NOTIFICATION

OPTION_ARRAY_ACCESSORS

public static int OPTION_ARRAY_ACCESSORS

OPTION_GENERATE_LOADER

public static int OPTION_GENERATE_LOADER

OPTION_NO_UNSETTABLE

public static int OPTION_NO_UNSETTABLE

OPTION_GENERATE_SWITCH

public static int OPTION_GENERATE_SWITCH

OPTION_NO_EMF

public static int OPTION_NO_EMF

OPTION_INTERFACE_DO

public static int OPTION_INTERFACE_DO

targetDirectory

protected java.lang.String targetDirectory

javaPackage

protected java.lang.String javaPackage

prefix

protected java.lang.String prefix

genOptions

protected int genOptions

xsdFileName

protected java.lang.String xsdFileName

inputIndex

protected int inputIndex
Constructor Detail

JavaGenerator

public JavaGenerator()
Method Detail

main

public static void main(java.lang.String[] args)
Deprecated. replaced by XSD2JavaGenerator


processArguments

protected void processArguments(java.lang.String[] args)

handleArgument

protected int handleArgument(java.lang.String[] args,
                             int index)

run

protected abstract void run(java.lang.String[] args)

generateFromXMLSchema

public static void generateFromXMLSchema(java.lang.String xsdFileName,
                                         java.lang.String targetDirectory,
                                         java.lang.String javaPackage,
                                         java.lang.String prefix,
                                         int genOptions)
Deprecated. moved to XSD2JavaGenerator


generatePackages

public static void generatePackages(java.util.Collection packageList,
                                    java.lang.String packageURI,
                                    java.lang.String shortName,
                                    java.lang.String targetDirectory,
                                    java.lang.String javaPackage,
                                    java.lang.String prefix,
                                    int genOptions)

getSchemaNamespace

public static java.lang.String getSchemaNamespace(java.lang.String xsdFileName)
Deprecated. 


createGenPackage

public static org.eclipse.emf.codegen.ecore.genmodel.GenPackage createGenPackage(org.eclipse.emf.ecore.EPackage ePackage,
                                                                                 java.lang.String basePackage,
                                                                                 java.lang.String prefix,
                                                                                 int genOptions,
                                                                                 org.eclipse.emf.ecore.resource.ResourceSet resourceSet)

generateFromEPackage

public static void generateFromEPackage(org.eclipse.emf.ecore.EPackage ePackage,
                                        java.lang.String targetDirectory,
                                        java.lang.String basePackage,
                                        java.lang.String prefix,
                                        int genOptions)

generateFromGenModel

public static void generateFromGenModel(org.eclipse.emf.codegen.ecore.genmodel.GenModel genModel,
                                        java.lang.String targetDirectory,
                                        int genOptions)

ecore2GenModel

public static org.eclipse.emf.codegen.ecore.genmodel.GenModel ecore2GenModel(org.eclipse.emf.ecore.EPackage ePackage,
                                                                             java.lang.String basePackage,
                                                                             java.lang.String prefix,
                                                                             int genOptions)

extractBasePackageName

public static java.lang.String extractBasePackageName(org.eclipse.emf.ecore.EPackage ePackage,
                                                      java.lang.String javaPackage)

shortName

public static java.lang.String shortName(java.lang.String qualifiedName)

safeQualifiedName

public static java.lang.String safeQualifiedName(java.lang.String qualifiedName)

printDiagnostic

protected static void printDiagnostic(org.eclipse.emf.common.util.Diagnostic diagnostic,
                                      java.lang.String indent)

printUsage

protected static void printUsage()


Copyright © 2006 Apache Software Foundation. All Rights Reserved.