MessageBuilderclass | output.t[1070] |
Superclass Tree | Subclass Tree | Global Objects | Property Summary | Method Summary | Property Details | Method Details |
id
id obj
id1/id2 obj
id1 obj/id2
The ID string gives the type of substitution to perform. The ID's all come from a table, which is specified by the language-specific subclass, so the ID's can vary by language (to allow for natural template-style parameter names for each language). If the ID is in two pieces (id1 and id2), we concatenate the two pieces together with a slash between to form the name we seek in the table - so {the/he dobj} and {the dobj/he} are equivalent, and both look up the identifier 'the/he'. If a two-part identifier is given, and the identifier isn't found in the table, we'll try looking it up with the parts reversed: if we see {he/the dobj}, we'll first try finding 'he/the', and if that fails we'll look for 'the/he'.
If 'obj' is present, it specificies the target object providing the text to be substitutued; this is a string passed to the current Action, and is usually something like 'actor', 'dobj', or 'iobj'.
One instance of this class, called langMessageBuilder, should be created by the language-specific library.
class
MessageBuilder : OutputFilter PreinitObject
MessageBuilder
OutputFilter
object
PreinitObject
ModuleExecObject
object
lastParamObj_
lastTargetObj_
nameTable_
paramList_
paramTable_
patAllCaps
patIdObj
patIdObjSlashId
patIdSlash
patUpper
Inherited from ModuleExecObject
:
execAfterMe
execBeforeMe
hasInitialized_
isDoingExec_
isExecuted_
execute
filterText
generateMessage
genLiteral
getTargetProp
langRewriteParam
processResult
quoteMessage
Inherited from ModuleExecObject
:
_execute
classExec
lastParamObj_ | output.t[1513] |
lastTargetObj_ | output.t[1510] |
nameTable_ | output.t[1519] |
paramList_ | output.t[1581] |
[entry1, entry2, entry3, ...]
Each entry is a list like this:
[paramName, &prop, impliedTargetName, <extra>]
paramName is a string giving the substitution parameter name; this can be one word or two ('the' or 'the obj', for example).
prop is a property identifier. This is the property invoked on the target object to obtain the substitution text.
impliedTargetName is a string giving the target object name to use. When this is supplied, the paramName is normally used in message text with no object name. This should be nil for parameters that do not imply a particular target.
<extra> is any number of additional parameters for the language-specific subclass. The generic code ignores these extra parameters, but the langague-specific subclass can use them if it requires additional information.
Here's an example:
paramList_ = [
['you', &theDesc, nil, 'actor'],
['the obj' &theObjDesc, &itReflexive, nil]
]
The first item specifies a substitution name of 'you', which is expanded by evaluating the property theDesc on the target object, and specifies an implied target object of 'actor'. When this is expanded, we'll call the current action to get the meaning of 'actor', then evaulate property theDesc on the result.
The second item specifies a substitution name of 'the obj', expanded by evaluating property theObjDesc on the target object. This one doesn't have an implied object, so the target object is the one explicitly given in the message source text or is the previous target object if one isn't specified in the message text.
paramTable_ | output.t[1516] |
patAllCaps | output.t[1073] |
patIdObj | output.t[1076] |
patIdObjSlashId | output.t[1074] |
patIdSlash | output.t[1077] |
patUpper | output.t[1072] |
execute ( ) OVERRIDDEN | output.t[1472] |
filterText (ostr, txt) OVERRIDDEN | output.t[1498] |
generateMessage (orig) | output.t[1084] |
genLiteral (str) | output.t[1463] |
getTargetProp (targetObj, paramObj, info) | output.t[1410] |
'targetObj' is the target object, and 'paramObj' is the parameter name of the target object. For example, 'paramObj' might be the string 'dobj' to represent the direct object, in which case 'targetObj' will be the gDobj object.
The English version, for example, uses this routine to supply a reflexive instead of the default entry when the target object matches the subject of the sentence.
langRewriteParam (paramStr) | output.t[1529] |
processResult (txt) | output.t[1442] |
The text we pass to this method has already had all parameter text fully expanded, so this routine does not need to worry about { } sequences - all { } sequences will have been removed and replaced with the corresponding expansion text before this is called.
This routine is called piecewise: the routine will be called once for each parameter replacement text and once for each run of text between parameters, and is called in the order in which the text appears in the original string.
By default we do nothing with the result text; we simply return the original text unchanged. The language-specific subclass can override this as desired to further modify the text for special language-specific parameterization outside of the { } mechanism. The subclass can also use this routine to maintain internal state that depends on sentence structure. For example, the English version looks for sentence-ending punctuation so that it can reset its internal notion of the subject of the sentence when a sentence appears to be ending.
quoteMessage (str) | output.t[1454] |
Note that only open braces need to be quoted, since lone close braces are ignored in the substitution process.