IpPrefix
public
final
class
IpPrefix
extends Object
implements
Parcelable
| java.lang.Object | |
| ↳ | android.net.IpPrefix |
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.
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
Inherited constants |
|---|
From
interface
android.os.Parcelable
|
Fields | |
|---|---|
public
static
final
Creator<IpPrefix> |
CREATOR
Implement the Parcelable interface. |
Public methods | |
|---|---|
boolean
|
contains(InetAddress address)
Determines whether the prefix contains the specified address. |
int
|
describeContents()
Implement the Parcelable interface. |
boolean
|
equals(Object obj)
Compares this |
InetAddress
|
getAddress()
Returns a copy of the first IP address in the prefix. |
int
|
getPrefixLength()
Returns the prefix length of this |
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. |
String
|
toString()
Returns a string representation of this |
void
|
writeToParcel(Parcel dest, int flags)
Implement the Parcelable interface. |
Inherited methods | |
|---|---|
From
class
java.lang.Object
| |
From
interface
android.os.Parcelable
| |
Fields
Public methods
contains
boolean contains (InetAddress address)
Determines whether the prefix contains the specified address.
| Parameters | |
|---|---|
address |
InetAddress:
An InetAddress to test. |
| Returns | |
|---|---|
boolean |
true if the prefix covers the given address.
|
describeContents
int describeContents ()
Implement the Parcelable interface.
| Returns | |
|---|---|
int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. |
equals
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 |
Object:
the object to be tested for equality. |
| Returns | |
|---|---|
boolean |
true if both objects are equal, false otherwise.
|
getAddress
InetAddress getAddress ()
Returns a copy of the first IP address in the prefix. Modifying the returned object does not change this object's contents.
| Returns | |
|---|---|
InetAddress |
the address in the form of a byte array. |
getPrefixLength
int getPrefixLength ()
Returns the prefix length of this IpPrefix.
| Returns | |
|---|---|
int |
the prefix length. |
getRawAddress
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 | |
|---|---|
byte[] |
the address in the form of a byte array. |
hashCode
int hashCode ()
Gets the hashcode of the represented IP prefix.
| Returns | |
|---|---|
int |
the appropriate hashcode value. |
toString
String toString ()
Returns a string representation of this IpPrefix.
| Returns | |
|---|---|
String |
a string such as "192.0.2.0/24" or "2001:db8:1:2::/64".
|
writeToParcel
void writeToParcel (Parcel dest, int flags)
Implement the Parcelable interface.
| Parameters | |
|---|---|
dest |
Parcel:
The Parcel in which the object should be written. |
flags |
int:
Additional flags about how the object should be written.
May be 0 or PARCELABLE_WRITE_RETURN_VALUE.
|
Interfaces
Classes
- CaptivePortal
- ConnectivityManager
- ConnectivityManager.NetworkCallback
- Credentials
- DhcpInfo
- IpPrefix
- LinkAddress
- LinkProperties
- LocalServerSocket
- LocalSocket
- LocalSocketAddress
- MailTo
- Network
- NetworkCapabilities
- NetworkInfo
- NetworkRequest
- NetworkRequest.Builder
- Proxy
- ProxyInfo
- PskKeyManager
- RouteInfo
- SSLCertificateSocketFactory
- SSLSessionCache
- TrafficStats
- Uri
- Uri.Builder
- UrlQuerySanitizer
- UrlQuerySanitizer.IllegalCharacterValueSanitizer
- UrlQuerySanitizer.ParameterValuePair
- VpnService
- VpnService.Builder
Enums
Exceptions


