001/* An object representing a link between a port and a relation.
002
003 Copyright (c) 2000-2014 The Regents of the University of California.
004 All rights reserved.
005 Permission is hereby granted, without written agreement and without
006 license or royalty fees, to use, copy, modify, and distribute this
007 software and its documentation for any purpose, provided that the above
008 copyright notice and the following two paragraphs appear in all copies
009 of this software.
010
011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
015 SUCH DAMAGE.
016
017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
022 ENHANCEMENTS, OR MODIFICATIONS.
023
024 PT_COPYRIGHT_VERSION_2
025 COPYRIGHTENDKEY
026
027 */
028package ptolemy.vergil.kernel;
029
030import ptolemy.kernel.ComponentRelation;
031
032//////////////////////////////////////////////////////////////////////////
033//// Link
034
035/**
036 Instances of this class represent a link between a port and a
037 relation, between two relations,
038 or a between two ports.  In the first two cases,
039 the relations are represented by an explicit node in the graph.  In the
040 third case, there is no explicit node representing the relation and
041 the edge runs directly from one port to the other.  Connections are made
042 and broken by the graph model depending on
043 which of the above contexts the link is being used in.
044
045 @author Steve Neuendorffer
046 @version $Id$
047 @since Ptolemy II 2.0
048 @Pt.ProposedRating Red (eal)
049 @Pt.AcceptedRating Red (johnr)
050 */
051public class Link {
052    /** Return the head of this link.   This may be a port, or a vertex
053     *  in a relation.
054     *  @return The head of this link.
055     *  @see #setHead(Object)
056     */
057    public Object getHead() {
058        return _head;
059    }
060
061    /** Return the relation that this link represents.  If the link goes
062     *  from a port to a port, then this is the only way to get at the
063     *  relation.  If the link goes from a vertex to a port, then the
064     *  relation will be the container of the vertex.
065     *  @return The relation that this link represents.
066     *  @see #setRelation(ComponentRelation)
067     */
068    public ComponentRelation getRelation() {
069        return _relation;
070    }
071
072    /** Return the tail of this link.   This may be a port, or a vertex
073     *  in a relation.
074     *  @return The tail of this link.
075     *  @see #setTail(Object)
076     */
077    public Object getTail() {
078        return _tail;
079    }
080
081    /** Set the head of this link.   This may be a port, or a vertex
082     *  in a relation.
083     *  @param head The head.
084     *  @see #getHead()
085     */
086    public void setHead(Object head) {
087        _head = head;
088    }
089
090    /** Set the relation for this link.
091     *  @param relation The relation.
092     *  @see #getRelation()
093     */
094    public void setRelation(ComponentRelation relation) {
095        _relation = relation;
096    }
097
098    /** Set the tail of this link.   This may be a port, or a vertex
099     *  in a relation.
100     *  @param tail The tail.
101     *  @see #getTail()
102     */
103    public void setTail(Object tail) {
104        _tail = tail;
105    }
106
107    /** Return a string representation of this link.
108     *  @return A string representation of this link.
109     */
110    @Override
111    public String toString() {
112        return "Link(" + _head + ", " + _tail + ", " + _relation + ")";
113    }
114
115    private Object _head;
116
117    private Object _tail;
118
119    private ComponentRelation _relation;
120}