Class Options


  • public class Options
    extends java.lang.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

      Fields 
      Modifier and Type Field Description
      java.util.List<Plugin> activePlugins
      Plugins that are enabled in this compilation.
      boolean automaticNameConflictResolution
      If true, try to resolve name conflicts automatically by assigning mechanical numbers.
      ClassNameAllocator classNameAllocator
      This allocator has the final say on deciding the class name.
      java.util.List<java.net.URL> classpaths  
      int compatibilityMode
      this switch determines how carefully the compiler will follow the compatibility rules in the spec.
      boolean contentForWildcard
      When on, generates content property for types with multiple xs:any derived elements (which is supposed to be correct behaviour)
      boolean debugMode
      If "-debug" is specified.
      java.lang.String defaultPackage
      The -p option that should control the default Java package that will contain the generated code.
      java.lang.String defaultPackage2
      Similar to the -p option, but this one works with a lower priority, and customizations overrides this.
      boolean disableXmlSecurity
      If true XML security features when parsing XML documents will be disabled.
      boolean enableIntrospection
      When on, fixes getter/setter generation to match the Bean Introspection API
      java.lang.String encoding
      Encoding to be used by generated java sources, null for platform default.
      org.xml.sax.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.
      static int EXTENSION
      loosely follow the compatibility rules and allow the use of vendor binding extensions
      boolean noFileHeader
      No file header comment (to be more friendly with diff.)
      boolean packageLevelAnnotations
      This switch controls whether or not xjc will generate package level annotations
      java.util.Set<java.lang.String> pluginURIs
      Set of URIs that plug-ins recognize as extension bindings.
      java.lang.String proxyAuth  
      boolean quiet
      If the "-quiet" option is specified.
      boolean readOnly
      If the -readOnly option is specified.
      boolean runtime14
      If -explicit-annotation option is specified.
      static int STRICT
      strictly follow the compatibility rules and reject schemas that contain features from App.
      boolean strictCheck
      Check the source schemas with extra scrutiny.
      SpecVersion target
      Generates output for the specified version of the runtime.
      java.io.File targetDir
      Target directory when producing files.
      boolean verbose
      If the "-verbose" option is specified.
    • Constructor Summary

      Constructors 
      Constructor Description
      Options()  
    • Field Detail

      • debugMode

        public boolean debugMode
        If "-debug" is specified.
      • verbose

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

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

        public boolean readOnly
        If the -readOnly option is specified.
      • noFileHeader

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

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

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

        public java.lang.String encoding
        Encoding to be used by generated java sources, null for platform default.
      • disableXmlSecurity

        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
      • strictCheck

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

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

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

      • automaticNameConflictResolution

        public boolean automaticNameConflictResolution
        If true, try to resolve name conflicts automatically by assigning mechanical numbers.
      • 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
        See Also:
        Constant Field Values
      • EXTENSION

        public static final int EXTENSION
        loosely follow the compatibility rules and allow the use of vendor binding extensions
        See Also:
        Constant Field Values
      • compatibilityMode

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

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

        public java.io.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).

      • entityResolver

        public org.xml.sax.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.
      • defaultPackage

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

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

        public java.lang.String proxyAuth
      • activePlugins

        public final java.util.List<Plugin> activePlugins
        Plugins that are enabled in this compilation.
      • pluginURIs

        public final java.util.Set<java.lang.String> pluginURIs
        Set of URIs that plug-ins recognize as extension bindings.
      • classNameAllocator

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

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

        public final java.util.List<java.net.URL> classpaths
    • Constructor Detail

      • Options

        public Options()
    • Method Detail

      • isExtensionMode

        public boolean isExtensionMode()
      • 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.
      • getAllPlugins

        public java.util.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.

        Returns:
      • getSchemaLanguage

        public Language getSchemaLanguage()
      • setSchemaLanguage

        public void setSchemaLanguage​(Language _schemaLanguage)
      • getGrammars

        public org.xml.sax.InputSource[] getGrammars()
        Input schema files.
        Returns:
      • addGrammar

        public void addGrammar​(org.xml.sax.InputSource is)
        Adds a new input schema.
        Parameters:
        is -
      • addGrammar

        public void addGrammar​(java.io.File source)
      • addGrammarRecursive

        public void addGrammarRecursive​(java.io.File dir)
        Recursively scan directories and add all XSD files in it.
        Parameters:
        dir -
      • getBindFiles

        public org.xml.sax.InputSource[] getBindFiles()
        Input external binding files.
        Returns:
      • addBindFile

        public void addBindFile​(org.xml.sax.InputSource is)
        Adds a new binding file.
        Parameters:
        is -
      • addBindFile

        public void addBindFile​(java.io.File bindFile)
        Adds a new binding file.
        Parameters:
        bindFile -
      • addBindFileRecursive

        public void addBindFileRecursive​(java.io.File dir)
        Recursively scan directories and add all ".xjb" files in it.
        Parameters:
        dir -
      • getUserClassLoader

        public java.lang.ClassLoader getUserClassLoader​(java.lang.ClassLoader parent)
        Gets a classLoader that can load classes specified via the -classpath option.
        Parameters:
        parent -
        Returns:
      • getModuleName

        public java.lang.String getModuleName()
        Gets Java module name option.
        Returns:
        Java module name option or null if this option was not set.
      • parseArgument

        public int parseArgument​(java.lang.String[] args,
                                 int i)
                          throws BadCommandLineException
        Parses an option args[i] and return the number of tokens consumed.
        Parameters:
        args -
        i -
        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.
      • requireArgument

        public java.lang.String requireArgument​(java.lang.String optionName,
                                                java.lang.String[] args,
                                                int i)
                                         throws BadCommandLineException
        Obtains an operand and reports an error if it's not there.
        Parameters:
        optionName -
        args -
        i -
        Returns:
        Throws:
        BadCommandLineException
      • addCatalog

        public void addCatalog​(java.io.File catalogFile)
                        throws java.io.IOException
        Adds a new catalog file.Use created or existed resolver to parse new catalog file.
        Parameters:
        catalogFile -
        Throws:
        java.io.IOException
      • parseArguments

        public void parseArguments​(java.lang.String[] args)
                            throws BadCommandLineException
        Parses arguments and fill fields of this object.
        Parameters:
        args -
        Throws:
        BadCommandLineException - thrown when there's a problem in the command-line arguments
      • guessSchemaLanguage

        public Language guessSchemaLanguage()
        Guesses the schema language.
        Returns:
      • createCodeWriter

        public CodeWriter createCodeWriter()
                                    throws java.io.IOException
        Creates a configured CodeWriter that produces files into the specified directory.
        Returns:
        Throws:
        java.io.IOException
      • createCodeWriter

        public CodeWriter createCodeWriter​(CodeWriter core)
        Creates a configured CodeWriter that produces files into the specified directory.
        Parameters:
        core -
        Returns:
      • getPrologComment

        public java.lang.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..."
        Returns:
      • getBuildID

        public static java.lang.String getBuildID()
      • normalizeSystemId

        public static java.lang.String normalizeSystemId​(java.lang.String systemId)