public interface JavaGenerator extends GenericAssemblerValidator
JavaGenerator
interface identifies the code fragments
required to specify how a defining Rule- instance is to be implemented.
These fragments are combined by First-Use Assembly, which can coordinate
multiple definitions into a single implementation class.
Each implementation of this interface is associated with one or more defining
Rule- classes. It determines how the specifications in instances of those
classes are to be implemented in Java. The implementation must specify a
constructor that accepts a FirstUseAssembler
instance as its only
parameter. This instance will provide access to the defining Rule-
ClipboardPage, will receive the generated Java fragments, and will provide
a variety of supporting functionality.
The JavaGenerator instance is "primary" if it corresponds to the reference that initiated the current Rules Assembly of Java code into an implementation class. It is "embedded" if it is being incorporated into an implementation class initiated by a different rule reference.
Each class that implements JavaGenerator must have a constructor of the form: JavaGenerator(FirstUseAssembler fua) The argument to the constructor provides access to the defining rule instance, implements functionality that can assist with the Java generation, and receives the Java as it is generated.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
COPYRIGHT |
static byte |
DEFERRED
Value returned by
methodAccess , indicating that the
referenced Rule- will be assembled separately. |
static byte |
PRIMARY
Value returned by
methodAccess , indicating that the
implementations of the referenced Rule- will be included directly in the
primary code buffer. |
static byte |
SUPPORT
Value returned by
methodAccess , indicating that the
implementations of the referenced Rule- will be included as a separate
method in the support code buffer, invoked from the primary code buffer. |
static java.lang.String |
VERSION |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getConstructorBody()
Generates the java for the body of the constructor for a rule.
|
java.lang.String |
getDefinedPrimaryPageClass()
Names the class of the primary page that will be used by this rule
in the absence of overriding information.
|
java.lang.String |
getInterfaceName()
Names the access interface implemented by the generated Java when this
processing is primary.
|
void |
methodAbsent(java.lang.String aMsgDescr)
Generates the code to handle the absence of the associated defining
ClipboardPage instance.
|
byte |
methodAccess(ExpressionMap aKeys)
Establishes the structure for accessing the implementation of this
instance within the implementation of another Rule- reference.
|
void |
methodBody(int aCircumstanceCount)
Provides the Java that implements one defining rule instance.
|
void |
methodCall(java.lang.String aMethodName,
ExpressionMap aKeys)
Generates the Java to invoke an implementation of the associated Rule-
class.
|
void |
methodCallVersion(java.lang.String aMethodName)
Generates the Java to call a method that implements a single version of
this rule.
|
void |
methodClose()
/** Generates "closing" code common for all versions of the rule being
assembled.
|
void |
methodFinish()
Generates the Java to complete the implementation.
|
void |
methodHeader()
Adds the access-method prototype to the primary code buffer, including
the opening brace for its definition.
|
void |
methodInit()
Generates initialization code common for all versions of the rule being
assembled.
|
void |
methodVersionFinish(int aVersion)
Generates the Java to complete a method that implements a single version
of the rule being assembled.
|
java.lang.String |
methodVersionHeader(int aVersion)
Generates method declaration for a method that implements a single
version of the rule being assembled, including the opening brace.
|
getLocalParametersName, getPagesAndClassesName, getParametersName
static final java.lang.String VERSION
static final java.lang.String COPYRIGHT
static final byte DEFERRED
methodAccess
, indicating that the
referenced Rule- will be assembled separately.static final byte PRIMARY
methodAccess
, indicating that the
implementations of the referenced Rule- will be included directly in the
primary code buffer.static final byte SUPPORT
methodAccess
, indicating that the
implementations of the referenced Rule- will be included as a separate
method in the support code buffer, invoked from the primary code buffer.java.lang.String getDefinedPrimaryPageClass()
getDefinedPrimaryPageClass
in interface GenericAssembler
java.lang.String getInterfaceName()
java.lang.String getConstructorBody()
FUAInstance
; therefore the returned
String does not contain the constructor DECLARATION. Only rule-specific initialization
logic is returned and is added to the stardard constructor body that is generated for
ALL FUA rules.null
if no specialized code needs to be added for the rule's
constructor.void methodCall(java.lang.String aMethodName, ExpressionMap aKeys)
aMethodName
- When this value is null
, the generated
call should be to the separately assembled implementation of this
reference. A non-null
value names a local method that
implements the desired processing.aKeys
- Identifies the generated Java that is to be referenced.
A value for "pxObjClass"
is required and must be a
StringExpression
for which isLiteral
is
true
. This was used to identify the implementation class
that has been selected. Any of the other values specified might require
runtime evaluation.void methodHeader()
isPrimary
.
This method might also provide variable
declarations, such as a 'result' variable, to be shared by the
alternative implementations, but it is preferred to implement the
methodInit()
method and generate that code there.
byte methodAccess(ExpressionMap aKeys)
DEFERRED
-- The referenced Rule- will be assembled
separately. Access to the processing can be provided by calling:methodCall(null, aKeys);
PRIMARY
-- The implementations of the referenced
Rule- will be included directly in the primary code buffer. This is
generally only possible when the access method does not return a value
and when any parameters can have unique names. It is recommended that
this method provide an opening brace for a compound statement to enclose
this implementation. The variables identifying any parameters should also
be defined here.SUPPORT
-- The implementation of the referenced Rule-
will be included as a separate method in the support code buffer, invoked
from the primary code buffer. If the implementation will be reusable, use
FirstUseAssembler.getMethodName()
to provide the name for the
implementing method. This will notify First-Use Assembly of its
reusability, when relevant conditions apply. The reference to the method
can be provided by calling:methodCall(
method-name,
aKeys);
When this method is called, isEmbedded()
and
isRuntime()
will both return true
.
aKeys
- Identifies the generated Java that is to be referenced. A
value for "pxObjClass"
and for each of the key
properties that value indicates is provided by a
StringExpression
for which
isLiteral
is true
; the
corresponding values are also provided in the 'keys'
StringMap
of the associated
FirstUseAssembler
instance. Additional
parameters for the method being referenced might also be
defined.DEFERRED
, PRIMARY
, or
SUPPORT
void methodBody(int aCircumstanceCount)
aCircumstanceCount
- The unique circumstance instance
which is being processed.void methodAbsent(java.lang.String aMsgDescr)
aMsgDescr
- identifies the reason that no implementation is
available. Some possible reasons are:
MultipleRuleVersionException
void methodFinish()
return
statement
when one is needed--but it is preferred to generate this statement in
a methodClose()
method.
The requirements for a particular implementation might vary
depending whether this instance isPrimary
(whether
methodHeader
or methodAccess
was used to begin
the implementation), and on the value returned by
methodAccess
when it was used.
void methodCallVersion(java.lang.String aMethodName)
This method does not need to be implemented. If it is not, then it should
throw UnsupportedOperationException
. If this method is
implemented, then all of the following methods must be implemented:
aMethodName
- the name of the method to calljava.lang.String methodVersionHeader(int aVersion)
This method does not need to be implemented. If it is not, then it should
throw UnsupportedOperationException
. If this method is
implemented, then all of the following methods must be implemented:
aVersion
- a number that uniquely identifies the version of the rule
whose implementation method is to be calledvoid methodVersionFinish(int aVersion)
methodVersionHeader(int)
with the same
argument. Normally, this method should simple emit a single closing
bracket.
This method does not need to be implemented. If it is not, then it should
throw UnsupportedOperationException
. If this method is
implemented, then all of the following methods must be implemented:
aVersion
- a number that uniquely identifies the version of the rule
whose implementation method is to be calledvoid methodInit()
methodVersionHeader(int)
with the same
argument. Normally, this method should simple emit a single closing
bracket.
This method does not need to be implemented. If it is not, then it should
throw UnsupportedOperationException
.
void methodClose()
return
statement where
applicable.
This method does not need to be implemented. If it is not, then it should
throw UnsupportedOperationException
.
Copyright © 2018 Pegasystems Inc. All Rights Reserved.