com.sun.tools.xjc

Class Options

public class Options extends Object

Global options.

This class stores invocation configuration for XJC. The configuration in this class should be abstract enough so that it could be parsed from both command-line or Ant.

Field Summary
List<Plugin>activePlugins
Plugins that are enabled in this compilation.
booleanautomaticNameConflictResolution
If true, try to resolve name conflicts automatically by assigning mechanical numbers.
ClassNameAllocatorclassNameAllocator
This allocator has the final say on deciding the class name.
List<URL>classpaths
intcompatibilityMode
this switch determines how carefully the compiler will follow the compatibility rules in the spec.
booleancontentForWildcard
When on, generates content property for types with multiple xs:any derived elements (which is supposed to be correct behaviour)
booleandebugMode
If "-debug" is specified.
StringdefaultPackage
The -p option that should control the default Java package that will contain the generated code.
StringdefaultPackage2
Similar to the -p option, but this one works with a lower priority, and customizations overrides this.
booleanenableIntrospection
When on, fixes getter/setter generation to match the Bean Introspection API
EntityResolverentityResolver
Actually stores CatalogResolver, but the field type is made to EntityResolver so that XJC can be used even if resolver.jar is not available in the classpath.
static intEXTENSION
loosely follow the compatibility rules and allow the use of vendor binding extensions
booleannoFileHeader
No file header comment (to be more friendly with diff.)
booleanpackageLevelAnnotations
This switch controls whether or not xjc will generate package level annotations
Set<String>pluginURIs
Set of URIs that plug-ins recognize as extension bindings.
booleanquiet
If the "-quiet" option is specified.
booleanreadOnly
If the -readOnly option is specified.
booleanruntime14
If -explicit-annotation option is specified.
booleanstrictCheck
Check the source schemas with extra scrutiny.
static intSTRICT
strictly follow the compatibility rules and reject schemas that contain features from App.
SpecVersiontarget
Generates output for the specified version of the runtime.
FiletargetDir
Target directory when producing files.
booleanverbose
If the "-verbose" option is specified.
Constructor Summary
Options()
Method Summary
voidaddBindFile(InputSource is)
Adds a new binding file.
voidaddBindFile(File bindFile)
Adds a new binding file.
voidaddBindFileRecursive(File dir)
Recursively scan directories and add all ".xjb" files in it.
voidaddCatalog(File catalogFile)
Adds a new catalog file.
voidaddGrammar(InputSource is)
Adds a new input schema.
voidaddGrammar(File source)
voidaddGrammarRecursive(File dir)
Recursively scan directories and add all XSD files in it.
CodeWritercreateCodeWriter()
Creates a configured CodeWriter that produces files into the specified directory.
CodeWritercreateCodeWriter(CodeWriter core)
Creates a configured CodeWriter that produces files into the specified directory.
List<Plugin>getAllPlugins()
Gets all the Plugins discovered so far.
InputSource[]getBindFiles()
Input external binding files.
static StringgetBuildID()
FieldRendererFactorygetFieldRendererFactory()
Gets the active FieldRendererFactory that shall be used to build Model.
InputSource[]getGrammars()
Input schema files.
NameConvertergetNameConverter()
Gets the active NameConverter that shall be used to build Model.
StringgetPrologComment()
Gets the string suitable to be used as the prolog comment baked into artifacts.
LanguagegetSchemaLanguage()
URLClassLoadergetUserClassLoader(ClassLoader parent)
Gets a classLoader that can load classes specified via the -classpath option.
LanguageguessSchemaLanguage()
Guesses the schema language.
booleanisExtensionMode()
intparseArgument(String[] args, int i)
Parses an option args[i] and return the number of tokens consumed.
voidparseArguments(String[] args)
Parses arguments and fill fields of this object.
StringrequireArgument(String optionName, String[] args, int i)
Obtains an operand and reports an error if it's not there.
voidscanEpisodeFile(File jar)
Finds the META-INF/sun-jaxb.episode file to add as a binding customization.
voidsetFieldRendererFactory(FieldRendererFactory frf, Plugin owner)
voidsetNameConverter(NameConverter nc, Plugin owner)
Sets the NameConverter.
voidsetSchemaLanguage(Language _schemaLanguage)

Field Detail

activePlugins

public final List<Plugin> activePlugins
Plugins that are enabled in this compilation.

automaticNameConflictResolution

public boolean automaticNameConflictResolution
If true, try to resolve name conflicts automatically by assigning mechanical numbers.

classNameAllocator

public ClassNameAllocator classNameAllocator
This allocator has the final say on deciding the class name.

classpaths

public final List<URL> classpaths

compatibilityMode

public int compatibilityMode
this switch determines how carefully the compiler will follow the compatibility rules in the spec. Either STRICT or EXTENSION.

contentForWildcard

public boolean contentForWildcard
When on, generates content property for types with multiple xs:any derived elements (which is supposed to be correct behaviour)

debugMode

public boolean debugMode
If "-debug" is specified.

defaultPackage

public String defaultPackage
The -p option that should control the default Java package that will contain the generated code. Null if unspecified.

defaultPackage2

public String defaultPackage2
Similar to the -p option, but this one works with a lower priority, and customizations overrides this. Used by JAX-RPC.

enableIntrospection

public boolean enableIntrospection
When on, fixes getter/setter generation to match the Bean Introspection API

entityResolver

public EntityResolver entityResolver
Actually stores CatalogResolver, but the field type is made to EntityResolver so that XJC can be used even if resolver.jar is not available in the classpath.

EXTENSION

public static final int EXTENSION
loosely follow the compatibility rules and allow the use of vendor binding extensions

noFileHeader

public boolean noFileHeader
No file header comment (to be more friendly with diff.)

packageLevelAnnotations

public boolean packageLevelAnnotations
This switch controls whether or not xjc will generate package level annotations

pluginURIs

public final Set<String> pluginURIs
Set of URIs that plug-ins recognize as extension bindings.

quiet

public boolean quiet
If the "-quiet" option is specified.

readOnly

public boolean readOnly
If the -readOnly option is specified.

runtime14

public boolean runtime14
If -explicit-annotation option is specified.

This generates code that works around issues specific to 1.4 runtime.

strictCheck

public boolean strictCheck
Check the source schemas with extra scrutiny. The exact meaning depends on the schema language.

STRICT

public static final int STRICT
strictly follow the compatibility rules and reject schemas that contain features from App. E.2, use vendor binding extensions

target

public SpecVersion target
Generates output for the specified version of the runtime.

targetDir

public File targetDir
Target directory when producing files.

This field is not used when XJC is driven through the XJC API. Plugins that need to generate extra files should do so by using JPackage#addResourceFile(JResourceFile).

verbose

public boolean verbose
If the "-verbose" option is specified.

Constructor Detail

Options

public Options()

Method Detail

addBindFile

public void addBindFile(InputSource is)
Adds a new binding file.

addBindFile

public void addBindFile(File bindFile)
Adds a new binding file.

addBindFileRecursive

public void addBindFileRecursive(File dir)
Recursively scan directories and add all ".xjb" files in it.

addCatalog

public void addCatalog(File catalogFile)
Adds a new catalog file.

addGrammar

public void addGrammar(InputSource is)
Adds a new input schema.

addGrammar

public void addGrammar(File source)

addGrammarRecursive

public void addGrammarRecursive(File dir)
Recursively scan directories and add all XSD files in it.

createCodeWriter

public CodeWriter createCodeWriter()
Creates a configured CodeWriter that produces files into the specified directory.

createCodeWriter

public CodeWriter createCodeWriter(CodeWriter core)
Creates a configured CodeWriter that produces files into the specified directory.

getAllPlugins

public List<Plugin> getAllPlugins()
Gets all the Plugins discovered so far.

A plugins are enumerated when this method is called for the first time, by taking classpaths into account. That means "-cp plugin.jar" has to come before you specify options to enable it.

getBindFiles

public InputSource[] getBindFiles()
Input external binding files.

getBuildID

public static String getBuildID()

getFieldRendererFactory

public FieldRendererFactory getFieldRendererFactory()
Gets the active FieldRendererFactory that shall be used to build Model.

Returns: always non-null.

getGrammars

public InputSource[] getGrammars()
Input schema files.

getNameConverter

public NameConverter getNameConverter()
Gets the active NameConverter that shall be used to build Model.

Returns: can be null, in which case it's up to the binding.

getPrologComment

public String getPrologComment()
Gets the string suitable to be used as the prolog comment baked into artifacts. This is the string like "This file was generated by the JAXB RI on YYYY/mm/dd..."

getSchemaLanguage

public Language getSchemaLanguage()

getUserClassLoader

public URLClassLoader getUserClassLoader(ClassLoader parent)
Gets a classLoader that can load classes specified via the -classpath option.

guessSchemaLanguage

public Language guessSchemaLanguage()
Guesses the schema language.

isExtensionMode

public boolean isExtensionMode()

parseArgument

public int parseArgument(String[] args, int i)
Parses an option args[i] and return the number of tokens consumed.

Returns: 0 if the argument is not understood. Returning 0 will let the caller report an error.

Throws: BadCommandLineException If the callee wants to provide a custom message for an error.

parseArguments

public void parseArguments(String[] args)
Parses arguments and fill fields of this object.

Throws: BadCommandLineException thrown when there's a problem in the command-line arguments

requireArgument

public String requireArgument(String optionName, String[] args, int i)
Obtains an operand and reports an error if it's not there.

scanEpisodeFile

public void scanEpisodeFile(File jar)
Finds the META-INF/sun-jaxb.episode file to add as a binding customization.

setFieldRendererFactory

public void setFieldRendererFactory(FieldRendererFactory frf, Plugin owner)
Sets the FieldRendererFactory.

This method is for plugins to call to set a custom FieldRendererFactory.

Parameters: frf The FieldRendererFactory to be installed. Must not be null. owner Identifies the plugin that owns this FieldRendererFactory. When two Plugins try to call this method, this allows XJC to report it as a user-friendly error message.

Throws: BadCommandLineException If a conflit happens, this exception carries a user-friendly error message, indicating a conflict.

setNameConverter

public void setNameConverter(NameConverter nc, Plugin owner)
Sets the NameConverter.

This method is for plugins to call to set a custom NameConverter.

Parameters: nc The NameConverter to be installed. Must not be null. owner Identifies the plugin that owns this NameConverter. When two Plugins try to call this method, this allows XJC to report it as a user-friendly error message.

Throws: BadCommandLineException If a conflit happens, this exception carries a user-friendly error message, indicating a conflict.

setSchemaLanguage

public void setSchemaLanguage(Language _schemaLanguage)