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

public Class XJCBase

extends MatchingTask
Class Inheritance
Known Direct Subclasses
com.sun.tools.xjc.XJC2Task
Annotations
@SuppressWarnings:exports
Imports
org.apache.tools.ant.taskdefs.MatchingTask, .Execute, .LogStreamHandler, java.io.File, .IOException, .OutputStream, .PrintWriter, .StringWriter, java.lang.reflect.Constructor, java.net.MalformedURLException, .URL, java.util.*, com.sun.codemodel.CodeWriter, .JCodeModel, .JPackage, com.sun.codemodel.writer.FilterCodeWriter, com.sun.istack.tools.DefaultAuthenticator, com.sun.tools.xjc.model.Model, com.sun.tools.xjc.reader.Util, com.sun.tools.xjc.util.ForkEntityResolver, com.sun.tools.xjc.api.SpecVersion, org.glassfish.jaxb.core.v2.util.EditDistance, org.apache.tools.ant.AntClassLoader, .BuildException, .DirectoryScanner, .Project, org.apache.tools.ant.types.*, org.xml.sax.InputSource, .SAXParseException

Author
Yan GAO ([email protected])

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
XJCBase.AntProgressCodeWriter

CodeWriter that produces progress messages as Ant verbose messages.

private class
XJCBase.ErrorReceiverImpl

ErrorReceiver that produces messages as Ant messages.

Field Summary

Modifier and TypeField and Description
private String
private String
private String
private String
private final ArrayList<File>
private File
private final Path
classpath

Used to load additional user-specified classes.

private final CommandlineJava
private final Commandline
cmdLine

Additional command line arguments.

private final ArrayList<File>
dependsSet

Files used to determine whether XJC should run or not.

private boolean
private boolean
failonerror

False to continue the build even if the compilation fails.

private boolean
private String
private Path
public final Options
private String
private final ArrayList<File>
private boolean
producesSpecified

Set to true once the <produces> element is used.

private boolean
removeOldOutput

True if we will remove all the old output files before invoking XJC.

private final ArrayList<File>
private String
private long
stackSize

User-specified stack size.

private Path
private XMLCatalog
xmlCatalog

for resolving entities such as dtds

Inherited from org.apache.tools.ant.taskdefs.MatchingTask:
fileset

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
public void
addConfiguredBinding(FileSet fs)

Nested <binding> element.

public void
addConfiguredDepends(FileSet fs)

Nested <depends> element.

public void
addConfiguredProduces(FileSet fs)

Nested <produces> element.

public void
addConfiguredSchema(FileSet fs)

Nested <schema> element.

public void
addConfiguredXMLCatalog(XMLCatalog
the XMLCatalog instance to use to look up DTDs
xmlCatalog
)

Add the catalog to our internal catalog

pack-priv void
private void
addIndividualFilesTo(FileSet fs, List<File> lst)

Extracts File objects that the given FileSet represents and adds them all to the given List.

private long
computeTimestampFor(List<File> files, boolean findNewest)

Determines the timestamp of the newest/oldest file in the given set.

public Commandline.Argument
public Path
createClasspath()

Nested <classpath> element.

public Commandline.Argument
private void
public void
public String
public String
public String
public String
public File
pack-priv CommandlineJava
public File
public boolean
public String
public boolean
public boolean

Returns:

true if execution should be done in forked JVM, false otherwise.
getFork
()

Gets the "fork" flag.

public boolean
public boolean
private InputSource
getInputSource(File f)

Converts a File object to an InputSource.

private InputSource
getInputSource(URL url)

Converts an URL to an InputSource.

public String
public Path
public String
public String
public boolean
public boolean
public String
public Path
public boolean
private int

Returns:

return value from the executed process.
run
(String[]
arguments.
command
)

Executes the given class name with the given arguments in a separate VM.

public void
public void
public void
public void
public void
setBinding(String binding)

External binding file.

public void
setCatalog(File catalog)

Adds a new catalog file.

public void
setClasspath(Path cp)

Nested <classpath> element.

public void
public void
setDestdir(File dir)

Sets the directory to produce generated source files.

public void
setDisableXmlSecurity(boolean flg)

Controls whether to disable XML security features when parsing XML documents or not

public void
setEncoding(String encoding)

public void
setExtension(boolean flg)

Controls whether the compiler will run in the strict conformance mode (flg=false) or the extension mode (flg=true)

public void
setFailonerror(boolean value)

Mostly for our SQE teams and not to be advertized.

public void
setFork(boolean
true to run execution in a forked JVM.
fork
)

Sets the "fork" flag.

public void
setHeader(boolean flg)

Controls whether the file header comment is generated or not.

public void
setHeaderWithDate(boolean flg)

Controls whether the file header comment should generate timestamp generation or not.

public void
setLanguage(String language)

Sets the schema language.

public void
public void
public void
setPackage(String pkg)

Sets the package name of the generated code.

public void
public void
setReadonly(boolean flg)

Controls whether files should be generated in read-only mode or not

public void
setRemoveOldOutput(boolean roo)

"removeOldOutput" attribute.

public void
setSchema(String
A file name (can be relative to base dir), or an URL (must be absolute).
schema
)

Parses the schema attribute.

public void
setStackSize(String ss)
Deprecated not much need for JAXB2, as we now use much less stack.

Sets the stack size of the XJC invocation.

public void
setTarget(String version)

Sets the target version of the compilation

protected CommandlineJava

Returns:

ready to run command line
setupCommand
()

Set up command line to invoke.

pack-priv void
public void
public void
private InputSource[]
toInputSources(FileSet fs)

Extracts files in the given FileSet.

Inherited from org.apache.tools.ant.taskdefs.MatchingTask:
addaddAndaddContainsaddContainsRegexpaddCustomaddDateaddDependaddDepthaddDifferentaddFilenameaddMajorityaddModifiedaddNoneaddNotaddOraddPresentaddSelectoraddSizeaddTypeappendSelectorcreateExcludecreateExcludesFilecreateIncludecreateIncludesFilecreatePatternSetgetDirectoryScannergetImplicitFileSetgetSelectorshasSelectorsselectorCountselectorElementssetCaseSensitivesetDefaultexcludessetExcludessetExcludesfilesetFollowSymlinkssetIncludessetIncludesfilesetProjectXsetIgnoreXsetItems

Field Detail

addexportsback to summary
private String addexports
addmodulesback to summary
private String addmodules
addopensback to summary
private String addopens
addreadsback to summary
private String addreads
bindingFilesback to summary
private final ArrayList<File> bindingFiles
catalogback to summary
private File catalog
classpathback to summary
private final Path classpath

Used to load additional user-specified classes.

cmdback to summary
private final CommandlineJava cmd
cmdLineback to summary
private final Commandline cmdLine

Additional command line arguments.

dependsSetback to summary
private final ArrayList<File> dependsSet

Files used to determine whether XJC should run or not.

extensionback to summary
private boolean extension
failonerrorback to summary
private boolean failonerror

False to continue the build even if the compilation fails.

forkback to summary
private boolean fork
limitmodulesback to summary
private String limitmodules
modulepathback to summary
private Path modulepath
optionsback to summary
public final Options options
patchmoduleback to summary
private String patchmodule
producesSetback to summary
private final ArrayList<File> producesSet
producesSpecifiedback to summary
private boolean producesSpecified

Set to true once the <produces> element is used. This flag is used to issue a suggestion to users.

removeOldOutputback to summary
private boolean removeOldOutput

True if we will remove all the old output files before invoking XJC.

schemaFilesback to summary
private final ArrayList<File> schemaFiles
specTargetback to summary
private String specTarget
stackSizeback to summary
private long stackSize

User-specified stack size.

upgrademodulepathback to summary
private Path upgrademodulepath
xmlCatalogback to summary
private XMLCatalog xmlCatalog

for resolving entities such as dtds

Constructor Detail

XJCBaseback to summary
public XJCBase()

Method Detail

_doXJCback to summary
private void _doXJC() throws BuildException
addConfiguredBindingback to summary
public void addConfiguredBinding(FileSet fs)

Nested <binding> element.

addConfiguredDependsback to summary
public void addConfiguredDepends(FileSet fs)

Nested <depends> element.

addConfiguredProducesback to summary
public void addConfiguredProduces(FileSet fs)

Nested <produces> element.

addConfiguredSchemaback to summary
public void addConfiguredSchema(FileSet fs)

Nested <schema> element.

addConfiguredXMLCatalogback to summary
public void addConfiguredXMLCatalog(XMLCatalog xmlCatalog)

Add the catalog to our internal catalog

Parameters
xmlCatalog:XMLCatalog

the XMLCatalog instance to use to look up DTDs

addFilesToCommandLineback to summary
pack-priv void addFilesToCommandLine(ArrayList<File> files, String option)
addIndividualFilesToback to summary
private void addIndividualFilesTo(FileSet fs, List<File> lst)

Extracts File objects that the given FileSet represents and adds them all to the given List.

computeTimestampForback to summary
private long computeTimestampFor(List<File> files, boolean findNewest)

Determines the timestamp of the newest/oldest file in the given set.

createArgback to summary
public Commandline.Argument createArg()
createClasspathback to summary
public Path createClasspath()

Nested <classpath> element.

createJvmargback to summary
public Commandline.Argument createJvmarg()
doXJCback to summary
private void doXJC() throws BuildException
executeback to summary
public void execute() throws BuildException

Overrides org.apache.tools.ant.Task.execute.

Runs XJC.

Annotations
@Override
Exceptions
BuildException:

Doc from org.apache.tools.ant.Task.execute.

if something goes wrong with the build.

getAddexportsback to summary
public String getAddexports()
getAddmodulesback to summary
public String getAddmodules()
getAddopensback to summary
public String getAddopens()
getAddreadsback to summary
public String getAddreads()
getCatalogback to summary
public File getCatalog()
getCommandlineback to summary
pack-priv CommandlineJava getCommandline()
getDestdirback to summary
public File getDestdir()
getDisableXmlSecurityback to summary
public boolean getDisableXmlSecurity()
getEncodingback to summary
public String getEncoding()
getExtensionback to summary
public boolean getExtension()
getForkback to summary
public boolean getFork()

Gets the "fork" flag.

Returns:boolean

true if execution should be done in forked JVM, false otherwise.

getHeaderback to summary
public boolean getHeader()
getHeaderWithDateback to summary
public boolean getHeaderWithDate()
getInputSourceback to summary
private InputSource getInputSource(File f)

Converts a File object to an InputSource.

getInputSourceback to summary
private InputSource getInputSource(URL url)

Converts an URL to an InputSource.

getLimitmodulesback to summary
public String getLimitmodules()
getModulepathback to summary
public Path getModulepath()
getPackageback to summary
public String getPackage()
getPatchmoduleback to summary
public String getPatchmodule()
getReadOnlyback to summary
public boolean getReadOnly()
getRemoveOldOutputback to summary
public boolean getRemoveOldOutput()
getSpecTargetback to summary
public String getSpecTarget()
getUpgrademodulepathback to summary
public Path getUpgrademodulepath()
getVerboseback to summary
public boolean getVerbose()
runback to summary
private int run(String[] command) throws BuildException

Executes the given class name with the given arguments in a separate VM.

Parameters
command:String[]

arguments.

Returns:int

return value from the executed process.

setAddexportsback to summary
public void setAddexports(String aes)
setAddmodulesback to summary
public void setAddmodules(String ams)
setAddopensback to summary
public void setAddopens(String aos)
setAddreadsback to summary
public void setAddreads(String ars)
setBindingback to summary
public void setBinding(String binding)

External binding file.

setCatalogback to summary
public void setCatalog(File catalog)

Adds a new catalog file.

setClasspathback to summary
public void setClasspath(Path cp)

Nested <classpath> element.

setClasspathRefback to summary
public void setClasspathRef(Reference r)
setDestdirback to summary
public void setDestdir(File dir)

Sets the directory to produce generated source files.

setDisableXmlSecurityback to summary
public void setDisableXmlSecurity(boolean flg)

Controls whether to disable XML security features when parsing XML documents or not

setEncodingback to summary
public void setEncoding(String encoding)
setExtensionback to summary
public void setExtension(boolean flg)

Controls whether the compiler will run in the strict conformance mode (flg=false) or the extension mode (flg=true)

setFailonerrorback to summary
public void setFailonerror(boolean value)

Mostly for our SQE teams and not to be advertized.

setForkback to summary
public void setFork(boolean fork)

Sets the "fork" flag.

Parameters
fork:boolean

true to run execution in a forked JVM.

setHeaderback to summary
public void setHeader(boolean flg)

Controls whether the file header comment is generated or not.

setHeaderWithDateback to summary
public void setHeaderWithDate(boolean flg)

Controls whether the file header comment should generate timestamp generation or not.

setLanguageback to summary
public void setLanguage(String language)

Sets the schema language.

setLimitmodulesback to summary
public void setLimitmodules(String lms)
setModulepathback to summary
public void setModulepath(Path mp)
setPackageback to summary
public void setPackage(String pkg)

Sets the package name of the generated code.

setPatchmoduleback to summary
public void setPatchmodule(String pms)
setReadonlyback to summary
public void setReadonly(boolean flg)

Controls whether files should be generated in read-only mode or not

setRemoveOldOutputback to summary
public void setRemoveOldOutput(boolean roo)

"removeOldOutput" attribute.

setSchemaback to summary
public void setSchema(String schema)

Parses the schema attribute. This attribute will be used when there is only one schema.

Parameters
schema:String

A file name (can be relative to base dir), or an URL (must be absolute).

setStackSizeback to summary
public void setStackSize(String ss)

Deprecated

not much need for JAXB2, as we now use much less stack.

Sets the stack size of the XJC invocation.

Annotations
@Deprecated
setTargetback to summary
public void setTarget(String version)

Sets the target version of the compilation

setupCommandback to summary
protected CommandlineJava setupCommand()

Set up command line to invoke.

Returns:CommandlineJava

ready to run command line

setupForkCommandback to summary
pack-priv void setupForkCommand(String className)
setUpgrademodulepathback to summary
public void setUpgrademodulepath(Path ump)
setXexplicitAnnotationback to summary
public void setXexplicitAnnotation(boolean flg)
See Also
Options#runtime14
toInputSourcesback to summary
private InputSource[] toInputSources(FileSet fs)

Extracts files in the given FileSet.

com.sun.tools.xjc back to summary

private Class XJCBase.AntProgressCodeWriter

extends FilterCodeWriter
Class Inheritance

CodeWriter that produces progress messages as Ant verbose messages.

Field Summary

Inherited from com.sun.codemodel.writer.FilterCodeWriter:
core

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public OutputStream
openBinary(JPackage pkg, String fileName)

Overrides com.sun.codemodel.writer.FilterCodeWriter.openBinary.

Called by CodeModel to store the specified file.

Inherited from com.sun.codemodel.writer.FilterCodeWriter:
closeopenSource

Constructor Detail

AntProgressCodeWriterback to summary
public AntProgressCodeWriter(CodeWriter output)

Method Detail

openBinaryback to summary
public OutputStream openBinary(JPackage pkg, String fileName) throws IOException

Overrides com.sun.codemodel.writer.FilterCodeWriter.openBinary.

Doc from com.sun.codemodel.CodeWriter.openBinary.

Called by CodeModel to store the specified file. The callee must allocate a storage to store the specified file.

The returned stream will be closed before the next file is stored. So the callee can assume that only one OutputStream is active at any given time.

Annotations
@Override
com.sun.tools.xjc back to summary

private Class XJCBase.ErrorReceiverImpl

extends ErrorReceiver
Class Inheritance

ErrorReceiver that produces messages as Ant messages.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
info(SAXParseException e)

Implements abstract com.sun.tools.xjc.ErrorReceiver.info.

Implements com.sun.tools.xjc.api.ErrorListener.info.

Reports verbose messages to users.

private void
print(int logLevel, String header, SAXParseException e)

public void
Inherited from com.sun.tools.xjc.ErrorReceiver:
debugerrorerrorerrorerrorgetLocationStringpollAbortwarning

Constructor Detail

ErrorReceiverImplback to summary
private ErrorReceiverImpl()

Method Detail

errorback to summary
public void error(SAXParseException e)

Implements abstract com.sun.tools.xjc.ErrorReceiver.error.

Implements org.xml.sax.ErrorHandler.error, com.sun.tools.xjc.api.ErrorListener.error.

Doc from org.xml.sax.ErrorHandler.error.

Receive notification of a recoverable error.

This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The default behaviour is to take no action.

The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end. If the application cannot do so, then the parser should report a fatal error even if the XML recommendation does not require it to do so.

Filters may use this method to report other, non-XML errors as well.

Annotations
@Override
fatalErrorback to summary
public void fatalError(SAXParseException e)

Implements abstract com.sun.tools.xjc.ErrorReceiver.fatalError.

Implements org.xml.sax.ErrorHandler.fatalError, com.sun.tools.xjc.api.ErrorListener.fatalError.

Doc from org.xml.sax.ErrorHandler.fatalError.

Receive notification of a non-recoverable, fatal error.

As defined in section 1.2 of the W3C XML 1.0 Recommendation, fatal errors are those that would make it impossible for a parser to continue normal processing. These include violation of a well-formedness constraint, invalid encoding, and forbidden structural errors as described in the W3C XML 1.0 Recommendation.

Annotations
@Override
infoback to summary
public void info(SAXParseException e)

Implements abstract com.sun.tools.xjc.ErrorReceiver.info.

Implements com.sun.tools.xjc.api.ErrorListener.info.

Doc from com.sun.tools.xjc.ErrorReceiver.info.

Reports verbose messages to users. This method can be used to report additional non-essential messages. The implementation usually discards them unless some specific debug option is turned on.

Annotations
@Override
printback to summary
private void print(int logLevel, String header, SAXParseException e)
warningback to summary
public void warning(SAXParseException e)

Implements abstract com.sun.tools.xjc.ErrorReceiver.warning.

Implements org.xml.sax.ErrorHandler.warning, com.sun.tools.xjc.api.ErrorListener.warning.

Doc from org.xml.sax.ErrorHandler.warning.

Receive notification of a warning.

SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML recommendation. The default behaviour is to take no action.

The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application to process the document through to the end.

Filters may use this method to report other, non-XML warnings as well.

Annotations
@Override