Class SyntacticName

  • All Implemented Interfaces:
    SyntacticTerm

    public class SyntacticName
    extends java.lang.Object
    implements SyntacticTerm
    This class represents a named SyntacticTerm. It could be either a a bound name referring to another term, possibly an expression, or a SyntacticNode. These terms are the leaves of the expression tree created using SyntacticTerm expression constructs. This mechanism could also be used for recursion, although this idea has not been completely worked out.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Chris Shaver
    Pt.AcceptedRating:
    Red
    Pt.ProposedRating:
    Red (shaver)
    • Constructor Summary

      Constructors 
      Constructor Description
      SyntacticName()
      Make named term with no reference or name.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void bind​(SyntacticTerm term)
      Bind a given term to this named term.
      java.lang.String generateCode()
      Generate the lexical representation of the term.
      java.lang.String generateDefinitionCode()
      Generate definition code for name in terms of the expression it is bound to.
      SyntacticTerm getBound()
      Get the term bound to this name.
      java.util.List<SyntacticPort> getInputs()
      Get a list of the input ports to the operator.
      java.lang.String getName()
      Get the name of the term.
      int getOrder()
      Get the sort order of the term.
      java.util.List<SyntacticPort> getOutputs()
      Get a list of output ports to the operator.
      boolean hasCode()
      Decide whether code can be generated from this term.
      java.lang.Integer inputIndex​(SyntacticPort port)
      Get the index of an input port given a reference to it.
      java.lang.Integer outputIndex​(SyntacticPort port)
      Get the index of an output port given a reference to it.
      SyntacticRank rank()
      Get the rank of the term.
      void setName​(java.lang.String name)
      Set the name of the term.
      int sizeInputs()
      Get the number of inputs to the term.
      int sizeOutputs()
      Get the number of outputs from the term.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SyntacticName

        public SyntacticName()
        Make named term with no reference or name.
    • Method Detail

      • getInputs

        public java.util.List<SyntacticPort> getInputs()
        Get a list of the input ports to the operator. If there is no kernel null is returned.
        Specified by:
        getInputs in interface SyntacticTerm
        Returns:
        list of input ports.
      • getOutputs

        public java.util.List<SyntacticPort> getOutputs()
        Get a list of output ports to the operator. If there is no kernel null is returned.
        Specified by:
        getOutputs in interface SyntacticTerm
        Returns:
        list of output ports.
      • sizeInputs

        public int sizeInputs()
        Get the number of inputs to the term.
        Specified by:
        sizeInputs in interface SyntacticTerm
        Returns:
        number of inputs or zero if no kernel.
      • sizeOutputs

        public int sizeOutputs()
        Get the number of outputs from the term.
        Specified by:
        sizeOutputs in interface SyntacticTerm
        Returns:
        number of outputs or zero if no kernel.
      • inputIndex

        public java.lang.Integer inputIndex​(SyntacticPort port)
        Get the index of an input port given a reference to it. null is returned if the port does not exist in the term or the kernel is absent.
        Specified by:
        inputIndex in interface SyntacticTerm
        Parameters:
        port - Port to find the index of.
        Returns:
        the index of the port or null if none.
      • outputIndex

        public java.lang.Integer outputIndex​(SyntacticPort port)
        Get the index of an output port given a reference to it. null is returned if the port does not exist in the term or the kernel is absent.
        Specified by:
        outputIndex in interface SyntacticTerm
        Parameters:
        port - Port to find the index of.
        Returns:
        the index of the port or null if none.
      • generateCode

        public java.lang.String generateCode()
        Generate the lexical representation of the term. Since this is a leaf of the expression tree, the term is simply the name annotated with the rank: name< rank >
        Specified by:
        generateCode in interface SyntacticTerm
        Returns:
        lexical representation of term.
      • generateDefinitionCode

        public java.lang.String generateDefinitionCode()
        Generate definition code for name in terms of the expression it is bound to. This code is of the form: node = term expression
        Returns:
        definition statement for the named term.
      • getOrder

        public int getOrder()
        Get the sort order of the term.
        Specified by:
        getOrder in interface SyntacticTerm
        Returns:
        sort order of the term.
      • hasCode

        public boolean hasCode()
        Decide whether code can be generated from this term.
        Specified by:
        hasCode in interface SyntacticTerm
        Returns:
        whether code can be generated.
      • setName

        public void setName​(java.lang.String name)
        Set the name of the term.
        Parameters:
        name - Name for the term.
        See Also:
        getName()
      • bind

        public void bind​(SyntacticTerm term)
        Bind a given term to this named term.
        Parameters:
        term - Term to bind to name.
      • getName

        public java.lang.String getName()
        Get the name of the term.
        Returns:
        name of term.
        See Also:
        setName(java.lang.String)
      • getBound

        public SyntacticTerm getBound()
        Get the term bound to this name.
        Returns:
        term bound.