org.exolab.castor.builder

Class SGStateInfo

Implemented Interfaces:
ClassInfoResolver

public final class SGStateInfo
extends ClassInfoResolverImpl

A class for maintaining state for the SourceGenerator.
Version:
$Revision: 6936 $ $Date: 2005-06-22 22:13:21 -0600 (Wed, 22 Jun 2005) $
Author:
Keith Visco

Field Summary

static int
NORMAL_STATUS
The SourceGenerator is still generating source.
static int
STOP_STATUS
The SourceGenerator has been stopped by an error or by the user.

Constructor Summary

SGStateInfo(Schema schema, SourceGenerator sgen)
Creates a new SGStateInfo.

Method Summary

void
bindSourceCode(Annotated annotated, JClass[] classes)
Binds the given Annotated structure with its generated source classes.
Properties
getCDRFile(String filename)
Returns the CDRFile (Properties file) associated with the given filename.
Enumeration
getCDRFilenames()
Returns the set of CDR file names.
FactoryState
getCurrentFactoryState()
Returns the current FactoryState that holds information about the classes being generated.
Dialog
getDialog()
Returns the Dialog used for interacting with the user.
JClass
getImportedSourceCode(String className)
Returns the JClass with the given name or null if no bindings have been specified for a JClass with the name.
Map
getImportedSourcesByName()
Returns the sources as generated through XML schema imports.
MappingRoot
getMapping(String filename)
Returns the Mapping file associated with the given filename.
Enumeration
getMappingFilenames()
Returns the set of mapping filenames.
String
getPackageName()
Get package used when creating new classes.
(package private) JClass
getProcessed(String className)
Returns the processed JClass with the given name.
(package private) Schema
getSchema()
Returns a reference to the schema for which we are generating source.
JClass
getSourceCode(String className)
Returns the JClass with the given name or null if no bindings have been specified for a JClass with the name.
JClass[]
getSourceCode(Annotated annotated)
Returns the array of JClass for the given Annotated structure or null if no bindings have been specified for the given Structure.
SourceGenerator
getSourceGenerator()
Returns the SourceGenerator instance being used.
Map
getSourcesByName()
Returns the sources as generated through XML schema imports.
int
getStatusCode()
Returns the current status.
boolean
getSuppressNonFatalWarnings()
Returns true if non-fatal warnings should be suppressed.
(package private) void
markAsProcessed(JClass jClass)
Marks the given JClass as having been processed.
(package private) boolean
processed(String className)
Returns true if a JClass with the given name has been marked as processed.
(package private) boolean
processed(JClass jClass)
Returns true if the given JClass has been marked as processed.
(package private) boolean
promptForOverwrite()
Returns true if existing source files should be prompted before being overwritten.
void
setCDRFile(String filename, Properties props)
Sets the CDR (ClassDescriptorResolver) file associated with the given filename.
void
setCurrentFactoryState(FactoryState state)
Sets the current FactoryState.
(package private) void
setDialog(Dialog dialog)
Sets the Dialog used for interacting with the user.
void
setMapping(String filename, MappingRoot mapping)
Sets the Mapping file associated with the given filename.
protected void
setPackageName(String packageName)
Set package used when creating new classes.
(package private) void
setPromptForOverwrite(boolean promptForOverwrite)
Sets whether or not existing source files should be silently overwritten or whether the user should be prompted first.
void
setStatusCode(int status)
Sets the current status code to the given one.
(package private) void
setSuppressNonFatalWarnings(boolean suppressNonFatalWarnings)
Sets whether non-fatal warnings should be supporessed.
(package private) void
setVerbose(boolean verbose)
Sets whether or not the source code generator prints additional messages during generating source code.
void
storeImportedSourcesByName(Map importedSourcesByName)
Stores generated sources as processed within an imported schema.
boolean
verbose()
Returns the value of the verbose flag.

Methods inherited from class org.exolab.castor.builder.util.ClassInfoResolverImpl

bindReference, keys, resolve

Field Details

NORMAL_STATUS

public static final int NORMAL_STATUS
The SourceGenerator is still generating source.
Field Value:
0

STOP_STATUS

public static final int STOP_STATUS
The SourceGenerator has been stopped by an error or by the user.
Field Value:
1

Constructor Details

SGStateInfo

protected SGStateInfo(Schema schema,
                      SourceGenerator sgen)
Creates a new SGStateInfo.
Parameters:
schema - the Schema to generate source for
sgen - the SourceGenerator instance

Method Details

bindSourceCode

public void bindSourceCode(Annotated annotated,
                           JClass[] classes)
Binds the given Annotated structure with its generated source classes.
Parameters:
annotated - the Annotated structure to add JClass bindings for
classes - the JClass[] to bind

getCDRFile

public Properties getCDRFile(String filename)
Returns the CDRFile (Properties file) associated with the given filename.
Parameters:
filename - filename of the CDR file to be processed
Returns:
the Properties file.

getCDRFilenames

public Enumeration getCDRFilenames()
Returns the set of CDR file names.
Returns:
the set of CDR file names.

getCurrentFactoryState

public FactoryState getCurrentFactoryState()
Returns the current FactoryState that holds information about the classes being generated.
Returns:
the current FactoryState

getDialog

public Dialog getDialog()
Returns the Dialog used for interacting with the user.
Returns:
the Dialog, or null if none has been set.

getImportedSourceCode

public JClass getImportedSourceCode(String className)
Returns the JClass with the given name or null if no bindings have been specified for a JClass with the name. This method consults with JClass instances imported through a Schema import only.
Parameters:
className - the name of the JClass
Returns:
the (imported) JClass if found

getImportedSourcesByName

public Map getImportedSourcesByName()
Returns the sources as generated through XML schema imports.
Returns:
the sources as generated through XML schema imports.

getMapping

public MappingRoot getMapping(String filename)
Returns the Mapping file associated with the given filename.
Parameters:
filename - The filename to search for a Mapping File association
Returns:
the Mapping file.

getMappingFilenames

public Enumeration getMappingFilenames()
Returns the set of mapping filenames.
Returns:
the set of mapping filenames.

getPackageName

public String getPackageName()
Get package used when creating new classes.
Returns:
Package used when creating new classes.

getProcessed

(package private)  JClass getProcessed(String className)
Returns the processed JClass with the given name. If no such JClass has been marked as processed, null is returned.
Parameters:
className - the JClass name to check against
Returns:
the JClass with the given name

getSchema

(package private)  Schema getSchema()
Returns a reference to the schema for which we are generating source.
Returns:
a reference to the schema for which we are generating source.

getSourceCode

public JClass getSourceCode(String className)
Returns the JClass with the given name or null if no bindings have been specified for a JClass with the name.
Parameters:
className - the name of the JClass
Returns:
the JClass if found

getSourceCode

public JClass[] getSourceCode(Annotated annotated)
Returns the array of JClass for the given Annotated structure or null if no bindings have been specified for the given Structure.
Parameters:
annotated - the Annotated structure to search
Returns:
the JClass array

getSourceGenerator

public SourceGenerator getSourceGenerator()
Returns the SourceGenerator instance being used.
Returns:
the SourceGenerator instance being used.

getSourcesByName

public Map getSourcesByName()
Returns the sources as generated through XML schema imports.
Returns:
the sources as generated through XML schema imports.

getStatusCode

public int getStatusCode()
Returns the current status.
Returns:
the current status.

getSuppressNonFatalWarnings

public boolean getSuppressNonFatalWarnings()
Returns true if non-fatal warnings should be suppressed.
Returns:
true if non-fatal warnings should be suppressed.

markAsProcessed

(package private)  void markAsProcessed(JClass jClass)
Marks the given JClass as having been processed.
Parameters:
jClass - the JClass to mark as having been processed.

processed

(package private)  boolean processed(String className)
Returns true if a JClass with the given name has been marked as processed.
Parameters:
className - the JClass name to check against
Returns:
true if a JClass with the given name has been marked as processed

processed

(package private)  boolean processed(JClass jClass)
Returns true if the given JClass has been marked as processed.
Parameters:
jClass - the JClass to check for being marked as processed
Returns:
true if the given JClass has been marked as processed.

promptForOverwrite

(package private)  boolean promptForOverwrite()
Returns true if existing source files should be prompted before being overwritten.
Returns:
true if existing source files should be prompted before being overwritten

setCDRFile

public void setCDRFile(String filename,
                       Properties props)
Sets the CDR (ClassDescriptorResolver) file associated with the given filename.
Parameters:
filename - the filename associated with the CDR file
props - the Properties file

setCurrentFactoryState

public void setCurrentFactoryState(FactoryState state)
Sets the current FactoryState.
Parameters:
state - the current FactoryState

setDialog

(package private)  void setDialog(Dialog dialog)
Sets the Dialog used for interacting with the user.
Parameters:
dialog - the Dialog to use

setMapping

public void setMapping(String filename,
                       MappingRoot mapping)
Sets the Mapping file associated with the given filename.
Parameters:
filename - the filename associated with the Mapping
mapping - the MappingRoot

setPackageName

protected void setPackageName(String packageName)
Set package used when creating new classes.
Parameters:
packageName - Package used when creating new classes.

setPromptForOverwrite

(package private)  void setPromptForOverwrite(boolean promptForOverwrite)
Sets whether or not existing source files should be silently overwritten or whether the user should be prompted first.
Parameters:
promptForOverwrite - true if existing files should not be silently overwritten.

setStatusCode

public void setStatusCode(int status)
Sets the current status code to the given one.
Parameters:
status - the new status code

setSuppressNonFatalWarnings

(package private)  void setSuppressNonFatalWarnings(boolean suppressNonFatalWarnings)
Sets whether non-fatal warnings should be supporessed.
Parameters:
suppressNonFatalWarnings - true if non-fatal warnings should be supporessed

setVerbose

(package private)  void setVerbose(boolean verbose)
Sets whether or not the source code generator prints additional messages during generating source code.
Parameters:
verbose - a boolean, when true indicates to print additional messages

storeImportedSourcesByName

public void storeImportedSourcesByName(Map importedSourcesByName)
Stores generated sources as processed within an imported schema.
Parameters:
importedSourcesByName - Generated sources as processed within an imported schema.

verbose

public boolean verbose()
Returns the value of the verbose flag. A true value indicates that additional messages may be printed during processing.
Returns:
the value of the verbose flag.

Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com