Class SyntacticTermList

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<SyntacticTerm>, java.util.Collection<SyntacticTerm>, java.util.Deque<SyntacticTerm>, java.util.List<SyntacticTerm>, java.util.Queue<SyntacticTerm>, SyntacticTerm
    Direct Known Subclasses:
    SyntacticColumn, SyntacticSeries

    public class SyntacticTermList
    extends java.util.LinkedList<SyntacticTerm>
    implements SyntacticTerm
    This class is the base class for SyntacticTerms that are formed from operations on lists of other terms. Since, it extends LinkedList, it internally maintains a list of SyntacticTerms, although not semantics are given to the list other than the collective access to the ports of its elements. Additional information and structure to form an operator should override or extend the methods of this base class to correctly calculate rank, connectivity, and other combinator behaviors.
    Since:
    Ptolemy II 10.0
    Version:
    $Id$
    Author:
    Chris Shaver
    See Also:
    Serialized Form
    Pt.AcceptedRating:
    Red
    Pt.ProposedRating:
    Red (shaver)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.LinkedList<SyntacticPort> _inputs
      List of exposed input ports of constituent terms.
      protected java.util.LinkedList<SyntacticPort> _outputs
      List of exposed output ports of constituent terms.
      protected SyntacticRank _rank
      Rank of list as a term.
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      SyntacticTermList()
      Constructs an empty term list with no rank information.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void _refreshPorts()
      Refresh the port lists scanning through the terms.
      protected void _refreshRank()
      Recalculate the rank of the list as a term.
      void add​(int index, SyntacticTerm term)
      Insert a Syntactic Term in the column.
      boolean add​(SyntacticTerm term)
      Add a Syntactic Term to the column.
      boolean addAll​(java.util.Collection<? extends SyntacticTerm> terms)
      Add collection of SyntacticTerms to the list by calling the add function.
      void clear()
      Clear list along with port lists.
      java.lang.String generateCode()
      Generate code for the term.
      java.util.List<SyntacticPort> getInputs()
      Get all of the output ports for a column.
      int getOrder()
      Get the sort order of the term.
      java.util.List<SyntacticPort> getOutputs()
      Get all of the output ports for a column.
      boolean hasCode()
      Decide whether the term has code to generate.
      java.lang.Integer inputIndex​(SyntacticPort port)
      Get the index of the syntactic input port in the column.
      java.lang.Integer outputIndex​(SyntacticPort port)
      Get the index of the syntactic output port in the column.
      SyntacticRank rank()
      Get the rank of the list.
      SyntacticTerm remove​(int index)
      Remove a term at a given index.
      boolean remove​(java.lang.Object ot)
      Remove a Syntactic Term from column.
      boolean removeAll​(java.util.Collection<?> terms)
      Remove collection of SyntacticTerms to the list by calling the remove function.
      SyntacticTerm set​(int index, SyntacticTerm term)
      Overwrite a Syntactic Term in the column.
      int sizeInputs()
      Get the number of inputs to the elements of the list exposed to the outside.
      int sizeOutputs()
      Get the number of outputs to the elements of the list exposed to the outside.
      • Methods inherited from class java.util.LinkedList

        addAll, addFirst, addLast, clone, contains, descendingIterator, element, get, getFirst, getLast, indexOf, lastIndexOf, listIterator, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, push, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, size, spliterator, toArray, toArray
      • Methods inherited from class java.util.AbstractSequentialList

        iterator
      • Methods inherited from class java.util.AbstractList

        equals, hashCode, listIterator, removeRange, subList
      • Methods inherited from class java.util.AbstractCollection

        containsAll, isEmpty, retainAll, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.util.Deque

        iterator
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        containsAll, equals, hashCode, isEmpty, iterator, listIterator, replaceAll, retainAll, sort, subList
    • Field Detail

      • _inputs

        protected java.util.LinkedList<SyntacticPort> _inputs
        List of exposed input ports of constituent terms.
      • _outputs

        protected java.util.LinkedList<SyntacticPort> _outputs
        List of exposed output ports of constituent terms.
    • Constructor Detail

      • SyntacticTermList

        public SyntacticTermList()
        Constructs an empty term list with no rank information.
    • Method Detail

      • add

        public boolean add​(SyntacticTerm term)
        Add a Syntactic Term to the column. Inputs and outputs are added to the total inputs and outputs of the composition.

        This method overrides the LinkedList add().

        Specified by:
        add in interface java.util.Collection<SyntacticTerm>
        Specified by:
        add in interface java.util.Deque<SyntacticTerm>
        Specified by:
        add in interface java.util.List<SyntacticTerm>
        Specified by:
        add in interface java.util.Queue<SyntacticTerm>
        Overrides:
        add in class java.util.LinkedList<SyntacticTerm>
        Parameters:
        term - Term to add to the composition.
        Returns:
        whether node was added.
      • addAll

        public boolean addAll​(java.util.Collection<? extends SyntacticTerm> terms)
        Add collection of SyntacticTerms to the list by calling the add function. If add is overridden then this will polymorphically apply it repeatedly to collections.
        Specified by:
        addAll in interface java.util.Collection<SyntacticTerm>
        Specified by:
        addAll in interface java.util.Deque<SyntacticTerm>
        Specified by:
        addAll in interface java.util.List<SyntacticTerm>
        Overrides:
        addAll in class java.util.LinkedList<SyntacticTerm>
        Parameters:
        terms - Terms is a collection of SyntacticTerms.
        Returns:
        whether or not operation changed list.
      • removeAll

        public boolean removeAll​(java.util.Collection<?> terms)
        Remove collection of SyntacticTerms to the list by calling the remove function. If add is overridden then this will polymorphically apply it repeatedly to collections.
        Specified by:
        removeAll in interface java.util.Collection<SyntacticTerm>
        Specified by:
        removeAll in interface java.util.List<SyntacticTerm>
        Overrides:
        removeAll in class java.util.AbstractCollection<SyntacticTerm>
        Parameters:
        terms - Terms is a collection of SyntacticTerms.
        Returns:
        whether or not operation changed list.
      • add

        public void add​(int index,
                        SyntacticTerm term)
        Insert a Syntactic Term in the column. Inputs and outputs are added to the total inputs and outputs of the composition.

        This method overrides the LinkedList add().

        Specified by:
        add in interface java.util.List<SyntacticTerm>
        Overrides:
        add in class java.util.LinkedList<SyntacticTerm>
        Parameters:
        index - Index at which to add the term.
        term - Term to add to the composition.
      • remove

        public boolean remove​(java.lang.Object ot)
        Remove a Syntactic Term from column. Inputs and outputs are removed from the total inputs and outputs.

        This method overrides the LinkedList remove.

        Specified by:
        remove in interface java.util.Collection<SyntacticTerm>
        Specified by:
        remove in interface java.util.Deque<SyntacticTerm>
        Specified by:
        remove in interface java.util.List<SyntacticTerm>
        Overrides:
        remove in class java.util.LinkedList<SyntacticTerm>
        Parameters:
        ot - Term to be removed from the composition.
        Returns:
        whether term was removed.
      • clear

        public void clear()
        Clear list along with port lists.
        Specified by:
        clear in interface java.util.Collection<SyntacticTerm>
        Specified by:
        clear in interface java.util.List<SyntacticTerm>
        Overrides:
        clear in class java.util.LinkedList<SyntacticTerm>
      • set

        public SyntacticTerm set​(int index,
                                 SyntacticTerm term)
        Overwrite a Syntactic Term in the column. Inputs and outputs are added to the total inputs and outputs of the list.
        Specified by:
        set in interface java.util.List<SyntacticTerm>
        Overrides:
        set in class java.util.LinkedList<SyntacticTerm>
        Parameters:
        index - Index at which to overwrite the term.
        term - Term with which the term at the given index is replaced.
        Returns:
        term replaced.
      • remove

        public SyntacticTerm remove​(int index)
        Remove a term at a given index.
        Specified by:
        remove in interface java.util.List<SyntacticTerm>
        Overrides:
        remove in class java.util.LinkedList<SyntacticTerm>
        Parameters:
        index - Index at which to remove the term.
        Returns:
        term that has been removed.
      • getInputs

        public java.util.List<SyntacticPort> getInputs()
        Get all of the output ports for a column.
        Specified by:
        getInputs in interface SyntacticTerm
        Returns:
        A list of input ports for the column.
      • getOutputs

        public java.util.List<SyntacticPort> getOutputs()
        Get all of the output ports for a column.
        Specified by:
        getOutputs in interface SyntacticTerm
        Returns:
        A list of input ports for the column.
      • sizeInputs

        public int sizeInputs()
        Get the number of inputs to the elements of the list exposed to the outside.
        Specified by:
        sizeInputs in interface SyntacticTerm
        Returns:
        number of inputs.
      • sizeOutputs

        public int sizeOutputs()
        Get the number of outputs to the elements of the list exposed to the outside.
        Specified by:
        sizeOutputs in interface SyntacticTerm
        Returns:
        number of outputs.
      • inputIndex

        public java.lang.Integer inputIndex​(SyntacticPort port)
        Get the index of the syntactic input port in the column. If the given port is not in the inputs for the column null is returned.
        Specified by:
        inputIndex in interface SyntacticTerm
        Parameters:
        port - Port to find the index of.
        Returns:
        index of the port or null.
      • outputIndex

        public java.lang.Integer outputIndex​(SyntacticPort port)
        Get the index of the syntactic output port in the column. If the given port is not in the outputs for the column null is returned.
        Specified by:
        outputIndex in interface SyntacticTerm
        Parameters:
        port - Port to find the index of.
        Returns:
        index of the port or null.
      • generateCode

        public java.lang.String generateCode()
        Generate code for the term. In the case of this base class it is blank.
        Specified by:
        generateCode in interface SyntacticTerm
        Returns:
        string containing the code for the 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 the term has code to generate.
        Specified by:
        hasCode in interface SyntacticTerm
        Returns:
        whether the term has code to generate.
      • _refreshPorts

        protected void _refreshPorts()
        Refresh the port lists scanning through the terms.
      • _refreshRank

        protected void _refreshRank()
        Recalculate the rank of the list as a term.