Package net.handle.hdllib
Class HandleValue
- java.lang.Object
-
- net.handle.hdllib.HandleValue
-
public class HandleValue extends java.lang.Object
Represents a single handle value
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<HandleValue>
INDEX_COMPARATOR
static int
MAX_RECOGNIZED_TTL
static byte
SUBTYPE_SEPARATOR
static byte
TTL_TYPE_ABSOLUTE
static byte
TTL_TYPE_RELATIVE
-
Constructor Summary
Constructors Constructor Description HandleValue()
HandleValue(int index, byte[] type, byte[] data)
HandleValue(int index, byte[] type, byte[] data, byte ttlType, int ttl, int timestamp, ValueReference[] references, boolean adminRead, boolean adminWrite, boolean publicRead, boolean publicWrite)
HandleValue(int index, java.lang.String type, byte[] data)
HandleValue(int index, java.lang.String type, java.lang.String data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HandleValue
duplicate()
Returns a copy of this HandleValueboolean
equals(java.lang.Object obj)
boolean
equalsIgnoreTimestamp(HandleValue other)
boolean
getAdminCanRead()
boolean
getAdminCanWrite()
boolean
getAnyoneCanRead()
boolean
getAnyoneCanWrite()
byte[]
getData()
java.lang.String
getDataAsString()
int
getIndex()
java.lang.String
getNicerTimestampAsString()
java.lang.String
getPermissionString()
ValueReference[]
getReferences()
int
getTimestamp()
java.util.Date
getTimestampAsDate()
java.lang.String
getTimestampAsString()
int
getTTL()
byte
getTTLType()
byte[]
getType()
java.lang.String
getTypeAsString()
int
hashCode()
boolean
hasType(byte[] someType)
Returns whether or not this handle value has the given type.boolean
isExpired(int now, int timeRetrieved)
Given the current time and the time this value was retrieved from a handle server (in seconds), return true if this value is "stale" and should be retrieved again.void
setAdminCanRead(boolean newAdminRead)
void
setAdminCanWrite(boolean newAdminWrite)
void
setAnyoneCanRead(boolean newPublicRead)
void
setAnyoneCanWrite(boolean newPublicWrite)
void
setData(byte[] newData)
void
setIndex(int newIndex)
void
setReferences(ValueReference[] newReferences)
void
setTimestamp(int newTimestamp)
void
setTTL(int newTTL)
void
setTTLType(byte newTTLType)
void
setType(byte[] newType)
java.lang.String
toDetailedString()
java.lang.String
toString()
static boolean
unorderedEquals(HandleValue[] vals1, HandleValue[] vals2)
static boolean
unorderedEqualsIgnoreTimestamp(HandleValue[] vals1, HandleValue[] vals2)
-
-
-
Field Detail
-
SUBTYPE_SEPARATOR
public static final byte SUBTYPE_SEPARATOR
- See Also:
- Constant Field Values
-
TTL_TYPE_RELATIVE
public static final byte TTL_TYPE_RELATIVE
- See Also:
- Constant Field Values
-
TTL_TYPE_ABSOLUTE
public static final byte TTL_TYPE_ABSOLUTE
- See Also:
- Constant Field Values
-
MAX_RECOGNIZED_TTL
public static final int MAX_RECOGNIZED_TTL
- See Also:
- Constant Field Values
-
INDEX_COMPARATOR
public static java.util.Comparator<HandleValue> INDEX_COMPARATOR
-
-
Constructor Detail
-
HandleValue
public HandleValue()
-
HandleValue
public HandleValue(int index, byte[] type, byte[] data)
-
HandleValue
public HandleValue(int index, java.lang.String type, byte[] data)
-
HandleValue
public HandleValue(int index, java.lang.String type, java.lang.String data)
-
HandleValue
public HandleValue(int index, byte[] type, byte[] data, byte ttlType, int ttl, int timestamp, ValueReference[] references, boolean adminRead, boolean adminWrite, boolean publicRead, boolean publicWrite)
-
-
Method Detail
-
getPermissionString
public final java.lang.String getPermissionString()
-
toDetailedString
public java.lang.String toDetailedString()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isExpired
public boolean isExpired(int now, int timeRetrieved)
Given the current time and the time this value was retrieved from a handle server (in seconds), return true if this value is "stale" and should be retrieved again.
-
hasType
public final boolean hasType(byte[] someType)
Returns whether or not this handle value has the given type. This handles subtypes, so if you call hasType("URL") and the type of this handle value is "URL.METADATA" then this will return true.
-
getDataAsString
public final java.lang.String getDataAsString()
-
getTypeAsString
public final java.lang.String getTypeAsString()
-
getTimestampAsString
public final java.lang.String getTimestampAsString()
-
getNicerTimestampAsString
public final java.lang.String getNicerTimestampAsString()
-
getTimestampAsDate
public final java.util.Date getTimestampAsDate()
-
getIndex
public final int getIndex()
-
setIndex
public final void setIndex(int newIndex)
-
getType
public final byte[] getType()
-
setType
public final void setType(byte[] newType)
-
getData
public final byte[] getData()
-
setData
public final void setData(byte[] newData)
-
getTTLType
public final byte getTTLType()
-
setTTLType
public final void setTTLType(byte newTTLType)
-
getTTL
public final int getTTL()
-
setTTL
public final void setTTL(int newTTL)
-
getTimestamp
public final int getTimestamp()
-
setTimestamp
public final void setTimestamp(int newTimestamp)
-
getReferences
public final ValueReference[] getReferences()
-
setReferences
public final void setReferences(ValueReference[] newReferences)
-
getAdminCanRead
public final boolean getAdminCanRead()
-
setAdminCanRead
public final void setAdminCanRead(boolean newAdminRead)
-
getAdminCanWrite
public final boolean getAdminCanWrite()
-
setAdminCanWrite
public final void setAdminCanWrite(boolean newAdminWrite)
-
getAnyoneCanRead
public final boolean getAnyoneCanRead()
-
setAnyoneCanRead
public final void setAnyoneCanRead(boolean newPublicRead)
-
getAnyoneCanWrite
public final boolean getAnyoneCanWrite()
-
setAnyoneCanWrite
public final void setAnyoneCanWrite(boolean newPublicWrite)
-
duplicate
public HandleValue duplicate()
Returns a copy of this HandleValue
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
equalsIgnoreTimestamp
public boolean equalsIgnoreTimestamp(HandleValue other)
-
unorderedEquals
public static boolean unorderedEquals(HandleValue[] vals1, HandleValue[] vals2)
-
unorderedEqualsIgnoreTimestamp
public static boolean unorderedEqualsIgnoreTimestamp(HandleValue[] vals1, HandleValue[] vals2)
-
-