|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--anthill.util.SHADigest | +--ants.utils.DocumentKey
Probabilistic identifier for a document.
Field Summary | |
protected int |
length
Length of the document |
Fields inherited from class anthill.util.SHADigest |
digest, DIGEST_SIZE, DIGEST_TYPE, hashcode, random, RANDOM_TYPE, rdigest |
Constructor Summary | |
DocumentKey()
Default constructor for externalization. |
|
DocumentKey(String urlPath)
Creates a deterministic DocumentKey instance for simulation
purposes. |
|
DocumentKey(URL url)
Creates a DocumentKey instance for real deployment purposes.
|
Method Summary | |
void |
computeDocumentKey(String urlPath)
Computes a fake DocumentKey based on the path component
of the specified URL. |
void |
computeDocumentKey(URL url)
Reads data from the specified URL and computes the length and digest components that comprise the DocumentKey . |
void |
computeHash()
Computes the hash code for this DocumentKey .
|
boolean |
equals(Object obj)
Check whether this DocumentKey is equal
to the specified object. |
int |
getLength()
Returns the length component of the DocumentKey . |
void |
readExternal(ObjectInput in)
Marshals this DocumentKey to the specified output stream. |
String |
toString()
Returns a string representation of the object. |
void |
writeExternal(ObjectOutput out)
Marshals this DocumentKey to the specified output stream. |
Methods inherited from class anthill.util.SHADigest |
compareTo, compareTo, computeDigest, computeRandomSHA, getBytes, hashCode, initRandom, isCloser |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected int length
Constructor Detail |
public DocumentKey()
public DocumentKey(URL url) throws IOException
DocumentKey
instance for real deployment purposes.
It will read the content of the given URL and compute the digest and length
components comprising the DocumentKey
.
url
- the URL for which we wish to compute a DocumentKey
.public DocumentKey(String urlPath)
DocumentKey
instance for simulation
purposes. The URL path string is used to compute the digest and
length, which comprises the document key. This computation is done
deterministically.
urlPath
- the URL path; can be fake since no checks are made.Method Detail |
public void computeDocumentKey(URL url) throws IOException
DocumentKey
.
url
- the URL from which to read the data needed to compute
the DocumentKey
.
IOException
- if an error occurspublic void computeDocumentKey(String urlPath)
DocumentKey
based on the path component
of the specified URL. This is useful for simulation purposes only.
urlPath
- the path component of a URL.public void computeHash()
DocumentKey
.
Note that we wish to avoid computing the hashcode of a big integer every time, so therefore we compute the hashcode prior to its use and store it for future calls to the hashcode method.
computeHash
in class SHADigest
public int getLength()
DocumentKey
.
DocumentKey
.public boolean equals(Object obj)
DocumentKey
is equal
to the specified object.
equals
in class SHADigest
obj
- the reference object with which to compare.
public String toString()
toString
in class SHADigest
public void readExternal(ObjectInput in) throws IOException
DocumentKey
to the specified output stream.
readExternal
in interface Externalizable
readExternal
in class SHADigest
in
- an ObjectInput
stream object
IOException
- if an error occurspublic void writeExternal(ObjectOutput out) throws IOException
DocumentKey
to the specified output stream.
writeExternal
in interface Externalizable
writeExternal
in class SHADigest
out
- an ObjectOutput
stream object
IOException
- if an error occurs
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |