Top Description Fields Constructors Methods
com.sun.tools.xjc

public Class Options

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.tools.xjc.Driver.OptionsEx
Imports
java.io.BufferedReader, .File, .FileInputStream, .IOException, .InputStreamReader, .PrintWriter, .StringWriter, java.net.MalformedURLException, .URI, .URISyntaxException, .URL, .URLClassLoader, java.nio.charset.Charset, .IllegalCharsetNameException, .StandardCharsets, java.security.AccessController, .PrivilegedAction, java.text.SimpleDateFormat, java.util.ArrayList, .Date, .Enumeration, .HashMap, .HashSet, .List, .Locale, .Map, .ServiceLoader, .Set, java.util.logging.Level, .Logger, com.sun.codemodel.CodeWriter, .JPackage, .JResourceFile, com.sun.codemodel.writer.FileCodeWriter, .PrologCodeWriter, com.sun.istack.tools.DefaultAuthenticator, com.sun.tools.xjc.api.ClassNameAllocator, .SpecVersion, com.sun.tools.xjc.generator.bean.field.FieldRendererFactory, com.sun.tools.xjc.model.Model, com.sun.tools.xjc.reader.Util, org.glassfish.jaxb.core.api.impl.NameConverter, org.xml.sax.EntityResolver, .InputSource

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

Modifier and TypeField and Description
public final List<Plugin>
activePlugins

Plugins that are enabled in this compilation.

private List<Plugin>
allPlugins

All discovered Plugins.

public boolean
automaticNameConflictResolution

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

private static final String
private final List<InputSource>
private final ArrayList<URI>
public ClassNameAllocator
classNameAllocator

This allocator has the final say on deciding the class name.

public final Map<String, String>
public final List<URL>
public int
compatibilityMode

this switch determines how carefully the compiler will follow the compatibility rules in the spec.

public boolean
contentForWildcard

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

public boolean
debugMode

If "-debug" is specified.

public String
defaultPackage

The -p option that should control the default Java package that will contain the generated code.

public String
defaultPackage2

Similar to the -p option, but this one works with a lower priority, and customizations overrides this.

public boolean
disableXmlSecurity

If true XML security features when parsing XML documents will be disabled.

public boolean
enableIntrospection

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

public String
encoding

Encoding to be used by generated java sources, null for platform default.

public EntityResolver
entityResolver

On JDK 8 an odler 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.

public static final int
EXTENSION

loosely follow the compatibility rules and allow the use of vendor binding extensions

private FieldRendererFactory
fieldRendererFactory

This FieldRendererFactory determines how the fields are generated.

private Plugin
fieldRendererFactoryOwner

Used to detect if two Plugins try to overwrite fieldRendererFactory.

private final List<InputSource>
grammars

Input schema files as a list of InputSources.

private static final String
private String
javaModule

Java module name in module-info.java.

private static final String
private static final String
private static final Logger
private NameConverter
nameConverter

If this is non-null, we use this NameConverter over the one given in the schema/binding.

private Plugin
nameConverterOwner

Used to detect if two Plugins try to overwrite nameConverter.

public boolean
noFileHeader

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

public boolean
noFileHeaderDate

File header comment without timestamp generation in it (to be more friendly with diff.)

public boolean
packageLevelAnnotations

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

private String
pluginLoadFailure

If a plugin failed to load, report.

public final Set<String>
pluginURIs

Set of URIs that plug-ins recognize as extension bindings.

public String
private String
private String
public boolean
quiet

If the "-quiet" option is specified.

public boolean
readOnly

If the -readOnly option is specified.

public boolean
runtime14

If -explicit-annotation option is specified.

private Language
schemaLanguage

Type of input schema language.

public static final int
STRICT

strictly follow the compatibility rules and reject schemas that contain features from App.

public boolean
strictCheck

Check the source schemas with extra scrutiny.

public SpecVersion
target

Generates output for the specified version of the runtime.

public File
targetDir

Target directory when producing files.

public boolean
verbose

If the "-verbose" option is specified.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private InputSource
public void
addBindFile(InputSource is)

Adds a new binding file.

public void
addBindFile(File bindFile)

Adds a new binding file.

public void
addBindFileRecursive(File dir)

Recursively scan directories and add all ".xjb" files in it.

public void
addCatalog(File catalogFile)

Adds a new catalog file.Use created or existed resolver to parse new catalog file.

private boolean
private void
addFile(String name, List<InputSource> target, String
If the given token is a directory name, we do a recursive search and find all files that have the given suffix.
suffix
)

Parses a token to a file (or a set of files) and add them as InputSource to the specified list.

public void
addGrammar(InputSource is)

Adds a new input schema.

public void
addGrammar(File source)

public void
addGrammarRecursive(File dir)

Recursively scan directories and add all XSD files in it.

private void
addRecursive(File dir, String suffix, List<InputSource> result)

public CodeWriter
createCodeWriter()

Creates a configured CodeWriter that produces files into the specified directory.

public CodeWriter
createCodeWriter(CodeWriter core)

Creates a configured CodeWriter that produces files into the specified directory.

private InputSource
private <T> List<T>
findServices(Class<T> clazz)

Looks for all "META-INF/services/[className]" files and create one instance for each class name found inside this file.

public List<Plugin>
getAllPlugins()

Gets all the Plugins discovered so far.

public InputSource[]
getBindFiles()

Input external binding files.

public static String
private static boolean
public FieldRendererFactory

Returns:

always non-null.
getFieldRendererFactory
()

Gets the active FieldRendererFactory that shall be used to build Model.

public InputSource[]
getGrammars()

Input schema files.

public String

Returns:

Java module name option or null if this option was not set.
getModuleName
()

Gets Java module name option.

public NameConverter

Returns:

can be null, in which case it's up to the binding.
getNameConverter
()

Gets the active NameConverter that shall be used to build Model.

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..."

public Language
public ClassLoader
getUserClassLoader(ClassLoader parent)

Gets a classLoader that can load classes specified via the -classpath option.

public Language
guessSchemaLanguage()

Guesses the schema language.

public boolean
private boolean
public static String
public int

Returns:

0 if the argument is not understood. Returning 0 will let the caller report an error.
parseArgument
(String[] args, int i)

Parses an option args[i] and return the number of tokens consumed.

public void
parseArguments(String[] args)

Parses arguments and fill fields of this object.

private void
public String
requireArgument(String optionName, String[] args, int i)

Obtains an operand and reports an error if it's not there.

public void
scanEpisodeFile(File jar)

Finds the META-INF/sun-jaxb.episode file to add as a binding customization.

public void
setFieldRendererFactory(FieldRendererFactory
The FieldRendererFactory to be installed. Must not be null.
frf
,
Plugin
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.
owner
)

Sets the FieldRendererFactory.

public void
setNameConverter(NameConverter
The NameConverter to be installed. Must not be null.
nc
,
Plugin
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.
owner
)

Sets the NameConverter.

public void
setSchemaLanguage(Language _schemaLanguage)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

activePluginsback to summary
public final List<Plugin> activePlugins

Plugins that are enabled in this compilation.

allPluginsback to summary
private List<Plugin> allPlugins

All discovered Plugins. This is lazily parsed, so that we can take '-cp' option into account.

See Also
getAllPlugins()
automaticNameConflictResolutionback to summary
public boolean automaticNameConflictResolution

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

BINDback to summary
private static final String BIND
bindFilesback to summary
private final List<InputSource> bindFiles
catalogUrlsback to summary
private final ArrayList<URI> catalogUrls
classNameAllocatorback to summary
public ClassNameAllocator classNameAllocator

This allocator has the final say on deciding the class name.

classNameReplacerback to summary
public final Map<String, String> classNameReplacer
classpathsback to summary
public final List<URL> classpaths
compatibilityModeback to summary
public int compatibilityMode

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

contentForWildcardback to summary
public boolean contentForWildcard

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

debugModeback to summary
public boolean debugMode

If "-debug" is specified.

defaultPackageback to summary
public String defaultPackage

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

defaultPackage2back to summary
public String defaultPackage2

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

disableXmlSecurityback to summary
public boolean disableXmlSecurity

If true XML security features when parsing XML documents will be disabled. The default value is false.

Boolean

Since
2.2.6
enableIntrospectionback to summary
public boolean enableIntrospection

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

encodingback to summary
public String encoding

Encoding to be used by generated java sources, null for platform default.

entityResolverback to summary
public EntityResolver entityResolver

On JDK 8 an odler 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.

EXTENSIONback to summary
public static final int EXTENSION

loosely follow the compatibility rules and allow the use of vendor binding extensions

fieldRendererFactoryback to summary
private FieldRendererFactory fieldRendererFactory

This FieldRendererFactory determines how the fields are generated.

fieldRendererFactoryOwnerback to summary
private Plugin fieldRendererFactoryOwner

Used to detect if two Plugins try to overwrite fieldRendererFactory.

grammarsback to summary
private final List<InputSource> grammars

Input schema files as a list of InputSources.

JAKARTAback to summary
private static final String JAKARTA
javaModuleback to summary
private String javaModule

Java module name in module-info.java.

JAVAXback to summary
private static final String JAVAX
JAXB_COREback to summary
private static final String JAXB_CORE
loggerback to summary
private static final Logger logger
nameConverterback to summary
private NameConverter nameConverter

If this is non-null, we use this NameConverter over the one given in the schema/binding.

nameConverterOwnerback to summary
private Plugin nameConverterOwner

Used to detect if two Plugins try to overwrite nameConverter.

noFileHeaderback to summary
public boolean noFileHeader

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

noFileHeaderDateback to summary
public boolean noFileHeaderDate

File header comment without timestamp generation in it (to be more friendly with diff.)

packageLevelAnnotationsback to summary
public boolean packageLevelAnnotations

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

pluginLoadFailureback to summary
private String pluginLoadFailure

If a plugin failed to load, report.

pluginURIsback to summary
public final Set<String> pluginURIs

Set of URIs that plug-ins recognize as extension bindings.

proxyAuthback to summary
public String proxyAuth
proxyHostback to summary
private String proxyHost
proxyPortback to summary
private String proxyPort
quietback to summary
public boolean quiet

If the "-quiet" option is specified.

readOnlyback to summary
public boolean readOnly

If the -readOnly option is specified.

runtime14back to summary
public boolean runtime14

If -explicit-annotation option is specified.

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

schemaLanguageback to summary
private Language schemaLanguage

Type of input schema language. One of the SCHEMA_XXX constants.

STRICTback to summary
public static final int STRICT

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

strictCheckback to summary
public boolean strictCheck

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

targetback to summary
public SpecVersion target

Generates output for the specified version of the runtime.

targetDirback to summary
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).

verboseback to summary
public boolean verbose

If the "-verbose" option is specified.

Constructor Detail

Optionsback to summary
public Options()

Method Detail

absolutizeback to summary
private InputSource absolutize(InputSource is)
addBindFileback to summary
public void addBindFile(InputSource is)

Adds a new binding file.

addBindFileback to summary
public void addBindFile(File bindFile)

Adds a new binding file.

addBindFileRecursiveback to summary
public void addBindFileRecursive(File dir)

Recursively scan directories and add all ".xjb" files in it.

addCatalogback to summary
public void addCatalog(File catalogFile) throws IOException

Adds a new catalog file.Use created or existed resolver to parse new catalog file.

addClassNameReplacersback to summary
private boolean addClassNameReplacers(SpecVersion target)
addFileback to summary
private void addFile(String name, List<InputSource> target, String suffix) throws BadCommandLineException

Parses a token to a file (or a set of files) and add them as InputSource to the specified list.

Parameters
suffix:String

If the given token is a directory name, we do a recursive search and find all files that have the given suffix.

addGrammarback to summary
public void addGrammar(InputSource is)

Adds a new input schema.

addGrammarback to summary
public void addGrammar(File source)
addGrammarRecursiveback to summary
public void addGrammarRecursive(File dir)

Recursively scan directories and add all XSD files in it.

addRecursiveback to summary
private void addRecursive(File dir, String suffix, List<InputSource> result)
createCodeWriterback to summary
public CodeWriter createCodeWriter() throws IOException

Creates a configured CodeWriter that produces files into the specified directory.

createCodeWriterback to summary
public CodeWriter createCodeWriter(CodeWriter core)

Creates a configured CodeWriter that produces files into the specified directory.

fileToInputSourceback to summary
private InputSource fileToInputSource(File source)
findServicesback to summary
private <T> List<T> findServices(Class<T> clazz)

Looks for all "META-INF/services/[className]" files and create one instance for each class name found inside this file.

getAllPluginsback to summary
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.

getBindFilesback to summary
public InputSource[] getBindFiles()

Input external binding files.

getBuildIDback to summary
public static String getBuildID()
getDebugPropertyValueback to summary
private static boolean getDebugPropertyValue()
getFieldRendererFactoryback to summary
public FieldRendererFactory getFieldRendererFactory()

Gets the active FieldRendererFactory that shall be used to build Model.

Returns:FieldRendererFactory

always non-null.

getGrammarsback to summary
public InputSource[] getGrammars()

Input schema files.

getModuleNameback to summary
public String getModuleName()

Gets Java module name option.

Returns:String

Java module name option or null if this option was not set.

getNameConverterback to summary
public NameConverter getNameConverter()

Gets the active NameConverter that shall be used to build Model.

Returns:NameConverter

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

getPrologCommentback to summary
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..."

getSchemaLanguageback to summary
public Language getSchemaLanguage()
getUserClassLoaderback to summary
public ClassLoader getUserClassLoader(ClassLoader parent)

Gets a classLoader that can load classes specified via the -classpath option.

guessSchemaLanguageback to summary
public Language guessSchemaLanguage()

Guesses the schema language.

isExtensionModeback to summary
public boolean isExtensionMode()
isJavaxback to summary
private boolean isJavax()
normalizeSystemIdback to summary
public static String normalizeSystemId(String systemId)
parseArgumentback to summary
public int parseArgument(String[] args, int i) throws BadCommandLineException

Parses an option args[i] and return the number of tokens consumed.

Returns:int

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

Exceptions
BadCommandLineException:
If the callee wants to provide a custom message for an error.
parseArgumentsback to summary
public void parseArguments(String[] args) throws BadCommandLineException

Parses arguments and fill fields of this object.

Exceptions
BadCommandLineException:
thrown when there's a problem in the command-line arguments
parseProxyback to summary
private void parseProxy(String text) throws BadCommandLineException
requireArgumentback to summary
public String requireArgument(String optionName, String[] args, int i) throws BadCommandLineException

Obtains an operand and reports an error if it's not there.

scanEpisodeFileback to summary
public void scanEpisodeFile(File jar) throws BadCommandLineException

Finds the META-INF/sun-jaxb.episode file to add as a binding customization.

setFieldRendererFactoryback to summary
public void setFieldRendererFactory(FieldRendererFactory frf, Plugin owner) throws BadCommandLineException

Sets the FieldRendererFactory.

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

Parameters
frf:FieldRendererFactory

The FieldRendererFactory to be installed. Must not be null.

owner:Plugin

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.

Exceptions
BadCommandLineException:
If a conflit happens, this exception carries a user-friendly error message, indicating a conflict.
setNameConverterback to summary
public void setNameConverter(NameConverter nc, Plugin owner) throws BadCommandLineException

Sets the NameConverter.

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

Parameters
nc:NameConverter

The NameConverter to be installed. Must not be null.

owner:Plugin

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.

Exceptions
BadCommandLineException:
If a conflit happens, this exception carries a user-friendly error message, indicating a conflict.
setSchemaLanguageback to summary
public void setSchemaLanguage(Language _schemaLanguage)