com.bowstreet.generation
Interface BuilderCall


public interface BuilderCall

This represents a call to a builder. One of these is created for each entry in the builder call list, and one is created whenever a builder calls another builder.


Nested Class Summary
static class BuilderCall.AssistedMessage
           
 
Field Summary
static java.lang.String RESERVEDINPUT_CATEGORY
          Reserved builder input for category
static java.lang.String RESERVEDINPUT_COMMENT
          Reserved builder input for comment
static java.lang.String RESERVEDINPUT_DEFAULTNAME
          Reserved builder input name for default builder call name
static java.lang.String RESERVEDINPUT_ENABLED
          Reserved builder input for enabling/disabling builder call
static java.lang.String RESERVEDINPUT_NAME
          Reserved builder input name for builder call name
static java.lang.String RESERVEDINPUT_PAGELOCATION
          Reserved builder input name for page location
static int SEVERITY_ERROR
          Error-level message
static int SEVERITY_WARNING
          Warning-level message
 
Method Summary
 void addMessage(int severity, java.lang.String message)
          Add error/warning.
 void addMessage(int severity, java.lang.String message, java.lang.String assistID)
          Add error/warning.
 void clearCacheData(java.lang.String keyStartsWith)
          Clear all the cached data for which the key starts with the string.
 void clearMessage(int severity)
          Clears error or warning messages.
 java.lang.String getBuilderCallID()
          Get the ID for this builder call.
 BuilderDef getBuilderDef()
          Get the BuilderDef for this builder call.
 BuilderInputs getBuilderInputs()
          Access builder inputs
 IXml getCacheData(java.lang.String key)
          Retrieve some cached data to speed generation.
 java.lang.String getCategory()
          Gets the Category builder input.
 java.lang.Object getClassInstance(java.lang.String builderDataEntryName)
          This will get a class instance for a GenHandler.
 java.lang.String getComment()
          Gets the Comment builder input.
 java.lang.Object getGenHandlerData()
          This allows the GenHandler to save a single Object in the BuilderCall.
 java.lang.String getMessage(int severity)
          Gets error or warning text.
 java.util.Collection getMessages(boolean assistedOnly)
          Gets all messages or all messages for which an assistID was created.
 java.lang.String getReadableName()
          Get a readable name (for display in Designer) for this BuilderCall.
 void setCacheData(java.lang.String key, IXml cacheData)
          Set some data to cache with builder to speed generation.
 void setGenHandlerData(java.lang.Object obj)
          This allows the GenHandler to save a single Object in the BuilderCall.
 void setPropertyResolver(com.bowstreet.generation.PropertyResolver propertyResolver)
          Sets the PropertyResolver on the BuilderCall.
 

Field Detail

RESERVEDINPUT_CATEGORY

static final java.lang.String RESERVEDINPUT_CATEGORY
Reserved builder input for category

See Also:
Constant Field Values

RESERVEDINPUT_COMMENT

static final java.lang.String RESERVEDINPUT_COMMENT
Reserved builder input for comment

See Also:
Constant Field Values

RESERVEDINPUT_DEFAULTNAME

static final java.lang.String RESERVEDINPUT_DEFAULTNAME
Reserved builder input name for default builder call name

See Also:
Constant Field Values

RESERVEDINPUT_ENABLED

static final java.lang.String RESERVEDINPUT_ENABLED
Reserved builder input for enabling/disabling builder call

See Also:
Constant Field Values

RESERVEDINPUT_NAME

static final java.lang.String RESERVEDINPUT_NAME
Reserved builder input name for builder call name

See Also:
Constant Field Values

RESERVEDINPUT_PAGELOCATION

static final java.lang.String RESERVEDINPUT_PAGELOCATION
Reserved builder input name for page location

See Also:
Constant Field Values

SEVERITY_ERROR

static final int SEVERITY_ERROR
Error-level message

See Also:
Constant Field Values

SEVERITY_WARNING

static final int SEVERITY_WARNING
Warning-level message

See Also:
Constant Field Values
Method Detail

addMessage

void addMessage(int severity,
                java.lang.String message)
Add error/warning. Note that these append to whatever message might already be there.

Parameters:
severity - Either SEVERITY_ERROR or SEVERITY_WARNING.
message - The error or warning text.
Example:
Set an error message indicating that a name is already in use:
   builderCall.addMessage(BuilderCall.SEVERITY_ERROR, "Specified name is already in use for a Variable: " + name);

addMessage

void addMessage(int severity,
                java.lang.String message,
                java.lang.String assistID)
Add error/warning. Note that these append to whatever message might already be there.

Parameters:
severity - Either SEVERITY_ERROR or SEVERITY_WARNING.
message - The error or warning text.
assistID - The id of some user assistance that can be displayed. Currently cheat sheet ID.
Example:
Set an error message indicating that a name is already in use:
   builderCall.addMessage(BuilderCall.SEVERITY_ERROR, "DataSource not found.", "EnableDataSource.Cheatsheet");

clearCacheData

void clearCacheData(java.lang.String keyStartsWith)
Clear all the cached data for which the key starts with the string. This should only be called if designTime is true!!!!

Parameters:
keyStartsWith - All keys that start with this prefix will be removed -- this should almost always be null when called from the Builder code.

clearMessage

void clearMessage(int severity)
Clears error or warning messages.

Parameters:
severity - Either SEVERITY_ERROR or SEVERITY_WARNING.

getBuilderCallID

java.lang.String getBuilderCallID()
Get the ID for this builder call.

Returns:
The identifier for this builder call in the builder call list.

getBuilderDef

BuilderDef getBuilderDef()
Get the BuilderDef for this builder call.

Returns:
The BuilderDef for this builder's bdef file.
Example:
This example gets some extra data defined in builder def file.
   // Assumes builder def file contains this entry under BuilderData:
   //        <BuilderDataEntry name="TemplateFileName">/test/sample.xml</BuilderDataEntry>
   BuilderDef bdef = builderCall.getBuilderDef();
   String filename = bdef.getBuilderDataString("TemplateFileName");

getBuilderInputs

BuilderInputs getBuilderInputs()
Access builder inputs

Returns:
All the builder inputs.
Example:
Get a builder input from a BuilderCall:
   String source = builderCall.getBuilderInputs().getString("SourceData", null);

getCacheData

IXml getCacheData(java.lang.String key)
Retrieve some cached data to speed generation. See setCacheData for example.

Parameters:
key - String which identifies the data
Returns:
XML that was cached at design time. Caller must check for null.

getCategory

java.lang.String getCategory()
Gets the Category builder input.

Returns:
The category this builder call is assigned to.

getClassInstance

java.lang.Object getClassInstance(java.lang.String builderDataEntryName)
This will get a class instance for a GenHandler. It will cache this object and give it back if, for example, the BuilderCall has deferred itself and you are running this again. It WILL check that the name is the same as the one you gave before, and it will one cache one value. This is intended for use by GenHandler code and should not be used by builder code.

Parameters:
builderDataEntryName - The name of the BuilderDataEntry inside the BuilderDef which contains the classname.
Returns:
an instance of that class.

getComment

java.lang.String getComment()
Gets the Comment builder input.

Returns:
The comment for this builder call, if any.

getGenHandlerData

java.lang.Object getGenHandlerData()
This allows the GenHandler to save a single Object in the BuilderCall. The value will always be null at the start of a Generation, but will be preserved through that Generation (if, for example, the BuilderCall defers itself). This is intended for use by GenHandler code and should not be used by builder code.

Returns:
The object that was stored with setGenHandlerData

getMessage

java.lang.String getMessage(int severity)
Gets error or warning text.

Parameters:
severity - Either SEVERITY_ERROR or SEVERITY_WARNING.
Returns:
The error or warning text.

getMessages

java.util.Collection getMessages(boolean assistedOnly)
Gets all messages or all messages for which an assistID was created. This will ALWAYS have all the errors first, then all the warnings.

Returns:
Collection of type AssistedMessage.

getReadableName

java.lang.String getReadableName()
Get a readable name (for display in Designer) for this BuilderCall. The default behavior is to return the contents of the "Name" builder input. If "Name" is not specified, may use DefaultName or elements in PageLocation.

Returns:
The name to display for this builder call.

setCacheData

void setCacheData(java.lang.String key,
                  IXml cacheData)
Set some data to cache with builder to speed generation.

Parameters:
key - String which identifies the data -- should embed the strings which caused you to create or use this particular data, so that you will not find it if a profile has changed one of your inputs!!
cacheData - XML data that can be retrieved in later regens. if null, will cause that cache key to be removed altogether.
Example:
This shows caching of parsed XML data.
  // Get XML builder input for variable data and create XML variable
  String xmlInput = builderInputs.getString("XMLSourceData", null);
  Variable xmlVariable = webApp.addVariable("sourceData", Variable.TYPE_XML);
  IXml parsedData = getCacheData(xmlInput);
  if (parsedData == null) {
      if (genContext.isDesignTime())
         builderCall.clearCacheData(null);
      try {
         parsedData = XmlUtil.parseXml(xmlInput);
      }
      catch (IOException e) {
         // should set error message here...
      }
      builderCall.setCacheData(xmlInput,parsedData);
  }
  xmlVariable.setValue(parsedData);   // set value in variable

setGenHandlerData

void setGenHandlerData(java.lang.Object obj)
This allows the GenHandler to save a single Object in the BuilderCall. The value will always be null at the start of a Generation, but will be preserved through that Generation (if, for example, the BuilderCall defers itself). This is intended for use by GenHandler code and should not be used by builder code.

Parameters:
obj - The object that will be returned by the next call to getGenHandlerData

setPropertyResolver

void setPropertyResolver(com.bowstreet.generation.PropertyResolver propertyResolver)
Sets the PropertyResolver on the BuilderCall. Used by BuilderInputs to resolve indirect property references.

Parameters:
propertyResolver - The PropertyResolver to set.


Copyright © 2009 IBM. All Rights Reserved.