public class VlanId extends Object implements Comparable<VlanId>
All constructors for this class are private. Creating instances of
VlanId
is done via the static methods on the class.
Instances of this class are immutable, making them inherently threadsafe.
This class overrides equals(java.lang.Object)
and hashCode()
so that instances
play nicely with the Collection classes.
This class implements the Comparable
interface to ensure that
a sorted list of identifiers is presented in an intuitive order.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_VALUE
The maximum permissible value (4095).
|
static int |
MIN_VALUE
The minimum permissible value (0).
|
static VlanId |
NONE
A special value denoting the absence of a VLAN ID.
|
static VlanId |
PRESENT
A special value denoting the presence of a VLAN ID, without defining
the specific value.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(VlanId o) |
boolean |
equals(Object o) |
int |
hashCode() |
void |
intoBuffer(ByteBuffer b)
Writes this VLAN ID into the given
ByteBuffer at the buffer's
(as a two byte value with the top four bits set to 0). |
static String |
specialName(VlanId v)
Returns the logical name of the given VLAN ID if it is a special value;
null otherwise.
|
int |
toInt()
Returns the Virtual Network Identifier represented as an integer.
|
String |
toString()
Returns a string representation of this VLAN ID, as a decimal number.
|
static VlanId |
valueFrom(ByteBuffer buffer)
Reads 2 bytes from the specified byte buffer and creates a VLAN ID
entity from the value.
|
static VlanId |
valueOf(int value)
Returns a VLAN ID instance representing the value given by the
specified integer.
|
static VlanId |
valueOf(String value)
Returns a VLAN ID instance representing the value given by the
specified string.
|
static VlanId |
vlan(int value)
A convenience method that simply delegates to
valueOf(int) . |
public static final int MAX_VALUE
public static final int MIN_VALUE
public static final VlanId NONE
public static final VlanId PRESENT
public String toString()
public int toInt()
public void intoBuffer(ByteBuffer b)
ByteBuffer
at the buffer's
(as a two byte value with the top four bits set to 0).b
- the byte buffer to write intopublic static VlanId valueOf(int value)
value
- the valueIllegalArgumentException
- if value is not u12public static VlanId vlan(int value)
valueOf(int)
.
Included so that this method may be statically imported, such that it is easy to express VLAN IDs in code:
import static com.hp.util.ip.VlanId.vlan; ... VlanId v = vlan(3);
value
- the valueIllegalArgumentException
- if value is not u12public static VlanId valueOf(String value)
The following examples return a VLAN ID of 23:
VlanId v1 = VlanId.valueOf("23"); VlanId v2 = VlanId.valueOf("0x17");
value
- a string representing a VLAN ID numberNullPointerException
- if value is nullIllegalArgumentException
- if value is not parsable as a u12 valuepublic static VlanId valueFrom(ByteBuffer buffer)
buffer
- byte buffer from which to read the bytesBufferUnderflowException
- if the buffer does not have 2 bytes
remainingIllegalArgumentException
- if the read value is not u12public int compareTo(VlanId o)
compareTo
in interface Comparable<VlanId>
Copyright © 2015. All Rights Reserved.