public final class MacRange extends CacheableDataType implements Comparable<MacRange>
valueOf(java.lang.String)
factory method.
A string specification is used to define the MAC address range, using the form:
{byteSpec}:{byteSpec}:{byteSpec}:{byteSpec}:{byteSpec}:{byteSpec}where byteSpec represents a single byte in the address, and is of the form:
{nn} | {nn}-{mm} | *where nn and mm are hex values in the range 00 to FF, mm (when specified) is > nn, and * stands for 00-FF.
For example, the specification "FE:00:45:01:00-03:*"
declares that
the range of MAC addresses starts with FE:00:45:01:00:00
and ends
with FE:00:45:01:03:FF
.
Modifier and Type | Field and Description |
---|---|
protected ByteArrayGenerator |
bag |
protected static String |
COLON_STAR |
protected static String |
COMMA |
protected static String |
DOT |
protected static BigInteger |
MAX_INT |
protected static BigInteger |
MAX_LONG |
protected String |
normalizedSpec |
protected String |
spec |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(MacRange o) |
boolean |
contains(com.hp.util.ip.AbstractByteRange<T> other)
Returns
true if this range is a superset of
the other range; false otherwise. |
boolean |
contains(MacAddress macAddress)
A predicate that returns
true if this range contains
the given item; false otherwise. |
static List<MacRange> |
createRanges(String commaSeparatedSpecs)
Returns a list of MAC ranges that embody the given range specifications.
|
boolean |
equals(Object o) |
MacAddress |
first()
Returns the first item in the range.
|
protected ByteArrayGenerator |
getBag(String spec)
Subclasses must return a byte array generator appropriate for the
given range specification.
|
int |
hashCode() |
boolean |
intersects(com.hp.util.ip.AbstractByteRange<T> other)
Returns
true if this range intersects
the other range; false otherwise. |
Iterator<MacAddress> |
iterator()
Returns an iterator for the range.
|
MacAddress |
last()
Returns the last item in the range.
|
MacAddress |
random()
Returns a randomly generated item that falls within this range.
|
static String |
rangeListToString(List<MacRange> ranges)
Converts a list of MAC address ranges to a comma separated string
representation.
|
BigInteger |
size()
Returns the size of the range.
|
int |
sizeAsInt()
Returns the size of the range as an integer value, unless the value
would be greater than
Integer.MAX_VALUE , in which case this
method returns -1. |
long |
sizeAsLong()
Returns the size of the range as a long value, unless the value
would be greater than
Long.MAX_VALUE , in which case this
method returns -1L. |
String |
toDebugString()
Returns a multi-line string representing the internal state of
this range.
|
String |
toString() |
static MacRange |
valueOf(MacPrefix prefix)
Returns a MAC range for the given prefix.
|
static MacRange |
valueOf(String spec)
Returns a MAC range for the given specification.
|
getRefQ, keyFromBytes
protected static final BigInteger MAX_LONG
protected static final BigInteger MAX_INT
protected static final String DOT
protected static final String COMMA
protected static final String COLON_STAR
protected final String spec
protected final String normalizedSpec
protected final transient ByteArrayGenerator bag
protected ByteArrayGenerator getBag(String spec)
spec
- the range specificationpublic boolean contains(MacAddress macAddress)
true
if this range contains
the given item; false otherwise.macAddress
- the itempublic MacAddress first()
public MacAddress last()
public MacAddress random()
public Iterator<MacAddress> iterator()
first()
and ending
with the last()
, emitting a total count of size()
items.public int compareTo(MacRange o)
compareTo
in interface Comparable<MacRange>
public static MacRange valueOf(String spec)
spec
- the MAC address range specificationpublic static MacRange valueOf(MacPrefix prefix)
MacPrefix p = MacPrefix.valueOf("11:22:33:44"); MacRange r = MacRange.valueOf(p); // 11:22:33:44:*:* MacAddress low = MacRange.first(); // 11:22:33:44:00:00 MacAddress high = MacRange.last(); // 11:22:33:44:FF:FF
prefix
- the MAC prefixpublic static List<MacRange> createRanges(String commaSeparatedSpecs)
commaSeparatedSpecs
- the comma separated list of range specspublic static String rangeListToString(List<MacRange> ranges)
createRanges(String)
.ranges
- the list of rangespublic String toDebugString()
public boolean contains(com.hp.util.ip.AbstractByteRange<T> other)
true
if this range is a superset of
the other range; false otherwise.
Put another way, the set of all items T_other
produced
by other.iterator()
is a subset of the set of all
items T_this
produced by this.iterator()
.other
- the other range to compare withIllegalArgumentException
- if other range is not the same type
as this oneNullPointerException
- if other is nullpublic boolean intersects(com.hp.util.ip.AbstractByteRange<T> other)
true
if this range intersects
the other range; false otherwise.
Put another way, the set of all items T_other
produced
by other.iterator()
contains at least one item from the set
of all items T_this
produced by this.iterator()
.other
- the other range to compare withIllegalArgumentException
- if other range is not the same type
as this oneNullPointerException
- if other is nullpublic BigInteger size()
sizeAsLong()
,
sizeAsInt()
public long sizeAsLong()
Long.MAX_VALUE
, in which case this
method returns -1L.size()
public int sizeAsInt()
Integer.MAX_VALUE
, in which case this
method returns -1.size()
Copyright © 2015. All Rights Reserved.