- java.lang.Object
-
- com.pervasive.datarush.tokens.scalar.Ip4AddressToken
-
- All Implemented Interfaces:
DataToken,Ip4AddressValued,ScalarToken,ScalarValued,TokenValued,ScalarTyped,TokenTyped,Serializable,Comparable<Ip4AddressToken>
public final class Ip4AddressToken extends Object implements ScalarToken, Comparable<Ip4AddressToken>
An immutableIp4AddressValuedobject.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Ip4AddressTokenNULLA null valuedIp4AddressTokenstatic Ip4AddressTokenZEROA zero valuedIp4AddressTokenstatic byte[]ZERO_VALUEThe byte array representing the 0.0.0.0 ip address, the emptybyte[4].
-
Constructor Summary
Constructors Constructor Description Ip4AddressToken(byte[] value)Constructs a new token with the given non-null ip4 value.Ip4AddressToken(Ip4AddressValued value)Constructs a new token with the ip4 address value in the given container.Ip4AddressToken(String value)Constructs aIp4AddressTokenwith the non-null ip4 address value encoded by the given string.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]asAddress()Gets the contained raw IPv4 address value.Inet4AddressasInet4Address()Gets the contained IP address as an Inet4Address.intcompareTo(Ip4AddressToken that)booleanequals(Object obj)Indicates whether another object is equal to this token.ScalarTokenTypegetType()Gets the data type of the token.inthashCode()Returns a hash code for the token.booleanisNull()Indicates whether the token is null valued.booleanisZero()Indicates whether the value is the zero value for the type.static Ip4AddressTokenparse(String value)Converts a string representation of a ip4 address value into a token.booleanrepresents(byte[] otherData)A 'deep equals' comparison of this token's contents to the provided raw ip4 bytes.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.pervasive.datarush.tokens.scalar.ScalarValued
getType, isZero
-
Methods inherited from interface com.pervasive.datarush.tokens.TokenValued
isNull
-
-
-
-
Field Detail
-
NULL
public static final Ip4AddressToken NULL
A null valuedIp4AddressToken
-
ZERO_VALUE
public static final byte[] ZERO_VALUE
The byte array representing the 0.0.0.0 ip address, the emptybyte[4].
-
ZERO
public static final Ip4AddressToken ZERO
A zero valuedIp4AddressToken
-
-
Constructor Detail
-
Ip4AddressToken
public Ip4AddressToken(Ip4AddressValued value)
Constructs a new token with the ip4 address value in the given container.- Parameters:
value- aIp4AddressValuedcontaining the desired value
-
Ip4AddressToken
public Ip4AddressToken(byte[] value)
Constructs a new token with the given non-null ip4 value. If a null valued token is desired, useNULL.- Parameters:
value- the ip4 address value of the token. A copy of the array will be made.- Throws:
NullPointerException- if the supplied array isnull
-
Ip4AddressToken
public Ip4AddressToken(String value)
Constructs aIp4AddressTokenwith the non-null ip4 address value encoded by the given string. Should be in form #.#.#.# If a null valued token is desired, useNULL.- Parameters:
value- a string representing the ip4 value- Throws:
NullPointerException- if the supplied hexadecimal string isnull
-
-
Method Detail
-
compareTo
public int compareTo(Ip4AddressToken that)
- Specified by:
compareToin interfaceComparable<Ip4AddressToken>
-
equals
public boolean equals(Object obj)
Description copied from interface:DataTokenIndicates whether another object is equal to this token. Two null valued tokens are considered equal. This differs from the behavior ofTokenComparator.equal(TokenValued,TokenValued)but makes it possible to storeDataTokens inMaps.
-
represents
public boolean represents(byte[] otherData)
A 'deep equals' comparison of this token's contents to the provided raw ip4 bytes. Implementations SHOULD use this instead of equals when comparing Ip4AddressTokens to arrays; equals() will eventually stop recognizing ip4 byte arrays to comply with the general equals/hashcode contracts.- Parameters:
otherData- the object that we're comparing to- Returns:
- a 'deep equals' comparison of contents with otherData
-
hashCode
public int hashCode()
Description copied from interface:DataTokenReturns a hash code for the token. This value is guaranteed to be consistent with that returned byTokenConverter.asHashCode(TokenValued).
-
parse
public static Ip4AddressToken parse(String value)
Converts a string representation of a ip4 address value into a token. Should be in form #.#.#.#- Parameters:
value- a string representing an ip4 address- Returns:
- a token with the specified value
-
getType
public final ScalarTokenType getType()
Description copied from interface:TokenValuedGets the data type of the token. This type will dictate the valid values that can be contained.- Specified by:
getTypein interfaceScalarTyped- Specified by:
getTypein interfaceScalarValued- Specified by:
getTypein interfaceTokenTyped- Specified by:
getTypein interfaceTokenValued- Returns:
- the token type.
-
asAddress
public final byte[] asAddress()
Description copied from interface:Ip4AddressValuedGets the contained raw IPv4 address value. The array returned is a copy of the binary data contained in the object.- Specified by:
asAddressin interfaceIp4AddressValued- Returns:
- the contained value as a
byte[4]. If null valued, as indicated byTokenValued.isNull(),nullis returned.
-
asInet4Address
public final Inet4Address asInet4Address()
Description copied from interface:Ip4AddressValuedGets the contained IP address as an Inet4Address.- Specified by:
asInet4Addressin interfaceIp4AddressValued- Returns:
- the contained value as a
Inet4Address. If null valued, as indicated byTokenValued.isNull(),nullis returned.
-
isZero
public final boolean isZero()
Description copied from interface:ScalarValuedIndicates whether the value is the zero value for the type. Zero values are not stored in sparse representation formats.- Specified by:
isZeroin interfaceScalarValued- Returns:
trueif the value is the zero value,falseotherwise.
-
isNull
public final boolean isNull()
Description copied from interface:TokenValuedIndicates whether the token is null valued. Tokens support null values analogous to SQL. Before accessing the value of the container, it is usually best to ensure it is not null valued using this method.- Specified by:
isNullin interfaceTokenValued- Returns:
trueif the token is null valued,falseotherwise
-
-