[kepler-dev] Actor's class name?

DONGHOON KIM dhkim717 at gmail.com
Mon Nov 17 11:06:24 PST 2014


Hi Christopher,

Thank you for your answers to my questions!

What about the name of the container (i.e., _container)?
When I debugged, I have found that the value of " _container" (red box in
the attached pic) is "StringConst".
If this value is also unique, I want to extract this value instead of the
full qualified classname.
lastIndexOf() may need extra work to extract the value "StringConst".
Do you know any other function to extract the value "StringConst"? maybe...
getUnderBarContainer.
but I can not find that function in source code.

Please, let me know

Thank you

-Donghoon






On Mon, Nov 17, 2014 at 1:35 PM, Christopher Brooks <cxh at eecs.berkeley.edu>
wrote:

>  Hi Donghoon,
>
> In Java, the fully qualified classname must be unique.  There is some
> magic that can be done with different class loaders and such, but in
> general, and in Kepler and Ptolemy, the fully qualified classname will be
> unique.  The fully qualified classname includes the package,  So,
> ptolemy.actor.lib.StringConstant is one actor.   There can be another
> actor, ptolemy.actor.lib.mypackage.StringConstant.  Both actors could be
> used in a model.
>
> Note that Kepler has actor oriented classes (see
> http://ptolemy.eecs.berkeley.edu/publications/papers/07/classesandInheritance/index.htm).
> The quick summary of actor oriented classes is that they are chunks of
> functionality implemented as Ptolemy models that can be reused by
> instantiation or subclassing.  The Sinewave actor is an actor-oriented
> class.  When you are calling parameter.getContainer().getClassName(), you
> are getting the className which may or may not be the same as the Java
> class name.
>
> Probably the method that is being called is in
> ptolemy/kernel/util/NamedObj.java:
>
>    /** Return the MoML class name.  This is either
> the
>      *  class of which this object is an instance, or if
> this
>      *  object is itself a class, then the class that it
> extends.
>      *  By default, it will be the Java class name of this
> object.
>      *  This method never returns
> null.
>
>      *  @return The MoML class
> name.
>
>      *  @see
> MoMLExportable
>
>      *  @see
> #setClassName(String)
>
>      */
>     @Override
>     public String getClassName() {
>     if (_className == null) {
>             _className = getClass().getName();
>         }
>
>         return _className;
>     }
>
>
> _className is set when instantiating clones for actor-oriented classes.
>
>
> To get the last part of the fully qualified classname, see the
> lastIndexOf() method in the java.lang.String class:
> https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#lastIndexOf-int
> -
>
> However, I think you just want to call NamedObj.getName():
> parameter.getContainer().getName() should do the trick.
>
> _Christopher
>
>
> On 11/17/14 9:47 AM, DONGHOON KIM wrote:
>
> Dear Kepler folks,
>
>  In ActorReference.pdf file, there are explanations of each actors.  I
> have questions for this reference.
>
>    - I can see the class name next to an actor. For example, String
>    Constant (ptolemy.actor.lib.StringConst). The class name must be unique
>    (i.e., ptolemy.actor.lib.StringConst). If so, is the last classname unique?
>    In other words, "StringConst" is also unique?
>    - I can see the value of "StringConst" in _container in parameter
>    class. How can I just extract only last name "StringConst"? Actually, I
>    have tried several ways in SQLRecording.java like below:
>       -  System.out.println("3: " +
>       parameter.getContainer().toplevel().toString());
>       -  System.out.println("4: " +
>       parameter.getContainer().getClassName());
>       -  System.out.println("5: " + parameter.getContainer());
>
>  The output is :
>
>
>     - 3: ptolemy.actor.TypedCompositeActor {.Unnamed1}
>       - 4: ptolemy.actor.lib.StringConst
>       - 5: ptolemy.actor.lib.StringConst {.Unnamed1.DonghoonConstant}
>
> Please, let me know
>
>  Thank you
>
>  -Donghoon
>
>
>  --
> Donghoon Kim
> Dept of Computer Science
> North Carolina State University
>
>
>
>
> _______________________________________________
> Kepler-dev mailing listKepler-dev at kepler-project.orghttp://lists.nceas.ucsb.edu/kepler/mailman/listinfo/kepler-dev
>
>
>
> --
> Christopher Brooks, PMP                       University of California
> Academic Program Manager & Software Engineer  US Mail: 337 Cory Hall
> CHESS/iCyPhy/Ptolemy/TerraSwarm               Berkeley, CA 94720-1774cxh at eecs.berkeley.edu, 707.332.0670           (Office: 545Q Cory)
>
>


-- 
Donghoon Kim
Dept of Computer Science
North Carolina State University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-dev/attachments/20141117/88edff7c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: container_question.png
Type: image/png
Size: 118679 bytes
Desc: not available
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-dev/attachments/20141117/88edff7c/attachment-0001.png>


More information about the Kepler-dev mailing list