[kepler-dev] references to Java properties from within StringParameter entry fields
Christopher Brooks
cxh at eecs.berkeley.edu
Thu May 28 12:23:54 PDT 2009
Hi Tim,
Try using a regular parameter instead of a parameter in string mode.
StringParameter extends Parameter, Parameter extends Variable.
StringParameter merely calls setStringMode(), which Variable
uses to determine which parser is used.
PtParser.jjt says:
/** Generates a parse tree from the given String, which is interpreted
* in "String Mode" instead of as an operator expression. In
* string mode, the expression is a literal string, except for
* identifiers which are denoted by $param. The root node is
* returned. To evaluate the parse tree, use a ParseTreeEvaluator.
* @param stringIn The expression to be parsed.
* @exception IllegalActionException If the parse fails.
* @return The root node of the parse tree.
*/
public ASTPtRootNode generateStringParseTree(String stringIn)
So, what you want is a regular Parameter, which should expand
property() properly.
_Christopher
Timothy McPhillips wrote:
> Hi Christopher,
>
> Is there a convenient way to access the values of Java properties from
> within the entry field for a StringParameter?
>
> For a plain Parameter it appears one can refer to Java properties in
> this manner:
>
> Image:
> property("KEPLER")+"/demos/getting-started/species-distribution.jpg"
>
> But this requires using quotes to signify a string value. In a
> StringParameter one can refer to the values of other Variables in scope
> (e.g., a Parameter defined on the workflow canvas) using the $ symbol,
> and no quotes are needed. For example, if I define a Parameter on the
> canvas named 'Directory' that refers to the value of the Java property
> 'COMAD_TESTS':
>
> Directory: property("COMAD_TESTS")
>
> ..then in a StringParameter of an actor on that canvas I can refer to
> the value of that Directory parameter:
>
> File: $Directory/test-files/TestCollectionReader_new.xml
>
> What I can't seem to do is refer to the Java property directly in the
> entry for the StringParameter, e.g. entering
>
> $property("COMAD_TESTS")/test-files/TestCollectionReader_new.xml
>
> gives the exception:
>
> ptolemy.kernel.util.IllegalActionException: Error evaluating expression:
> $property("COMAD_TESTS")/test-files/TestCollectionReader_new.xml
> in .TestCollectionReader_test.CollectionReader_New.File
> Because:
> The ID property is undefined.
>
>
> Is there an easy way to do this?
>
> Thanks!
>
> Tim
>
>
>
>
--
Christopher Brooks (cxh at eecs berkeley edu) University of California
CHESS Executive Director US Mail: 337 Cory Hall
Programmer/Analyst CHESS/Ptolemy/Trust Berkeley, CA 94720-1774
ph: 510.643.9841 fax:510.642.2718 (Office: 545Q Cory)
home: (F-Tu) 707.665.0131 (W-F) 510.655.5480
More information about the Kepler-dev
mailing list