Class Overview
This class represents an IP prefix, i.e., a contiguous block of IP addresses aligned on a
power of two boundary (also known as an "IP subnet"). A prefix is specified by two pieces of
information:
- A starting IP address (IPv4 or IPv6). This is the first IP address of the prefix.
- A prefix length. This specifies the length of the prefix by specifing the number of bits
in the IP address, starting from the most significant bit in network byte order, that
are constant for all addresses in the prefix.
For example, the prefix
192.0.2.0/24
covers the 256 IPv4 addresses from
192.0.2.0
to
192.0.2.255
, inclusive, and the prefix
2001:db8:1:2
covers the 2^64 IPv6 addresses from
2001:db8:1:2::
to
2001:db8:1:2:ffff:ffff:ffff:ffff
, inclusive.
Objects of this class are immutable.
Summary
Public Methods |
int
|
describeContents()
Implement the Parcelable interface.
|
boolean
|
equals(Object obj)
Compares this IpPrefix object against the specified object in obj .
|
InetAddress
|
getAddress()
Returns a copy of the first IP address in the prefix.
|
int
|
getPrefixLength()
Returns the prefix length of this IpAddress .
|
byte[]
|
getRawAddress()
Returns a copy of the IP address bytes in network order (the highest order byte is the zeroth
element).
|
int
|
hashCode()
Gets the hashcode of the represented IP prefix.
|
void
|
writeToParcel(Parcel dest, int flags)
Implement the Parcelable interface.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
|
From interface
android.os.Parcelable
abstract
int
|
describeContents()
Describe the kinds of special objects contained in this Parcelable's
marshalled representation.
|
abstract
void
|
writeToParcel(Parcel dest, int flags)
Flatten this object in to a Parcel.
|
|
Fields
Implement the Parcelable interface.
Public Methods
public
int
describeContents
()
Implement the Parcelable interface.
Returns
- a bitmask indicating the set of special object types marshalled
by the Parcelable.
public
boolean
equals
(Object obj)
Compares this IpPrefix
object against the specified object in obj
. Two
objects are equal if they have the same startAddress and prefixLength.
Parameters
obj
| the object to be tested for equality. |
Returns
true
if both objects are equal, false
otherwise.
Returns a copy of the first IP address in the prefix. Modifying the returned object does not
change this object's contents.
Returns
- the address in the form of a byte array.
public
int
getPrefixLength
()
Returns the prefix length of this IpAddress
.
public
byte[]
getRawAddress
()
Returns a copy of the IP address bytes in network order (the highest order byte is the zeroth
element). Modifying the returned array does not change this object's contents.
Returns
- the address in the form of a byte array.
public
int
hashCode
()
Gets the hashcode of the represented IP prefix.
Returns
- the appropriate hashcode value.
public
void
writeToParcel
(Parcel dest, int flags)
Implement the Parcelable interface.
Parameters
dest
| The Parcel in which the object should be written. |
flags
| Additional flags about how the object should be written.
May be 0 or PARCELABLE_WRITE_RETURN_VALUE .
|