SSF.OS.BGP4.Path
Class Segment

java.lang.Object
  |
  +--SSF.OS.BGP4.Path.Segment
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable

public class Segment
extends java.lang.Object
implements java.io.Externalizable

An AS path segment. A path segment is a grouping of ASes (indicated by NHI address prefix) which comprises a portion of an AS path. A segment can either be an unordered set of ASes or an ordered sequence of ASes.

See Also:
Serialized Form

Field Summary
 java.util.ArrayList asnhs
          The AS NHI prefix addresses which make up this segment of the path.
static int SEQ
          Indicates a segment type of AS_SEQUENCE, meaning that the ASes in the segment are ordered.
static int SET
          Indicates a segment type of AS_SET, meaning that the ASes in the segment are not ordered.
 int typ
          The type of the path segment.
 
Constructor Summary
Segment()
          Empty constructor.
Segment(int ty, java.util.ArrayList asn)
          Generic constructor for initializing member data.
Segment(Segment seg)
          Constructs a path segment based on another one.
 
Method Summary
 void append_as(java.lang.String asnh)
          Adds an AS NHI prefix address to the end of the list.
 boolean contains(java.lang.String asnh)
          Determines whether or not this path segment contains a given AS.
 boolean equals(Segment seg)
          Returns true only if the two path segments are equivalent.
 void prepend_as(java.lang.String asnh)
          Adds an AS NHI prefix address to the beginning of the list.
 void readExternal(java.io.DataInput in)
          Reads the contents of this object from a serialization stream.
 void readExternal(java.io.ObjectInput in)
           
 int size()
          Returns the number of ASes in this path segment.
 java.lang.String toMinString()
          Returns this path segment as a string, leaving out set/sequence info.
 java.lang.String toMinString(char sepchar, boolean usenhi)
          Returns this path segment as a string, leaving out set/sequence info.
 java.lang.String toString()
          Returns this path segment as a string.
 void writeExternal(java.io.DataOutput out)
          Writes the contents of this object to a serialization stream.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SET

public static final int SET
Indicates a segment type of AS_SET, meaning that the ASes in the segment are not ordered.

See Also:
Constant Field Values

SEQ

public static final int SEQ
Indicates a segment type of AS_SEQUENCE, meaning that the ASes in the segment are ordered. Those closer to the beginning of the list (lower indices) have been added more recently.

See Also:
Constant Field Values

typ

public int typ
The type of the path segment. Either an unordered (set) or ordered (sequence) group of ASes.


asnhs

public java.util.ArrayList asnhs
The AS NHI prefix addresses which make up this segment of the path.

Constructor Detail

Segment

public Segment()
Empty constructor. Used to deserialize this object.


Segment

public Segment(int ty,
               java.util.ArrayList asn)
Generic constructor for initializing member data.

Parameters:
ty - The type of the path segment.
asn - The AS NHI prefix addresses making up the path segment.

Segment

public Segment(Segment seg)
Constructs a path segment based on another one.

Method Detail

size

public final int size()
Returns the number of ASes in this path segment.

Returns:
the number of ASes in this path segment

contains

public boolean contains(java.lang.String asnh)
Determines whether or not this path segment contains a given AS.

Parameters:
asnh - The NHI prefix of the AS to look for in this segment.
Returns:
true only if the AS is in this segment

prepend_as

public final void prepend_as(java.lang.String asnh)
Adds an AS NHI prefix address to the beginning of the list.


append_as

public final void append_as(java.lang.String asnh)
Adds an AS NHI prefix address to the end of the list.

Parameters:
asnh - The AS NHI prefix address to append to this segment.

equals

public boolean equals(Segment seg)
Returns true only if the two path segments are equivalent. This means that if it is a sequence, the AS NHI prefix addresses must be in the same order, but if it is a set, they need not be in the same order.

Parameters:
seg - The path segment to compare with this one.
Returns:
true if either of two cases holds: (1) the segments are both sequences and have identical lists of AS NHI prefix addresses or (2) the segments are both sets and contain exactly the same AS NHI prefix addresses, not necessarily in the same order

toMinString

public final java.lang.String toMinString(char sepchar,
                                          boolean usenhi)
Returns this path segment as a string, leaving out set/sequence info.

Parameters:
sepchar - The character used to separate ASes in the string.
usenhi - Whether to show ASes as NHI address prefixes or numbers
Returns:
the path segment as a string of ASes

toMinString

public final java.lang.String toMinString()
Returns this path segment as a string, leaving out set/sequence info.

Returns:
the path segment as a string of ASes

toString

public final java.lang.String toString()
Returns this path segment as a string.

Overrides:
toString in class java.lang.Object
Returns:
the path segment as a string

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
java.io.IOException

writeExternal

public void writeExternal(java.io.DataOutput out)
                   throws java.io.IOException
Writes the contents of this object to a serialization stream.

Throws:
java.io.IOException - if there's an error writing the data

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException

readExternal

public void readExternal(java.io.DataInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Reads the contents of this object from a serialization stream.

Throws:
java.io.IOException - if there's an error reading in the data
java.lang.ClassNotFoundException - if a class name is unrecognized