info.bioinfweb.jphyloio.events

## Class EdgeEvent

- java.lang.Object
- - info.bioinfweb.jphyloio.events.ConcreteJPhyloIOEvent
  - - info.bioinfweb.jphyloio.events.LabeledEvent
    - - info.bioinfweb.jphyloio.events.LabeledIDEvent
      - - info.bioinfweb.jphyloio.events.EdgeEvent

- All Implemented Interfaces:
    JPhyloIOEvent

      public class EdgeEvent
      extends LabeledIDEvent

  Event indicating an edge in a tree or network. Edges are directed and connect a source node with a target node, which are references by their IDs. If an edge represents a root of a tree or network, its source node ID reference is `null`. All referenced nodes must have been defined in the event stream before this event is fired.

  This event is a start event, which is followed by an end event of the same content type. Comment and metainformation events maybe nested between this and its according end event. (See the description of `JPhyloIOEventReader` for the complete grammar definition of JPhyloIO event streams.)

  Author:
    Ben Stöver

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `EdgeEvent(java.lang.String id, java.lang.String label, java.lang.String targetID, double length)` Creates a new instance of this class that represents a root edge.
    `EdgeEvent(java.lang.String id, java.lang.String label, java.lang.String sourceID, java.lang.String targetID, double length)` Creates a new instance of this class that represents an internal edge or a root edge.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `getLength()` Returns the length of this edge.
    `java.lang.String` | `getSourceID()` Returns the ID of the source node linked by this edge.
    `java.lang.String` | `getTargetID()` Returns the ID of the target node linked by this edge.
    `boolean` | `hasLength()` Indicates whether this edge has a defined length.
    `boolean` | `hasSource()` Indicates whether this edge has a source node and can therefore be considered a root edge.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class info.bioinfweb.jphyloio.events.LabeledIDEvent

      `checkID, getID`

    - ### Methods inherited from class info.bioinfweb.jphyloio.events.LabeledEvent

      `getLabel, hasLabel`

    - ### Methods inherited from class info.bioinfweb.jphyloio.events.ConcreteJPhyloIOEvent

      `asCharacterDefinitionEvent, asCharacterSetIntervalEvent, asCommentEvent, asEdgeEvent, asLabeledIDEvent, asLinkedLabeledIDEvent, asLiteralMetadataContentEvent, asLiteralMetadataEvent, asNodeEvent, asPartEndEvent, asResourceMetadataEvent, asSequenceTokensEvent, asSetElementEvent, asSingleSequenceTokenEvent, asSingleTokenDefinitionEvent, asTokenSetDefinitionEvent, asUnknownCommandEvent, createEndEvent, getType`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### EdgeEvent

          public EdgeEvent(java.lang.String id,
                           java.lang.String label,
                           java.lang.String sourceID,
                           java.lang.String targetID,
                           double length)

      Creates a new instance of this class that represents an internal edge or a root edge. If `sourceID` is `null` the content type will be `EventContentType.ROOT_EDGE` and otherwise it will be `EventContentType.EDGE`.
      Parameters:
        `id` - the unique ID associated with the represented edge (Must be a valid NCName.)
        `label` - an optional label associated with this edge (Maybe `null`.)
        `sourceID` - the ID of the source node of this edge (Maybe `null` if a root edge shall be created.)
        `targetID` - the ID of the target node of this edge
        `length` - an optional lengths of this edge (Maybe `Double.NaN` if no length is given.)
      Throws:
        `java.lang.NullPointerException` - if `id`, `sourceID` or `targetID` are `null`
        `java.lang.IllegalArgumentException` - if `id`, `sourceID` or `targetID` are not a valid NCNames

    - #### EdgeEvent

          public EdgeEvent(java.lang.String id,
                           java.lang.String label,
                           java.lang.String targetID,
                           double length)

      Creates a new instance of this class that represents a root edge.
      Parameters:
        `id` - the unique ID associated with the represented edge (Must be a valid NCName.)
        `label` - an optional label associated with this edge (Maybe `null`.)
        `targetID` - the ID of the target node of this edge
        `length` - an optional lengths of this edge (Maybe `Double.NaN` if no length is given.)
      Throws:
        `java.lang.NullPointerException` - if `id` or `targetID` are `null`
        `java.lang.IllegalArgumentException` - if `id` or `targetID` are not a valid NCNames

  - ### Method Detail

    - #### getSourceID

          public java.lang.String getSourceID()

      Returns the ID of the source node linked by this edge.
      Returns:
        the ID of the source node or `null` if this event represents a root edge
      See Also:
        `hasSource()`

    - #### hasSource

          public boolean hasSource()

      Indicates whether this edge has a source node and can therefore be considered a root edge.

      If this method returns `true`, `getSourceID()` will return `null`.

      Returns:
        `true` if this edge has a source node or `false` otherwise

    - #### getTargetID

          public java.lang.String getTargetID()

      Returns the ID of the target node linked by this edge.
      Returns:
        the ID of the target node (never `null`)

    - #### getLength

          public double getLength()

      Returns the length of this edge.

      Additional information (e.g. on length confidence intervals) maybe given in upcoming nested metaevents.

      Returns:
        the length of this edge or `Double.NaN` if this edge does not have a defined length

    - #### hasLength

          public boolean hasLength()

      Indicates whether this edge has a defined length.

      If this method returns `false`, `getLength()` will return `Double#NaN`.

      Returns:
        `true` if this edge has a defined length or `false` otherwise

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`