com.googlecode.ipv6
Class IPv6AddressRange

java.lang.Object
  extended by com.googlecode.ipv6.IPv6AddressRange
All Implemented Interfaces:
Comparable<IPv6AddressRange>, Iterable<IPv6Address>
Direct Known Subclasses:
IPv6Network

public class IPv6AddressRange
extends Object
implements Comparable<IPv6AddressRange>, Iterable<IPv6Address>

Immutable representation of a continuous range of IPv6 addresses (bounds included).

Author:
Jan Van Besien

Method Summary
 int compareTo(IPv6AddressRange that)
           
 boolean contains(IPv6Address address)
           
 boolean contains(IPv6AddressRange range)
           
 boolean equals(Object o)
           
 IPv6AddressRange extend(IPv6Address address)
          Extend the range just enough at its head or tail such that the given address is included.
static IPv6AddressRange fromFirstAndLast(IPv6Address first, IPv6Address last)
           
 IPv6Address getFirst()
           
 IPv6Address getLast()
           
 int hashCode()
           
 Iterator<IPv6Address> iterator()
           
 boolean overlaps(IPv6AddressRange range)
           
 List<IPv6AddressRange> remove(IPv6Address address)
          Remove an address from the range, resulting in one, none or two new ranges.
 List<IPv6AddressRange> remove(IPv6Network network)
          Remove a network from the range, resulting in one, none or two new ranges.
 String toLongString()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

fromFirstAndLast

public static IPv6AddressRange fromFirstAndLast(IPv6Address first,
                                                IPv6Address last)

contains

public boolean contains(IPv6Address address)

contains

public boolean contains(IPv6AddressRange range)

overlaps

public boolean overlaps(IPv6AddressRange range)

iterator

public Iterator<IPv6Address> iterator()
Specified by:
iterator in interface Iterable<IPv6Address>
Returns:
an iterator which iterates all addresses in this range, in order.

remove

public List<IPv6AddressRange> remove(IPv6Address address)
Remove an address from the range, resulting in one, none or two new ranges. If an address outside the range is removed, this has no effect. If the first or last address is removed, a single new range is returned (potentially empty if the range only contained a single address). If an address somewhere else in the range is removed, two new ranges are returned.

Parameters:
address - adddress to remove from the range
Returns:
list of resulting ranges

extend

public IPv6AddressRange extend(IPv6Address address)
Extend the range just enough at its head or tail such that the given address is included.

Parameters:
address - address to extend the range to
Returns:
new (bigger) range

remove

public List<IPv6AddressRange> remove(IPv6Network network)
Remove a network from the range, resulting in one, none or two new ranges. If a network outside (or partially outside) the range is removed, this has no effect. If the network which is removed is aligned with the beginning or end of the range, a single new ranges is returned (potentially empty if the range was equal to the network which is removed from it). If a network somewhere else in the range is removed, two new ranges are returned.

Parameters:
network - network to remove from the range
Returns:
list of resulting ranges

toString

public String toString()
Overrides:
toString in class Object

toLongString

public String toLongString()
Returns:
like toString but without using shorthand notations for addresses

compareTo

public int compareTo(IPv6AddressRange that)
Specified by:
compareTo in interface Comparable<IPv6AddressRange>

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getFirst

public IPv6Address getFirst()

getLast

public IPv6Address getLast()


Copyright © 2012. All Rights Reserved.