OK. Thanks all. This makes sense to me now. I was trying to use some version of an absolute name (.a.b.c or a.b.c) when I already was at the top level so what I really wanted was b.c as Edward points out.

Edward A. Lee wrote:
The getEntity() method takes a name relative to the object
on which it is invoked.  Thus, a.getEntity("b.c") will return
an object with full name .a.b.c, assuming a is the top level.

Simple names ("a", "b", and "c" above) are unique only within
their container.  Full names are unique within a model.

Edward

At 09:46 AM 7/7/2008, Paul Allen wrote:
Here's a newbie question. I haven't been able to figure out how to use 
CompositeEntity.getEntity() by passing anything other than the simple name of 
the entity.

E.g. When I parse the attached workflow and ask for toplevel.getEntity("Expression6") I get back an 
entity. But, when I ask for the entity using the full name of the entity 
".parameter-writing-sample-1.Expression6" I get nothing back. Is there any possibility that 
"Expression6" won't uniquely name my entity? I assume that yes there is a possibility and so that's 
why I'm trying to use the full name of the entity instead of just the simple name.








<?xml version="1.0" standalone="no"?>
<!DOCTYPE entity PUBLIC "-//UC Berkeley//DTD MoML 1//EN"
   "http://ptolemy.eecs.berkeley.edu/xml/dtd/MoML_1.dtd";>
<entity name="parameter-writing-sample-1" 
class="ptolemy.actor.TypedCompositeActor">
   <property name="_createdBy" class="ptolemy.kernel.attributes.VersionAttribute" 
value="7.0.beta">
   </property>
   <property name="SDF Director" class="ptolemy.domains.sdf.kernel.SDFDirector">
       <property name="iterations" class="ptolemy.data.expr.Parameter" 
value="1">
       </property>
       <property name="timeResolution" class="ptolemy.moml.SharedParameter" 
value="1E-10">
       </property>
       <property name="entityId" class="org.kepler.moml.NamedObjId" 
value="urn:lsid:kepler-project.org:director:1:1">
       </property>
       <property name="class" class="ptolemy.kernel.util.StringAttribute" 
value="ptolemy.domains.sdf.kernel.SDFDirector">
           <property name="id" class="ptolemy.kernel.util.StringAttribute" 
value="urn:lsid:kepler-project.org:directorclass:1:1">
           </property>
       </property>
       <property name="semanticType00" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:1:1#Director">
       </property>
       <property name="semanticType11" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:2:1#Director">
       </property>
       <property name="_location" class="ptolemy.kernel.util.Location" value="{135, 
135}">
       </property>
   </property>
   <property name="_windowProperties" class="ptolemy.actor.gui.WindowPropertiesAttribute" 
value="{bounds={-4, -4, 1288, 998}, maximized=true}">
   </property>
   <property name="_vergilSize" class="ptolemy.actor.gui.SizeAttribute" value="[971, 
863]">
   </property>
   <property name="_vergilZoomFactor" class="ptolemy.data.expr.ExpertParameter" 
value="1.0">
   </property>
   <property name="_vergilCenter" class="ptolemy.data.expr.ExpertParameter" 
value="{485.5, 431.5}">
   </property>
   <property name="myparm" class="ptolemy.data.expr.Parameter" value="27">
       <property name="entityId" class="org.kepler.moml.NamedObjId" 
value="urn:lsid:kepler-project.org:actor:420:1">
       </property>
       <property name="class" class="ptolemy.kernel.util.StringAttribute" 
value="ptolemy.data.expr.Parameter">
           <property name="id" class="ptolemy.kernel.util.StringAttribute" 
value="urn:lsid:kepler-project.org:class:1184:1">
           </property>
       </property>
       <property name="semanticType00" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:1:1#Parameter">
       </property>
       <property name="semanticType11" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:2:1#Parameter">
       </property>
       <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
           <property name="_color" class="ptolemy.actor.gui.ColorAttribute" 
value="{0.0, 0.0, 1.0, 1.0}">
           </property>
       </property>
       <property name="_smallIconDescription" 
class="ptolemy.kernel.util.SingletonConfigurableAttribute">
           <configure>
     <svg>
       <text x="20" style="font-size:14; font-family:SansSerif; fill:blue" 
y="20">-P-</text>
     </svg>
   </configure>
       </property>
       <property name="_editorFactory" 
class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
       </property>
       <property name="_location" class="ptolemy.kernel.util.Location" value="{55, 
485}">
       </property>
   </property>
   <property name="mystringparm" class="ptolemy.data.expr.StringParameter" 
value="mystringvalue">
       <property name="entityId" class="org.kepler.moml.NamedObjId" 
value="urn:lsid:kepler-project.org:actor:421:1">
       </property>
       <property name="class" class="ptolemy.kernel.util.StringAttribute" 
value="ptolemy.data.expr.StringParameter">
           <property name="id" class="ptolemy.kernel.util.StringAttribute" 
value="urn:lsid:kepler-project.org:class:1185:1">
           </property>
       </property>
       <property name="semanticType00" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:1:1#Parameter">
       </property>
       <property name="semanticType11" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:2:1#Parameter">
       </property>
       <property name="_hideName" 
class="ptolemy.kernel.util.SingletonAttribute">
       </property>
       <property name="_icon" class="ptolemy.vergil.icon.ValueIcon">
           <property name="_color" class="ptolemy.actor.gui.ColorAttribute" 
value="{1.0, 0.0, 0.0, 1.0}">
           </property>
       </property>
       <property name="_smallIconDescription" 
class="ptolemy.kernel.util.SingletonConfigurableAttribute">
           <configure>
       <svg>
         <text x="20" style="font-size:14; font-family:SansSerif; fill:red" 
y="20">-S-</text>
       </svg>
     </configure>
       </property>
       <property name="_editorFactory" 
class="ptolemy.vergil.toolbox.VisibleParameterEditorFactory">
       </property>
       <property name="_location" class="ptolemy.kernel.util.Location" value="[55.0, 
510.0]">
       </property>
   </property>
   <property name="Annotation" 
class="ptolemy.vergil.kernel.attributes.TextAttribute">
       <property name="text" class="ptolemy.kernel.util.StringAttribute" value="This 
shows some expresssions and workflow parameters.">
       </property>
       <property name="entityId" class="org.kepler.moml.NamedObjId" 
value="urn:lsid:kepler-project.org:actor:436:1">
       </property>
       <property name="class" class="ptolemy.kernel.util.StringAttribute" 
value="ptolemy.vergil.kernel.attributes.TextAttribute">
           <property name="id" class="ptolemy.kernel.util.StringAttribute" 
value="urn:lsid:kepler-project.org:class:1199:1">
           </property>
       </property>
       <property name="semanticType00" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:1:1#DocumentationActor">
       </property>
       <property name="semanticType11" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:2:1#WorkflowDocumentation">
       </property>
       <property name="_location" class="ptolemy.kernel.util.Location" value="{75, 
70}">
       </property>
   </property>
   <entity name="Expression6" class="ptolemy.actor.lib.Expression">
       <property name="expression" class="ptolemy.kernel.util.StringAttribute" 
value="&quot;mystringparm = &quot; + mystringparm + &quot;; myparm = &quot; + myparm">
           <property name="_hide" class="ptolemy.data.expr.Parameter" 
value="true">
           </property>
       </property>
       <property name="entityId" class="org.kepler.moml.NamedObjId" 
value="urn:lsid:kepler-project.org:actor:75:1">
       </property>
       <property name="class" class="ptolemy.kernel.util.StringAttribute" 
value="ptolemy.actor.lib.Expression">
           <property name="id" class="ptolemy.kernel.util.StringAttribute" 
value="urn:lsid:kepler-project.org:class:950:1">
           </property>
       </property>
       <property name="semanticType00" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:1:1#MathOperationActor">
       </property>
       <property name="semanticType11" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:2:1#GeneralPurpose">
       </property>
       <property name="_icon" class="ptolemy.vergil.icon.BoxedValueIcon">
           <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" 
value="expression">
           </property>
           <property name="displayWidth" class="ptolemy.data.expr.Parameter" 
value="60">
           </property>
       </property>
       <property name="_location" class="ptolemy.kernel.util.Location" value="[205.0, 
395.0]">
       </property>
   </entity>
   <entity name="File Writer" class="org.geon.FileWrite">
       <property name="fileName" class="ptolemy.actor.parameters.FilePortParameter" 
value="parameter.txt">
       </property>
       <property name="append" class="ptolemy.data.expr.Parameter" 
value="false">
       </property>
       <property name="confirmOverwrite" class="ptolemy.data.expr.Parameter" 
value="true">
       </property>
<property name="KeplerDocumentation" 
class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
<property name="description" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>No 
author given</configure></property>
<property name="version" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
<property name="userLevelDocumentation" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The FileWriter actor reads a 
string and writes it to a file. The actor outputs the file path of the generated file.</p>

<p>Specify a destination file path with the fileName parameter. If the specified file 
does not exist, then the actor will create it.  If the file already exists, then the actor 
will ask for permission to overwrite it (unless the append parameter is selected, in which 
case the new content is appended to the existing content).</p>

<p>The actor is similar to the LineWriter, except that the FileWriter outputs the 
generated file path, while the LineWriter actor does not. FileWriter is also similar to 
TextFileWriter, except that the FileWriter actor adds line breaks, while the TextFileWriter 
does not.</p>
</configure></property>
<property name="port:input" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An 
input port that receives a string to write to a file.</configure></property>
<property name="port:url" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>An 
output port that broadcasts the file name of the generated file.</configure></property>
<property name="prop:append" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify whether to append the input string 
to an existing, specified file. By default, the actor will overwrite any preexisting 
file.</configure></property>
<property name="prop:confirmOverwrite" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Specify whether the actor should confirm 
before overwriting an existing file. By default, the actor will not ask for confirmation.</configure></property>
<property name="prop:fileName" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The name of the file to which to write. See 
FileParameter for more information about specifying file names. </configure></property>
</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" 
value="urn:lsid:kepler-project.org:actor:144:1">
       </property>
       <property name="class" class="ptolemy.kernel.util.StringAttribute" 
value="org.geon.FileWrite">
           <property name="id" class="ptolemy.kernel.util.StringAttribute" 
value="urn:lsid:kepler-project.org:class:1003:1">
           </property>
       </property>
       <property name="semanticType00" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:1:1#WriterOutputActor">
       </property>
       <property name="semanticType11" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:2:1#LocalOutput">
       </property>
       <property name="_location" class="ptolemy.kernel.util.Location" value="[530.0, 
285.0]">
       </property>
       <property name="" class="ptolemy.vergil.basic.DocAttribute">
           <property name="author" class="ptolemy.kernel.util.StringAttribute" 
value="No author given">
           </property>
           <property name="version" class="ptolemy.kernel.util.StringAttribute" 
value="null">
           </property>
           <property name="since" class="ptolemy.kernel.util.StringAttribute">
           </property>
           <property name="description" class="ptolemy.data.expr.StringParameter" value="&lt;p&gt;The FileWriter actor reads a string and writes it 
to a file. The actor outputs the file path of the generated file.&lt;/p&gt;&#10;&#10;&lt;p&gt;Specify a destination file path with the fileName parameter. If 
the specified file does not exist, then the actor will create it.  If the file already exists, then the actor will ask for permission to overwrite it (unless the append parameter is 
selected, in which case the new content is appended to the existing content).&lt;/p&gt;&#10;&#10;&lt;p&gt;The actor is similar to the LineWriter, except that 
the FileWriter outputs the generated file path, while the LineWriter actor does not. FileWriter is also similar to TextFileWriter, except that the FileWriter actor adds line breaks, 
while the TextFileWriter does not.&lt;/p&gt;&#10;">
           </property>
           <property name="input (port)" class="ptolemy.kernel.util.StringAttribute" 
value="An input port that receives a string to write to a file.">
           </property>
           <property name="url (port)" class="ptolemy.kernel.util.StringAttribute" 
value="An output port that broadcasts the file name of the generated file.">
           </property>
           <property name="append (parameter)" class="ptolemy.data.expr.StringParameter" 
value="Specify whether to append the input string to an existing, specified file. By default, the actor will 
overwrite any preexisting file.">
           </property>
           <property name="confirmOverwrite (parameter)" 
class="ptolemy.data.expr.StringParameter" value="Specify whether the actor should confirm before 
overwriting an existing file. By default, the actor will not ask for confirmation.">
           </property>
           <property name="fileName (parameter)" class="ptolemy.data.expr.StringParameter" 
value="The name of the file to which to write. See FileParameter for more information about specifying file 
names. ">
           </property>
       </property>
   </entity>
   <entity name="Monitor Value" class="ptolemy.actor.lib.MonitorValue">
<property name="KeplerDocumentation" 
class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
<property name="description" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward 
A. Lee</configure></property>
<property name="version" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
<property name="userLevelDocumentation" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The MonitorValue actor displays a received 
value on the Workflow canvas. The actor accepts tokens of any type and stores the most recently received token in its value parameter, 
which is displayed on the Workflow canvas.</p></configure></property>
<property name="port:input" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A 
multiport that accepts tokens of any type. </configure></property>
<property name="prop:value" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The most recent input value. The value is 
displayed on the Workflow canvas, and has the same type as the input.</configure></property>
</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" 
value="urn:lsid:kepler-project.org:actor:8:1">
       </property>
       <property name="class" class="ptolemy.kernel.util.StringAttribute" 
value="ptolemy.actor.lib.MonitorValue">
           <property name="id" class="ptolemy.kernel.util.StringAttribute" 
value="urn:lsid:kepler-project.org:class:884:1">
           </property>
       </property>
       <property name="semanticType00" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:1:1#TextualOutputActor">
       </property>
       <property name="semanticType11" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:2:1#TextualOutput">
       </property>
       <property name="displayWidth" class="ptolemy.data.expr.Parameter" 
value="60">
       </property>
       <property name="_icon" class="ptolemy.vergil.icon.UpdatedValueIcon">
           <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" 
value="value">
           </property>
           <property name="displayWidth" class="ptolemy.data.expr.Parameter" 
value="displayWidth">
           </property>
       </property>
       <property name="_location" class="ptolemy.kernel.util.Location" value="[600.0, 
210.0]">
       </property>
   </entity>
   <entity name="Monitor Value2" class="ptolemy.actor.lib.MonitorValue">
<property name="KeplerDocumentation" 
class="ptolemy.vergil.basic.KeplerDocumentationAttribute">
<property name="description" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
<property name="author" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>Edward 
A. Lee</configure></property>
<property name="version" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure>null</configure></property>
<property name="userLevelDocumentation" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure><p>The MonitorValue actor displays a received 
value on the Workflow canvas. The actor accepts tokens of any type and stores the most recently received token in its value parameter, 
which is displayed on the Workflow canvas.</p></configure></property>
<property name="port:input" class="ptolemy.kernel.util.ConfigurableAttribute"><configure>A 
multiport that accepts tokens of any type. </configure></property>
<property name="prop:value" 
class="ptolemy.kernel.util.ConfigurableAttribute"><configure>The most recent input value. The value is 
displayed on the Workflow canvas, and has the same type as the input.</configure></property>
</property>        <property name="entityId" class="org.kepler.moml.NamedObjId" 
value="urn:lsid:kepler-project.org:actor:8:1">
       </property>
       <property name="class" class="ptolemy.kernel.util.StringAttribute" 
value="ptolemy.actor.lib.MonitorValue">
           <property name="id" class="ptolemy.kernel.util.StringAttribute" 
value="urn:lsid:kepler-project.org:class:884:1">
           </property>
       </property>
       <property name="semanticType00" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:1:1#TextualOutputActor">
       </property>
       <property name="semanticType11" class="org.kepler.sms.SemanticType" 
value="urn:lsid:localhost:onto:2:1#TextualOutput">
       </property>
       <property name="displayWidth" class="ptolemy.data.expr.Parameter" 
value="50">
       </property>
       <property name="_icon" class="ptolemy.vergil.icon.UpdatedValueIcon">
           <property name="attributeName" class="ptolemy.kernel.util.StringAttribute" 
value="value">
           </property>
           <property name="displayWidth" class="ptolemy.data.expr.Parameter" 
value="displayWidth">
           </property>
       </property>
       <property name="_location" class="ptolemy.kernel.util.Location" value="[695.0, 
475.0]">
       </property>
   </entity>
   <relation name="relation" class="ptolemy.actor.TypedIORelation">
       <property name="width" class="ptolemy.data.expr.Parameter" value="1">
       </property>
       <vertex name="vertex1" value="[195.0, 315.0]">
       </vertex>
   </relation>
   <relation name="relation2" class="ptolemy.actor.TypedIORelation">
       <property name="width" class="ptolemy.data.expr.Parameter" value="1">
       </property>
   </relation>
   <link port="Expression6.output" relation="relation"/>
   <link port="File Writer.input" relation="relation"/>
   <link port="File Writer.url" relation="relation2"/>
   <link port="Monitor Value.input" relation="relation"/>
   <link port="Monitor Value2.input" relation="relation2"/>
</entity>

------------ Edward A. Lee
Robert S. Pepper Distinguished Professor
EECS Dept., 545Q Cory Hall, UC Berkeley, Berkeley, CA 94720-1770
phone: 510-642-0253, fax: 510-642-2845
[EMAIL PROTECTED], http://www.eecs.berkeley.edu/Faculty/Homepages/lee.html

Reply via email to