com.pega.pegarules.pub.generator
Interface FirstUseAssembler

All Known Subinterfaces:
IAssemblyStreamSupport

public interface FirstUseAssembler

The FirstUseAssembler interface defines a toolkit for use by implementations of the JavaGenerator interface. A distinct instance of FirstUseAssembler is associated with each instance of JavaGenerator when it is instantiated. This instance provides the information needed to drive the Java generation, support facilities to standardize and simplify some common processing, and a repository to receive the resulting generated code.

Code buffers

Throughout its processing, First-Use Assembly makes two code buffers available to the Java generation. The general flow-of-control processing being implemented should be added to the primary code buffer, accessed using the addCode methods. The support code buffer, accessed using the addToSupport methods, is for complete Java declarations -- methods, inner classes, class and instance variables -- used to facilitate the direct processing added to the primary code buffer.

Rule lists

During the course of generating a rule, the FirstUseAssembler maintains two lists of rules. The first is the list of rule dependencies. When a Java implementation is generated for a rule, PegaRULES remembers the list of rule dependencies for that rule. Whenever any rule on that list changes, the generated rule is invalidated.

The second list is the list of used rules. This list contains the keys and update date/time of every rule which is used to generate a rule. This list is used to help PegaRULES determine whether users with different ruleset lists can share the same Java implementation of a rule.

Most often, these two lists contain the same rules. A rule is usually added to one or both of these lists with the noteInstanceUsed(com.pega.pegarules.pub.util.StringMap, com.pega.pegarules.pub.generator.PageDescriptor) method, though other methods might also add rules to the lists.

Version:
$Revision: 32285 $ $Date: 2012-08-01 12:12:42 -0400 (Wed, 01 Aug 2012) $
Author:
John van der Meer

Field Summary
static java.lang.String COPYRIGHT
           
static java.lang.String VERSION
           
 
Method Summary
 void addCode(ExpressionMap aKeys)
          Deprecated. this method may be used only if the rule in question has a single aspect defined. It it has more than one, then an error will occur. Use addCode(ExpressionMap, String) instead.
 void addCode(ExpressionMap aKeys, java.lang.String aAspect)
          Adds execution of the specified Rule- reference for the specified aspect to the primary code buffer.
 void addCode(ExpressionMap aKeys, java.lang.String aAspect, PageDescriptor aPageDesc)
          Adds execution of the specified Rule- reference for the specified aspect to the primary code buffer.
 java.lang.StringBuffer addCode(java.lang.String aCode)
          Adds specified code fragment to primary buffer.
 boolean addErrorMessages(ClipboardProperty aProp, CodeGenerator aGenCode)
          Checks for error messages in aGenCode and adds them to aProp
 void addImport(java.lang.String aImport)
          Add to the set of import statements required for the generated Java.
 void addKnownPageDescriptor(java.lang.String aPageName, java.lang.String aClassName)
          Add a page to the "known page" list so that subsequent processing will be able to identify the class of a page created by Page-New, Obj-Open, etc.
 void addToSupport(ExpressionMap aKeys)
          Deprecated. this method may be used only if the rule in question has a single aspect defined. It it has more than one, then an error will occur. Use addToSupport(ExpressionMap, String) instead.
 void addToSupport(ExpressionMap aKeys, java.lang.String aAspect)
          Adds execution of the specified Rule- reference for the specified aspect to the support code buffer.
 java.lang.StringBuffer addToSupport(java.lang.String aCode)
          Adds specified code fragment to support-code buffer.
 boolean checkModelInstance(java.lang.String aStepPPageClass, java.lang.String aPPageClass, java.lang.String aModelName, ClipboardProperty aModelRef)
          Validates that the specified model exists and is accessible to the user's context.
 boolean checkWhenInstance(java.lang.String aStepPPageClass, java.lang.String aPPageClass, java.lang.String aWhenName, ClipboardProperty aWhenRef)
          Validates that the specified when block exists and is accessible to the user's context.
 IGeneratedMethod createMethod(java.lang.String aProposedName, boolean aCaptureAddCode)
          Begin construction of a generated method.
 IGeneratedMethod createMethod(java.lang.String aProposedName, boolean aCaptureAddCode, java.lang.String aInsKey)
          Begin construction of a generated method.
 PageDescriptor createPageDescriptor(java.lang.String aPageName, java.lang.String aClassName, boolean aIsExact, boolean aIsParameter)
          Create a PageDescriptor.
 PageDescriptor createPageDescriptor(java.lang.String aPageName, java.lang.String aClassName, boolean aIsExact, boolean aIsParameter, boolean aIsPrimaryPageForAssembly)
          Create a PageDescriptor.
 ICodeBuffer decreaseIndent()
          Decreases the indentation level by one.
 ICodeBuffer emit(java.lang.String aContent)
          Adds specified content fragment to primary buffer.
 ICodeBuffer emitAS(java.lang.String aContent)
          Accumulates the specified content which will be added to the primary buffer at the end of sequence of "emitAS*" method calls as the parameter to the "tools.appendString()" method.
 ICodeBuffer emitASconst(java.lang.String aContent)
          Accumulates the specified content which will be added to the primary buffer at the end of sequence of "emitAS*" method calls as the parameter to the "tools.appendString()" method.
 ICodeBuffer emitASraw(java.lang.String aContent)
          Accumulates the specified content which will be added to the primary buffer at the end of sequence of "emitAS*" method calls as the parameter to the "tools.appendString()" method.
 ICodeBuffer emitCSF(java.lang.String aContent)
          Adds specified content fragment to primary buffer after processing it through StringUtils.crossScriptingFilter.
 ICodeBuffer emitCSFln(java.lang.String aContent)
          Adds specified content fragment to primary buffer after processing it through StringUtils.crossScriptingFilter and then appends a newline character.
 ICodeBuffer emitEscaped(java.lang.String aContent)
          Adds specified content fragment to primary buffer after processing it through StringUtils.escapeIntoJavaString.
 ICodeBuffer emitEscapedln(java.lang.String aContent)
          Adds specified content fragment to primary buffer after processing it through StringUtils.escapeIntoJavaString and then appends a newline character.
 ICodeBuffer emitln(java.lang.String aContent)
          Adds specified content fragment to primary buffer followed by a newline character.
 void focusOnSupport()
          Adjusts the code buffers to make the current support buffer primary and provide a new support buffer.
 java.lang.String generateJavaForPropertySet(ClipboardProperty aLHS, ClipboardProperty aRHS)
          Generates code for a property set.
 CodeGenerator getBooleanCodeGenerator()
          Accessor for the expected type Boolean instance.
 CodeGenerator getBooleanWithVariableCodeGenerator()
          Accessor for the expected type Boolean with intermediate variable instance.
 GenericAssembler getBuilder()
          Identifies the rule assembler that is being used during this assembly.
 FirstUseAssembler getCaller()
          Identifies the FirstUseAssembler instance assocaited with the Rule- that referenced this Rule-.
 java.lang.String getClassForPage(java.lang.String aPage, boolean aIsPrimaryReference)
          Gets the class for a specified page, if known.
 CodeGenerator getCodeGenerator()
          Provides an instance of CodeGenerator that may be used to specify the requried return type of an expression
 CodeGenerator getCodeGeneratorInstance()
          Returns a newly constructed instance of CodeGenerator
 Database getDatabase()
          Provides access to the appropriate Database instance for this execution context.
 ClipboardPage getDefinition()
          Supplies the definition being processed.
 Dictionary getDictionary()
          Provides access to the appropriate Dictionary instance for this execution context and edit/runtime processing mode.
 RulesetContext getEditContext()
          Supplies the RulesetContext that corresponds to the design time environment for the Rule instance being assembled.
 java.lang.String getIdentification()
          Provides a string value that can be used in message descriptors to identify the Rule- reference of this instance.
 JavaGenerator getJavaBuilder()
          Identifies the rule assembler that is being used during this assembly.
 CodeGenerator getJavaForExpression(java.lang.String aExpression, ClipboardProperty aProp, CodeGenerator aExpectedType, boolean aProcessBlank)
          Adds execution logic for the expression to the primary and support buffers, and provides an instance of CodeGenerator from which one can retrieve a reference to the value of the expression via getTertiary().
 CodeGenerator getJavaForExpression(java.lang.String aExpression, ClipboardProperty aProp, CodeGenerator aExpectedType, boolean aProcessBlank, boolean aSupportLinkedReference)
          Adds execution logic for the expression to the primary and support buffers, and provides an instance of CodeGenerator from which one can retrieve a reference to the value of the expression via getTertiary().
 java.lang.String getJavaName()
          Provides a string value that is the name of the Java class assigned by First Use Assembly for this Rule instance.
 java.lang.String getJavaTypeForPegaType(char aPegaType)
          Returns the "preferred" Java type for the specified PegaRULES data type
 StringMap getKeys()
          Identifies the key information for this instance.
 ClipboardProperty getLocalParameters()
          Supplies the LocalParameters property for this definition, for use by expression parsing and reference resolution interfaces.
 java.lang.String getMethodName()
          Provide unique mnemonic name to mBuilder.methodAccess method for a local implementation of this Rule- that can be reused within this implementation class.
 java.lang.String getMethodNameForKey(java.lang.String aInsKey)
          Return the method name which has been generated for this pzInsKey, or null if no such method has been generated yet.
 PageDescriptor getPageDescriptor(java.lang.String aPageName, boolean aFlagMissing)
          Provides the information known about the named page.
 ClipboardProperty getParameters()
          Supplies the Parameters property for this definition, for use by expression parsing and reference resolution interfaces.
 PageDescriptor getPrimaryDescriptor()
          Provides the information known about the current Primary Page.
 ClipboardPage getRuleBasis()
          Supplies the basis, if any, for the Rule- instance being edited.
 PageDescriptor getStepPage()
          Provides the information known about the current Step Page.
 CodeGenerator getStringCodeGenerator()
          Accessor for the expected type String instance.
 CodeGenerator getStringWithVariableCodeGenerator()
          Accessor for the expected type String with intermediate variable instance.
 PRThread getThread()
          Provides access to the appropriate PRThread instance for this execution context.
 java.lang.String getUniqueID(java.lang.String aPrefix)
          Identifies a unique Java identifier, using a specified prefix.
 java.util.List getWhenChangeDeclarativeReferences()
          Gets the list of RHS property references for change tracking.
 java.util.List getWillChangeDeclarativeReferences()
          Gets the list of LHS property references for change tracking.
 boolean haveRuleBasis()
          Indicates whether this Rule- instance has a basis instance.
 ICodeBuffer increaseIndent()
          Increases the indentation level by one.
 boolean isDeclarativeInvoked()
          Is this rule type called by declarative rules?
 boolean isDeclarativeRule()
          Is this rule type used for declarative processing?
 boolean isEditing()
          Identifies whether the current processing is for design-time editing of an instance defined for First-Use Assembly.
 boolean isEmbedded()
          Identifies whether this definition is being referenced within the First-Use Assembly of another definition.
 boolean isMyStepPageChecked()
          Gets the flag to check for null myStepPage
 boolean isPrimary()
          Identifies whether this is the originating reference to First-Use Assembly, defining the top-level processing of the desired GeneratedJava instance.
 boolean isRuntime()
          Identifies whether the current processing is assembling Java for runtime execution.
 StringExpression newStringExpression()
          Provides a new StringExpression instance, initially representing an empty String.
 StringExpression newStringExpression(java.lang.String aInitial, boolean aIsLiteral)
          Provides a new StringExpression instance, initially representing a value specified by either a String literal or a String-valued Java expression.
 StringExpression newStringExpression(StringExpression aOriginal)
          Provides a new StringExpression instance, initially representing a copy of the argument instance.
 void noteClassDependence(java.lang.String aClassName)
          Includes the specified class among those that might affect the generated Java.
 void noteInstanceUsed(StringMap aKeys)
          Adds the specified instance to the list of rule dependencies, and optionally to the list of used rules.
 void noteInstanceUsed(StringMap aKeys, PageDescriptor pageDesc)
          Adds the specified instance to the list of rule dependencies, and optionally to the list of used rules.
 void notePropertyUsed(java.lang.String aClassName, java.lang.String aPropertyName)
          Includes the specified Rule-Obj-Property instance among those that might affect the generated Java.
 void notePropertyUsed(java.lang.String aClassName, java.lang.String aPropertyName, PageDescriptor aPageDesc)
          Includes the specified Rule-Obj-Property instance among those that might affect the generated Java.
 ClipboardPage openRule(StringMap aKeyPage, boolean aForceDBOpen)
          Opens the specified database instance, using either the RulesetContext (at design time) or Database (at runtime) so that referenced rule tracking is properly performed.
 void popStepPage()
          Unwinds one call to pushStepPage.
 java.lang.String preprocessExpression(java.lang.String aExpression)
          Applies pre-processing heuristics to the specified expression and modifies the expression if required to a form that can be consumed by the expression parsing framework.
 void pushStepPage(java.lang.String aPageName, boolean aNewPrimary)
          Establishes information about a new Step Page (which might also be a new Primary Page), based on the name of the page.
 void pushStepPage(java.lang.String aPageName, java.lang.String aClassName, boolean aIsExact, boolean aNewPrimary)
          Establishes information about a new Step Page (which might also be a new Primary Page), based on information known about the class of the page.
 void resetDefaultDefinition()
          Restores the original definition(s) (and clears temp containers) being processed.
 void restoreFocus()
          Restores the current primary code buffer to its previous role as support buffer.
 void setCurrentRepeatType(java.lang.String currentRepeatType)
           
 void setDeclarativeInvoked(boolean aIsDeclarativeInvoked)
          Instruct the parser to treat this rule type as a declarative rule.
 void setDeclarativeRule(boolean aIsDeclarativeRule)
          Instruct the parser to treat this rule type as a declarative rule.
 ICodeBuffer setIndentContent(java.lang.String aIndentContent)
          Sets the desired String to use for each indentation level.
 ICodeBuffer setIndentLevel(int aLevel)
          Sets the desired indentation level (e.g.
 void setMyStepPageChecked(boolean aMyStepPageChecked)
          Sets the flag to check for null myStepPage
 void setOverrideDefinition(ClipboardPage aDef)
          Overrides the definition being processed, original definitions are saved for resetDefaultDefinition().
 void setWhenChangeDeclarativeReferences(java.util.List aWhenChangeRefs)
          Sets the list of RHS property references for change tracking.
 void setWillChangeDeclarativeReferences(java.util.List aWillChangeRefs)
          Sets the list of LHS property references for change tracking.
 void summarizeGeneratedMethods(java.lang.String aIdentifier)
          Outputs summary information about the methods generated and the number of times that each method has been (re-)used during this assembly.
 CodeGenerator translateExpression(java.lang.String aExpression, ClipboardProperty aProp, CodeGenerator aExpectedType, boolean aProcessBlank)
          Provides execution logic for the expression and returns an instance of a CodeGenerator from which one can retrieve the assembled Java (via CodeGenerator.getPrimary() and CodeGenerator.getSecondary()) and a reference to the value of the expression (via CodeGenerator.getTertiary()).
 CodeGenerator translateExpression(java.lang.String aExpression, ClipboardProperty aProp, CodeGenerator aExpectedType, boolean aProcessBlank, boolean aSupportLinkedReference)
           
 

Field Detail

COPYRIGHT

static final java.lang.String COPYRIGHT
See Also:
Constant Field Values

VERSION

static final java.lang.String VERSION
See Also:
Constant Field Values
Method Detail

isRuntime

boolean isRuntime()
Identifies whether the current processing is assembling Java for runtime execution.

Returns:
true when Java is being assembled for runtime execution; false when Java is being assembled for a compilation test at design time

isEditing

boolean isEditing()
Identifies whether the current processing is for design-time editing of an instance defined for First-Use Assembly.

Returns:
true when Java is being assembled for a compilation test at design time; false when Java is being assembled for runtime execution

isPrimary

boolean isPrimary()
Identifies whether this is the originating reference to First-Use Assembly, defining the top-level processing of the desired GeneratedJava instance.

Returns:
true if this is the originating reference to First-Use Assembly; false if this definition is referenced within another

isEmbedded

boolean isEmbedded()
Identifies whether this definition is being referenced within the First-Use Assembly of another definition.

Returns:
true if this definition is referenced within another; false if this is the originating reference to First-Use Assembly

getBuilder

GenericAssembler getBuilder()
Identifies the rule assembler that is being used during this assembly.

Returns:
instance of the class implementing the rule assembler.

getJavaBuilder

JavaGenerator getJavaBuilder()
Identifies the rule assembler that is being used during this assembly.

Returns:
instance of the class implementing the rule assembler.

getCaller

FirstUseAssembler getCaller()
Identifies the FirstUseAssembler instance assocaited with the Rule- that referenced this Rule-.

Returns:
the calling instance of FirstUseAssembler; or null when isPrimary returns true

getDatabase

Database getDatabase()
Provides access to the appropriate Database instance for this execution context.

Returns:
a Database instance

getDictionary

Dictionary getDictionary()
Provides access to the appropriate Dictionary instance for this execution context and edit/runtime processing mode.

Returns:
a Dictionary instance

getThread

PRThread getThread()
Provides access to the appropriate PRThread instance for this execution context.

Returns:
a PRThread instance

getKeys

StringMap getKeys()
Identifies the key information for this instance. When isEditing returns true, the object returned might be the ClipboardPage instance being edited.

Returns:
StringMap of key values that indentify this instance

getIdentification

java.lang.String getIdentification()
Provides a string value that can be used in message descriptors to identify the Rule- reference of this instance. The value consists of the class name, a tab character, then a dot-delimited list of the key-property values. The case of all values is preserved from the original StringMap specification.

Returns:
string value that identifies the associated Rule-reference

getJavaName

java.lang.String getJavaName()
Provides a string value that is the name of the Java class assigned by First Use Assembly for this Rule instance.

Returns:
string value that identifies the Java class

getCodeGenerator

CodeGenerator getCodeGenerator()
Provides an instance of CodeGenerator that may be used to specify the requried return type of an expression

Returns:
CodeGenerator instance

getJavaTypeForPegaType

java.lang.String getJavaTypeForPegaType(char aPegaType)
Returns the "preferred" Java type for the specified PegaRULES data type

Parameters:
aPegaType - PropertyInfo.TYPE_* code
Returns:
name of Java type

getDefinition

ClipboardPage getDefinition()
Supplies the definition being processed.

Returns:
a defining instance

setOverrideDefinition

void setOverrideDefinition(ClipboardPage aDef)
Overrides the definition being processed, original definitions are saved for resetDefaultDefinition(). If called more than once (without calling resetDefaultDefinition()) the old overrides are lost.

Parameters:
aDef - definition to using from now on.

resetDefaultDefinition

void resetDefaultDefinition()
Restores the original definition(s) (and clears temp containers) being processed. Makes no changes unless setOverrideDefinition(ClipboardPage) was called.


getLocalParameters

ClipboardProperty getLocalParameters()
Supplies the LocalParameters property for this definition, for use by expression parsing and reference resolution interfaces.

Returns:
ClipboardProperty of mode PageList and class Embed-MethodParams or null if no such property exists.

getParameters

ClipboardProperty getParameters()
Supplies the Parameters property for this definition, for use by expression parsing and reference resolution interfaces.

Returns:
ClipboardProperty of mode PageList and class Embed-MethodParams or null if no such property exists.

getMethodName

java.lang.String getMethodName()
Provide unique mnemonic name to mBuilder.methodAccess method for a local implementation of this Rule- that can be reused within this implementation class.

Returns:
unique mnemonic name

getUniqueID

java.lang.String getUniqueID(java.lang.String aPrefix)
Identifies a unique Java identifier, using a specified prefix.

Parameters:
aPrefix - suggested prefix for the Java class name
Returns:
unique identifier

addImport

void addImport(java.lang.String aImport)
Add to the set of import statements required for the generated Java.

Parameters:
aImport - fully-qualified class name, or fully-qualified package name that ends with ".*" or "."

noteClassDependence

void noteClassDependence(java.lang.String aClassName)
Includes the specified class among those that might affect the generated Java. A change to any instance of this class will force reassembly of this instance.

Parameters:
aClassName - identifies teh name of the class

noteInstanceUsed

void noteInstanceUsed(StringMap aKeys,
                      PageDescriptor pageDesc)
Adds the specified instance to the list of rule dependencies, and optionally to the list of used rules.

The aKeys parameter identifies the instance. It must contain the pxObjClass and the key property values for the rule to be added.

The rule identified by aKeys is always added to the list of rule dependencies.

The aKeys map may also contain the instance's pzInsKey, pxUpdateDateTime, and pyRuleSet properties. Iff these are included, then the rule is added to list of used rules (as well as the rule dependency list).

Parameters:
aKeys - identifies at least the key properties of the instance to be included
pageDesc - a page descriptor

noteInstanceUsed

void noteInstanceUsed(StringMap aKeys)
Adds the specified instance to the list of rule dependencies, and optionally to the list of used rules.

The aKeys parameter identifies the instance. It must contain the pxObjClass and the key property values for the rule to be added.

The rule identified by aKeys is always added to the list of rule dependencies.

The aKeys map may also contain the instance's pzInsKey, pxUpdateDateTime, and pyRuleSet properties. Iff these are included, then the rule is added to list of used rules (as well as the rule dependency list).

Parameters:
aKeys - identifies at least the key properties of the instance to be included

notePropertyUsed

void notePropertyUsed(java.lang.String aClassName,
                      java.lang.String aPropertyName)
Includes the specified Rule-Obj-Property instance among those that might affect the generated Java.

Parameters:
aClassName - pyClassName of the property
aPropertyName - pyPropertyName of the property

notePropertyUsed

void notePropertyUsed(java.lang.String aClassName,
                      java.lang.String aPropertyName,
                      PageDescriptor aPageDesc)
Includes the specified Rule-Obj-Property instance among those that might affect the generated Java.

Parameters:
aClassName - pyClassName of the property
aPropertyName - pyPropertyName of the property
aPageDesc - a page descriptor

addCode

java.lang.StringBuffer addCode(java.lang.String aCode)
Adds specified code fragment to primary buffer.

Parameters:
aCode - code fragment to add
Returns:
primary code buffer

addToSupport

java.lang.StringBuffer addToSupport(java.lang.String aCode)
Adds specified code fragment to support-code buffer.

Parameters:
aCode - code fragment to add
Returns:
support-code buffer

addCode

void addCode(ExpressionMap aKeys)
             throws FirstUseAssemblerException
Deprecated. this method may be used only if the rule in question has a single aspect defined. It it has more than one, then an error will occur. Use addCode(ExpressionMap, String) instead.

Adds execution of the specified Rule- reference to the primary code buffer. If some of the identifying values require runtime evaluation, or if isEditing returns true, then the execution will be provided by a call to a separately assembled implementation class. Otherwise, the JavaGenerator for the referenced Rule- class will determine whether the implementation is incorporated into the implementation class being assembled.

Parameters:
aKeys - Map of named Expressions identifying the referenced Rule-. A StringExpression with a literal value (isLiteral returns true) must be specified for "pxObjClass". Any other key-property or parameter values needed to identify and execute the referenced Rule- must also be provided, but need not have literal values.
Throws:
FirstUseAssemblerException - if unable to establish the indicated execution

addCode

void addCode(ExpressionMap aKeys,
             java.lang.String aAspect)
             throws FirstUseAssemblerException
Adds execution of the specified Rule- reference for the specified aspect to the primary code buffer. If some of the identifying values require runtime evaluation, or if isEditing returns true, then the execution will be provided by a call to a separately assembled implementation class. Otherwise, the JavaGenerator for the referenced Rule- class will determine whether the implementation is incorporated into the implementation class being assembled.

Parameters:
aKeys - Map of named Expressions identifying the referenced Rule-. A StringExpression with a literal value (isLiteral returns true) must be specified for "pxObjClass". Any other key-property or parameter values needed to identify and execute the referenced Rule- must also be provided, but need not have literal values.
aAspect - the aspect
Throws:
FirstUseAssemblerException - if unable to establish the indicated execution

addCode

void addCode(ExpressionMap aKeys,
             java.lang.String aAspect,
             PageDescriptor aPageDesc)
             throws FirstUseAssemblerException
Adds execution of the specified Rule- reference for the specified aspect to the primary code buffer. If some of the identifying values require runtime evaluation, or if isEditing returns true, then the execution will be provided by a call to a separately assembled implementation class. Otherwise, the JavaGenerator for the referenced Rule- class will determine whether the implementation is incorporated into the implementation class being assembled.

Parameters:
aKeys - Map of named Expressions identifying the referenced Rule-. A StringExpression with a literal value (isLiteral returns true) must be specified for "pxObjClass". Any other key-property or parameter values needed to identify and execute the referenced Rule- must also be provided, but need not have literal values.
aAspect - the aspect
aPageDesc - the PageDescriptor representing the class these rules are assembled against
Throws:
FirstUseAssemblerException - if unable to establish the indicated execution

addToSupport

void addToSupport(ExpressionMap aKeys)
                  throws FirstUseAssemblerException
Deprecated. this method may be used only if the rule in question has a single aspect defined. It it has more than one, then an error will occur. Use addToSupport(ExpressionMap, String) instead.

Adds execution of the specified Rule- reference to the support code buffer. If some of the identifying values require runtime evaluation, or if isEditing returns true, then the execution will be provided by a call to a separately assembled implementation class. Otherwise, the JavaGenerator for the referenced Rule- class will determine whether the implementation is incorporated into the implementation class being assembled.

Parameters:
aKeys - Map of named Expressions identifying the referenced Rule-. A StringExpression with a literal value (isLiteral returns true) must be specified for "pxObjClass". Any other key-property or parameter values needed to identify and execute the referenced Rule- must also be provided, but need not have literal values.
Throws:
FirstUseAssemblerException - if unable to establish the indicated execution

addToSupport

void addToSupport(ExpressionMap aKeys,
                  java.lang.String aAspect)
                  throws FirstUseAssemblerException
Adds execution of the specified Rule- reference for the specified aspect to the support code buffer. If some of the identifying values require runtime evaluation, or if isEditing returns true, then the execution will be provided by a call to a separately assembled implementation class. Otherwise, the JavaGenerator for the referenced Rule- class will determine whether the implementation is incorporated into the implementation class being assembled.

Parameters:
aKeys - Map of named Expressions identifying the referenced Rule-. A StringExpression with a literal value (isLiteral returns true) must be specified for "pxObjClass". Any other key-property or parameter values needed to identify and execute the referenced Rule- must also be provided, but need not have literal values.
aAspect - the aspect
Throws:
FirstUseAssemblerException - if unable to establish the indicated execution

getJavaForExpression

CodeGenerator getJavaForExpression(java.lang.String aExpression,
                                   ClipboardProperty aProp,
                                   CodeGenerator aExpectedType,
                                   boolean aProcessBlank)
Adds execution logic for the expression to the primary and support buffers, and provides an instance of CodeGenerator from which one can retrieve a reference to the value of the expression via getTertiary(). Type information about the result of the expression is also contained in the CodeGenerator instance.
This method is intended for use by FUA classes that implement the JavaGenerator interface. It places the generated code directly into the primary and support buffers.

Parameters:
aExpression - String containing expression to be parsed
aProp - ClipboardProperty corresponding to the expression passed. If not null, and the generator encounters a problem generating code for this expression, error messages will be added to this specified property for display.
aExpectedType - CodeGenerator specifying expected type of the expression, or null if unknown.
aProcessBlank - indicates that a blanks expression should be processed and returned as empty strings.
Returns:
CodeGenerator containing result of parsing the expression

getJavaForExpression

CodeGenerator getJavaForExpression(java.lang.String aExpression,
                                   ClipboardProperty aProp,
                                   CodeGenerator aExpectedType,
                                   boolean aProcessBlank,
                                   boolean aSupportLinkedReference)
Adds execution logic for the expression to the primary and support buffers, and provides an instance of CodeGenerator from which one can retrieve a reference to the value of the expression via getTertiary(). Type information about the result of the expression is also contained in the CodeGenerator instance.
This method is intended for use by FUA classes that implement the JavaGenerator interface. It places the generated code directly into the primary and support buffers.

Parameters:
aExpression - String containing expression to be parsed
aProp - ClipboardProperty corresponding to the expression passed. If not null, and the generator encounters a problem generating code for this expression, error messages will be added to this specified property for display.
aExpectedType - CodeGenerator specifying expected type of the expression, or null if unknown.
aProcessBlank - indicates that a blanks expression should be processed and returned as empty strings.
aSupportLinkedReference - indicates that we should allow a linked reference in this expression
Returns:
CodeGenerator containing result of parsing the expression

translateExpression

CodeGenerator translateExpression(java.lang.String aExpression,
                                  ClipboardProperty aProp,
                                  CodeGenerator aExpectedType,
                                  boolean aProcessBlank)
Provides execution logic for the expression and returns an instance of a CodeGenerator from which one can retrieve the assembled Java (via CodeGenerator.getPrimary() and CodeGenerator.getSecondary()) and a reference to the value of the expression (via CodeGenerator.getTertiary()). Type information about the result of the expression is also contained in the CodeGenerator instance.

This method is intended for use by the "ClipboardPage" interface to FUA. It returns the translated Java in the CodeGenerator instance, and it is the responsibility of the caller to move this logic into the final code buffers if desired.

Parameters:
aExpression - Expression to be parsed.
aProp - ClipboardProperty corresponding to the expression passed. If not null, and the generator encounters a problem generating code for this expression, error messages will be added to this specified property for display.
aExpectedType - CodeGenerator specifying expected type of the expression, or null if unknown.
aProcessBlank - indicates that a blank expression should be processed and returned as empty strings. If this flag is set to false and a blank expression is passed, getPrimary() returns java code that throws an UnresolvedAssemblyError if executed at runtime.
Returns:
a CodeGenerator containing result of parsing the expression

translateExpression

CodeGenerator translateExpression(java.lang.String aExpression,
                                  ClipboardProperty aProp,
                                  CodeGenerator aExpectedType,
                                  boolean aProcessBlank,
                                  boolean aSupportLinkedReference)

preprocessExpression

java.lang.String preprocessExpression(java.lang.String aExpression)
Applies pre-processing heuristics to the specified expression and modifies the expression if required to a form that can be consumed by the expression parsing framework.

Parameters:
aExpression - Expression to be pre-processed.
Returns:
String the resulting expression after pre-processing

getStepPage

PageDescriptor getStepPage()
Provides the information known about the current Step Page.

Returns:
descriptor for the current Step Page

getPageDescriptor

PageDescriptor getPageDescriptor(java.lang.String aPageName,
                                 boolean aFlagMissing)
Provides the information known about the named page.

Parameters:
aPageName - name of the ClipboardPage
aFlagMissing - true if a missing page should result in an error
Returns:
descriptor for the named page

getPrimaryDescriptor

PageDescriptor getPrimaryDescriptor()
Provides the information known about the current Primary Page.

Returns:
descriptor for the current Primary Page

pushStepPage

void pushStepPage(java.lang.String aPageName,
                  boolean aNewPrimary)
Establishes information about a new Step Page (which might also be a new Primary Page), based on the name of the page. This method typically corresponds to a PegaAPI.pushStackFrame call in the generated Java.

Parameters:
aPageName - name of the new Step Page
aNewPrimary - true when the new Step Page will also be the new Primary Page

pushStepPage

void pushStepPage(java.lang.String aPageName,
                  java.lang.String aClassName,
                  boolean aIsExact,
                  boolean aNewPrimary)
Establishes information about a new Step Page (which might also be a new Primary Page), based on information known about the class of the page. This method typically corresponds to a PegaAPI.pushStackFrame call in the generated Java.

Parameters:
aPageName -
aClassName - specified class of the new Step Page
aIsExact - true if the actual class of the new Step Page is known; false if the actual class of the Step Page might derive from the specified class name
aNewPrimary - true when the new Step Page will also be the new Primary Page

popStepPage

void popStepPage()
Unwinds one call to pushStepPage.


getEditContext

RulesetContext getEditContext()
Supplies the RulesetContext that corresponds to the design time environment for the Rule instance being assembled.

Returns:
a RulesetContext instance or null if isRuntime() is true.

getRuleBasis

ClipboardPage getRuleBasis()
Supplies the basis, if any, for the Rule- instance being edited. The basis is the Rule- instance overridden by this one, which therefore constrains the external interface to the processing defined by this instance.

Returns:
the basis of the Rule- being edited, or null

haveRuleBasis

boolean haveRuleBasis()
Indicates whether this Rule- instance has a basis instance.

Returns:
true if this instance has a basis instance; false if the Rule- instance being edited does not override another Rule- instance, and also if isEditing returns false or isPrimary returns false

newStringExpression

StringExpression newStringExpression()
Provides a new StringExpression instance, initially representing an empty String.

Returns:
the new StringExpression instance

newStringExpression

StringExpression newStringExpression(StringExpression aOriginal)
Provides a new StringExpression instance, initially representing a copy of the argument instance.

Parameters:
aOriginal - a StringExpression instance to be copied
Returns:
the new StringExpression instance

newStringExpression

StringExpression newStringExpression(java.lang.String aInitial,
                                     boolean aIsLiteral)
Provides a new StringExpression instance, initially representing a value specified by either a String literal or a String-valued Java expression.

Parameters:
aInitial - initial specification
aIsLiteral - true if aInitial specifies a String literal; false if it identifies a String-valued Java expression.
Returns:
the new StringExpression instance

addErrorMessages

boolean addErrorMessages(ClipboardProperty aProp,
                         CodeGenerator aGenCode)
Checks for error messages in aGenCode and adds them to aProp

Parameters:
aProp - ClipboardProperty from which the expression was parsed
aGenCode - Generated code for the expression
Returns:
true if aGenCode contains a non-empty list of error messages

openRule

ClipboardPage openRule(StringMap aKeyPage,
                       boolean aForceDBOpen)
                       throws BadClassDefinitionException,
                              ConfigurationException,
                              MultipleCircumstancePropertiesException,
                              MultipleRuleVersionException,
                              BadInputException,
                              BadInstanceDataException,
                              DatabaseException
Opens the specified database instance, using either the RulesetContext (at design time) or Database (at runtime) so that referenced rule tracking is properly performed.

Parameters:
aKeyPage - keys to instance desired
aForceDBOpen - true to bypass EditContext and use database open even at design-time.
Returns:
ClipboardPage of instance retrieved
Throws:
BadClassDefinitionException
ConfigurationException
MultipleCircumstancePropertiesException
MultipleRuleVersionException
BadInputException
BadInstanceDataException
DatabaseException

addKnownPageDescriptor

void addKnownPageDescriptor(java.lang.String aPageName,
                            java.lang.String aClassName)
Add a page to the "known page" list so that subsequent processing will be able to identify the class of a page created by Page-New, Obj-Open, etc.

Parameters:
aPageName - name of page, simple names only
aClassName - name of class

getStringCodeGenerator

CodeGenerator getStringCodeGenerator()
Accessor for the expected type String instance.

Returns:
CodeGenerator

getStringWithVariableCodeGenerator

CodeGenerator getStringWithVariableCodeGenerator()
Accessor for the expected type String with intermediate variable instance.

Returns:
CodeGenerator

getBooleanCodeGenerator

CodeGenerator getBooleanCodeGenerator()
Accessor for the expected type Boolean instance.

Returns:
CodeGenerator

getBooleanWithVariableCodeGenerator

CodeGenerator getBooleanWithVariableCodeGenerator()
Accessor for the expected type Boolean with intermediate variable instance.

Returns:
CodeGenerator

isDeclarativeRule

boolean isDeclarativeRule()
Is this rule type used for declarative processing?

Returns:
boolean

isDeclarativeInvoked

boolean isDeclarativeInvoked()
Is this rule type called by declarative rules?

Returns:
boolean

setDeclarativeRule

void setDeclarativeRule(boolean aIsDeclarativeRule)
Instruct the parser to treat this rule type as a declarative rule. Among other things, this will tell the parser to collect all property references discovered during creation of CodeGenerator objects, which can be retrieved by the caller.

Parameters:
aIsDeclarativeRule - Is this a declarative rule?

setDeclarativeInvoked

void setDeclarativeInvoked(boolean aIsDeclarativeInvoked)
Instruct the parser to treat this rule type as a declarative rule. Among other things, this will tell the parser to collect all property references discovered during creation of CodeGenerator objects, which can be retrieved by the caller.

Parameters:
aIsDeclarativeInvoked - Is this invoked by declarative rules?

isMyStepPageChecked

boolean isMyStepPageChecked()
Gets the flag to check for null myStepPage

Returns:
true if code to check for null myStepPage has been emitted to the code buffer

setMyStepPageChecked

void setMyStepPageChecked(boolean aMyStepPageChecked)
Sets the flag to check for null myStepPage

Parameters:
aMyStepPageChecked -

generateJavaForPropertySet

java.lang.String generateJavaForPropertySet(ClipboardProperty aLHS,
                                            ClipboardProperty aRHS)
Generates code for a property set. Uses the expression parser framework to apply standard property-resolution and pre-processing heuristics.

Parameters:
aLHS - left hand side of property-set
aRHS - right hand side of property-set
Returns:
the generated code for Property-Set

getWhenChangeDeclarativeReferences

java.util.List getWhenChangeDeclarativeReferences()
Gets the list of RHS property references for change tracking. To be used ONLY in conjunction with generateJavaForPropertySet. AFTER calling generateJavaForPropertySet use this method to fetch RHS properties found in the property-sets.

Returns:
List RHS property references

getWillChangeDeclarativeReferences

java.util.List getWillChangeDeclarativeReferences()
Gets the list of LHS property references for change tracking. To be used ONLY in conjunction with generateJavaForPropertySet. AFTER calling generateJavaForPropertySet use this method to fetch LHS properties found in the property-sets.

Returns:
List LHS property references

setWhenChangeDeclarativeReferences

void setWhenChangeDeclarativeReferences(java.util.List aWhenChangeRefs)
Sets the list of RHS property references for change tracking.

Parameters:
aWhenChangeRefs - RHS property references

setWillChangeDeclarativeReferences

void setWillChangeDeclarativeReferences(java.util.List aWillChangeRefs)
Sets the list of LHS property references for change tracking.

Parameters:
aWillChangeRefs - LHS property references

focusOnSupport

void focusOnSupport()
Adjusts the code buffers to make the current support buffer primary and provide a new support buffer.


restoreFocus

void restoreFocus()
Restores the current primary code buffer to its previous role as support buffer. The current support buffer is assimilated.


checkWhenInstance

boolean checkWhenInstance(java.lang.String aStepPPageClass,
                          java.lang.String aPPageClass,
                          java.lang.String aWhenName,
                          ClipboardProperty aWhenRef)
Validates that the specified when block exists and is accessible to the user's context.

Parameters:
aStepPPageClass - - Step page class name.
aPPageClass - - primary page class name.
aWhenName - - when rule name.
aWhenRef - - when rule reference.
Returns:
boolean - true if the when instance exists and is accessible to the user's edit context.

checkModelInstance

boolean checkModelInstance(java.lang.String aStepPPageClass,
                           java.lang.String aPPageClass,
                           java.lang.String aModelName,
                           ClipboardProperty aModelRef)
Validates that the specified model exists and is accessible to the user's context.

Parameters:
aStepPPageClass - - Step page class name.
aPPageClass - - primary page class name.
aModelName - - model name.
aModelRef - - model reference.
Returns:
boolean - true if the model instance exists and is accessible to the user's edit context.

getCodeGeneratorInstance

CodeGenerator getCodeGeneratorInstance()
Returns a newly constructed instance of CodeGenerator

Returns:
CodeGenerator a freshly created instance of CodeGenerator

setCurrentRepeatType

void setCurrentRepeatType(java.lang.String currentRepeatType)
Parameters:
currentRepeatType - The mCurrentRepeatType to set.

getClassForPage

java.lang.String getClassForPage(java.lang.String aPage,
                                 boolean aIsPrimaryReference)
Gets the class for a specified page, if known.

Parameters:
aPage - the Page
aIsPrimaryReference -
Returns:
the class of the page. This might be a symbolic name like $ANY

createMethod

IGeneratedMethod createMethod(java.lang.String aProposedName,
                              boolean aCaptureAddCode)
Begin construction of a generated method.

Parameters:
aProposedName - Name that the caller suggests be used as the base for the method name. Use IGeneratedMethod.insertMethodName(IGeneratedMethod.put("")) to insert the real method name into method at the appropriate location.
aCaptureAddCode - if true then calls to FirstUseAssembler.addCode(String) will be captured and the text added to this generated method until the method is closed.
Returns:
method instance to be used during assembly.

createMethod

IGeneratedMethod createMethod(java.lang.String aProposedName,
                              boolean aCaptureAddCode,
                              java.lang.String aInsKey)
Begin construction of a generated method.

Parameters:
aProposedName - Name that the caller suggests be used as the base for the method name. Use IGeneratedMethod.insertMethodName(IGeneratedMethod.put("")) to insert the real method name into method at the appropriate location.
aCaptureAddCode - if true then calls to FirstUseAssembler.addCode(String) will be captured and the text added to this generated method until the method is closed.
aInsKey - pzInsKey of rule for which this method is being generated (JSP include tag handling)
Returns:
method instance to be used during assembly.

getMethodNameForKey

java.lang.String getMethodNameForKey(java.lang.String aInsKey)
Return the method name which has been generated for this pzInsKey, or null if no such method has been generated yet.

Parameters:
aInsKey - pzInsKey to look up
Returns:
method name or null

summarizeGeneratedMethods

void summarizeGeneratedMethods(java.lang.String aIdentifier)
Outputs summary information about the methods generated and the number of times that each method has been (re-)used during this assembly. (output only if "info" logging is enabled for com.pega.pegarules.generation.internal.assembly.FUAManagerImpl-GenMethods)

Parameters:
aIdentifier - identifies the rule being assembled

setIndentLevel

ICodeBuffer setIndentLevel(int aLevel)
Sets the desired indentation level (e.g. number of leading tab characters)

Parameters:
aLevel - desired level; if less than 0, then 0 will be used
Returns:
CodeBuffer instance

setIndentContent

ICodeBuffer setIndentContent(java.lang.String aIndentContent)
Sets the desired String to use for each indentation level. Defaults to "\t". If, for example, you prefer two spaces then use " ".

Parameters:
aIndentContent - content for each indentation level.
Returns:
CodeBuffer instance

increaseIndent

ICodeBuffer increaseIndent()
Increases the indentation level by one.

Returns:
CodeBuffer instance

decreaseIndent

ICodeBuffer decreaseIndent()
Decreases the indentation level by one. If this would reduce the level to less than zero, the 0 will be used.

Returns:
CodeBuffer instance

emit

ICodeBuffer emit(java.lang.String aContent)
Adds specified content fragment to primary buffer. If this content starts on a new line, then the appropriate indentation will be added prior to the content.

Parameters:
aContent - content to be added
Returns:
CodeBuffer instance

emitln

ICodeBuffer emitln(java.lang.String aContent)
Adds specified content fragment to primary buffer followed by a newline character. If this content starts on a new line, then the appropriate indentation will be added prior to the content.

Parameters:
aContent - content to be added
Returns:
CodeBuffer instance

emitEscaped

ICodeBuffer emitEscaped(java.lang.String aContent)
Adds specified content fragment to primary buffer after processing it through StringUtils.escapeIntoJavaString. If this content starts on a new line, then the appropriate indentation will be added prior to the content.

Parameters:
aContent - content to be added
Returns:
CodeBuffer instance

emitEscapedln

ICodeBuffer emitEscapedln(java.lang.String aContent)
Adds specified content fragment to primary buffer after processing it through StringUtils.escapeIntoJavaString and then appends a newline character. If this content starts on a new line, then the appropriate indentation will be added prior to the content.

Parameters:
aDepth - number of additional times the content should be escaped (specify 0 to escape once, the most typical use)
aContent - content to be added
Returns:
CodeBuffer instance

emitCSF

ICodeBuffer emitCSF(java.lang.String aContent)
Adds specified content fragment to primary buffer after processing it through StringUtils.crossScriptingFilter. If this content starts on a new line, then the appropriate indentation will be added prior to the content.

Parameters:
aContent - content to be added
Returns:
CodeBuffer instance

emitCSFln

ICodeBuffer emitCSFln(java.lang.String aContent)
Adds specified content fragment to primary buffer after processing it through StringUtils.crossScriptingFilter and then appends a newline character. If this content starts on a new line, then the appropriate indentation will be added prior to the content.

Parameters:
aContent - content to be added
Returns:
CodeBuffer instance

emitAS

ICodeBuffer emitAS(java.lang.String aContent)
Accumulates the specified content which will be added to the primary buffer at the end of sequence of "emitAS*" method calls as the parameter to the "tools.appendString()" method. If this sequence of content starts on a new line, then the appropriate indentation will be added prior to the content.

The content will be processed through StringUtils.escapeIntoJavaString.

Parameters:
aContent - content to be added
Returns:
CodeBuffer instance

emitASconst

ICodeBuffer emitASconst(java.lang.String aContent)
Accumulates the specified content which will be added to the primary buffer at the end of sequence of "emitAS*" method calls as the parameter to the "tools.appendString()" method. If this sequence of content starts on a new line, then the appropriate indentation will be added prior to the content.

The content will be processed through StringUtils.escapeIntoJavaString and then surrounded by quotation marks so that the content is treated as a constant String. Consecutive calls to "emitASconst" will have their content merged to a single constant String.

Parameters:
aContent - content to be added
Returns:
CodeBuffer instance

emitASraw

ICodeBuffer emitASraw(java.lang.String aContent)
Accumulates the specified content which will be added to the primary buffer at the end of sequence of "emitAS*" method calls as the parameter to the "tools.appendString()" method. If this sequence of content starts on a new line, then the appropriate indentation will be added prior to the content. Unlike the other "emitAS*" methods, the content will NOT be processed through StringUtils.escapeIntoJavaString.

Parameters:
aContent - content to be added
Returns:
CodeBuffer instance

createPageDescriptor

PageDescriptor createPageDescriptor(java.lang.String aPageName,
                                    java.lang.String aClassName,
                                    boolean aIsExact,
                                    boolean aIsParameter)
Create a PageDescriptor.

Parameters:
aPageName - The name of this page, if known. May be null.
aClassName - The class of this page, if known. May be null.
aIsExact - True if the class of this page cannot vary between assembly time and run time.
aIsParameter - True if this is a parameter page.
Returns:
A PageDescriptor described by the above arguments, with the value for PageDescriptor.isPrimaryPageForAssembly() calculated based on the assembly environment.

createPageDescriptor

PageDescriptor createPageDescriptor(java.lang.String aPageName,
                                    java.lang.String aClassName,
                                    boolean aIsExact,
                                    boolean aIsParameter,
                                    boolean aIsPrimaryPageForAssembly)
Create a PageDescriptor.

Parameters:
aPageName - The name of this page, if known. May be null.
aClassName - The class of this page, if known. May be null.
aIsExact - True if the class of this page cannot vary between assembly time and run time.
aIsParameter - True if this is a parameter page.
aIsPrimaryPageForAssembly - True if this page descriptor's type was drawn from the primary page at assembly time--most often true when this page represents the primary page.
Returns:
A PageDescriptor described by the above arguments.


Copyright © 2012 Pegasystems Inc. All Rights Reserved.