public final class IpPrefix
extends Object implements Parcelable
| java.lang.Object | |
| android.net.IpPrefix | |
此类表示IP前缀,即在两个边界的电源(也称为“IP子网”)上对齐的连续IP地址块。 前缀由两条信息指定:
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.
Inherited constants |
|---|
android.os.Parcelable
|
Fields |
|
|---|---|
public static final Creator<IpPrefix> |
CREATOR 实现Parcelable接口。 |
公共方法(Public methods) |
|
|---|---|
boolean |
contains(InetAddress address) 确定前缀是否包含指定的地址。 |
int |
describeContents() 实现Parcelable接口。 |
boolean |
equals(Object obj) 将此 |
InetAddress |
getAddress() 返回前缀中第一个IP地址的副本。 |
int |
getPrefixLength() 返回此 |
byte[] |
getRawAddress() 按网络顺序返回IP地址字节的副本(最高顺序字节是第零个元素)。 |
int |
hashCode() 获取表示的IP前缀的哈希码。 |
String |
toString() 返回此 |
void |
writeToParcel(Parcel dest, int flags) 实现Parcelable接口。 |
继承方法(Inherited methods) |
|
|---|---|
java.lang.Object
|
|
android.os.Parcelable
|
|
boolean contains (InetAddress address)
确定前缀是否包含指定的地址。
| 参数(Parameters) | |
|---|---|
address |
InetAddress: An InetAddress to test. |
| 返回(Returns) | |
|---|---|
boolean |
true if the prefix covers the given address. |
int describeContents ()
实现Parcelable接口。
| 返回(Returns) | |
|---|---|
int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. |
boolean equals (Object obj)
将此IpPrefix对象与IpPrefix中的指定对象进行obj 。 如果两个对象具有相同的startAddress和prefixLength,则两个对象相等。
| 参数(Parameters) | |
|---|---|
obj |
Object: the object to be tested for equality. |
| 返回(Returns) | |
|---|---|
boolean |
true if both objects are equal, false otherwise. |
InetAddress getAddress ()
返回前缀中第一个IP地址的副本。 修改返回的对象不会改变这个对象的内容。
| 返回(Returns) | |
|---|---|
InetAddress |
the address in the form of a byte array. |
int getPrefixLength ()
返回此 IpPrefix的前缀长度。
| 返回(Returns) | |
|---|---|
int |
the prefix length. |
byte[] getRawAddress ()
按网络顺序返回IP地址字节的副本(最高顺序字节是第零个元素)。 修改返回的数组不会改变这个对象的内容。
| 返回(Returns) | |
|---|---|
byte[] |
the address in the form of a byte array. |
int hashCode ()
获取表示的IP前缀的哈希码。
| 返回(Returns) | |
|---|---|
int |
the appropriate hashcode value. |
String toString ()
返回此 IpPrefix的字符串表示 IpPrefix 。
| 返回(Returns) | |
|---|---|
String |
a string such as "192.0.2.0/24" or "2001:db8:1:2::/64". |
void writeToParcel (Parcel dest, int flags)
实现Parcelable接口。
| 参数(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. |