Most visited

Recently visited

Added in API level 21

IpPrefix

public final class IpPrefix
extends Object implements Parcelable

java.lang.Object
   ↳ android.net.IpPrefix


此类表示IP前缀,即在两个边界的电源(也称为“IP子网”)上对齐的连续IP地址块。 前缀由两条信息指定:

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

Inherited constants

From interface android.os.Parcelable

Fields

public static final Creator<IpPrefix> CREATOR

实现Parcelable接口。

Public methods

boolean contains(InetAddress address)

确定前缀是否包含指定的地址。

int describeContents()

实现Parcelable接口。

boolean equals(Object obj)

将此 IpPrefix对象与 IpPrefix中的指定对象进行 obj

InetAddress getAddress()

返回前缀中第一个IP地址的副本。

int getPrefixLength()

返回此 IpPrefix的前缀长度。

byte[] getRawAddress()

按网络顺序返回IP地址字节的副本(最高顺序字节是第零个元素)。

int hashCode()

获取表示的IP前缀的哈希码。

String toString()

返回此 IpPrefix的字符串表示 IpPrefix

void writeToParcel(Parcel dest, int flags)

实现Parcelable接口。

Inherited methods

From class java.lang.Object
From interface android.os.Parcelable

Fields

CREATOR

Added in API level 21
Creator<IpPrefix> CREATOR

实现Parcelable接口。

Public methods

contains

Added in API level 23
boolean contains (InetAddress address)

确定前缀是否包含指定的地址。

Parameters
address InetAddress: An InetAddress to test.
Returns
boolean true if the prefix covers the given address.

describeContents

Added in API level 21
int describeContents ()

实现Parcelable接口。

Returns
int a bitmask indicating the set of special object types marshaled by this Parcelable object instance.

equals

Added in API level 21
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.

getAddress

Added in API level 21
InetAddress getAddress ()

返回前缀中第一个IP地址的副本。 修改返回的对象不会改变这个对象的内容。

Returns
InetAddress the address in the form of a byte array.

getPrefixLength

Added in API level 21
int getPrefixLength ()

返回此 IpPrefix的前缀长度。

Returns
int the prefix length.

getRawAddress

Added in API level 21
byte[] getRawAddress ()

按网络顺序返回IP地址字节的副本(最高顺序字节是第零个元素)。 修改返回的数组不会改变这个对象的内容。

Returns
byte[] the address in the form of a byte array.

hashCode

Added in API level 21
int hashCode ()

获取表示的IP前缀的哈希码。

Returns
int the appropriate hashcode value.

toString

Added in API level 21
String toString ()

返回此 IpPrefix的字符串表示 IpPrefix

Returns
String a string such as "192.0.2.0/24" or "2001:db8:1:2::/64".

writeToParcel

Added in API level 21
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.

Hooray!