|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.limegroup.gnutella.Response
A single result from a query reply message. (In hindsight, "Result" would have been a better name.) Besides basic file information, responses can include metadata, which is actually stored query reply's QHD. Metadata comes in two formats: raw strings or parsed LimeXMLDocument.
Response was originally intended to be immutable, but it currently includes mutator methods for metadata; these will be removed in the future.
Constructor Summary | |
Response(FileDesc fd)
Constructs a new Response instance from the data in the specified FileDesc. |
|
Response(long index,
long size,
java.lang.String name)
Creates a fresh new response. |
|
Response(long index,
long size,
java.lang.String name,
LimeXMLDocument doc)
Creates a new response with parsed metadata. |
|
Response(long index,
long size,
java.lang.String name,
java.lang.String metadata)
Creates a new response with raw unparsed metadata. |
Method Summary | |
static Response |
createFromStream(java.io.InputStream is)
Factory method for instantiating individual responses from an InputStream instance. |
boolean |
equals(java.lang.Object o)
Overrides equals to check that these two responses are equal. |
LimeXMLDocument |
getDocument()
Returns this' metadata as a parsed XML document |
long |
getIndex()
Returns the index for the file stored in this Response instance. |
int |
getLength()
|
java.util.Set |
getLocations()
Returns an immutabe Set of Endpoint that contain the same file described in this Response. |
byte[] |
getMetaBytes()
Returns a copy of the array of bytes for the meta-data for this Response instance. |
int |
getMetaBytesSize()
Accessor fot the length of the array of bytes that stores the meta- data. |
java.lang.String |
getMetadata()
Returns the string of meta-data for this Response instance. |
java.lang.String |
getName()
Returns the name of the file for this response. |
byte[] |
getNameBytes()
Returns a copy of the array of bytes for the file name for this Response instance. |
int |
getNameBytesSize()
Returns the size of the name in bytes (not the whole response) In the constructor we create the nameBytes array once which is the representation of the name in bytes. |
long |
getSize()
Returns the size of the file for this Response instance (in bytes). |
java.util.Set |
getUrns()
Returns an immutable Set of URN instances for this Response. |
int |
hashCode()
|
void |
setDocument(LimeXMLDocument doc)
Sets this' metadata. |
RemoteFileDesc |
toRemoteFileDesc(HostData data)
Returns this Response as a RemoteFileDesc. |
java.lang.String |
toString()
Overrides Object.toString to print out a more informative message. |
int |
writeToArray(byte[] array,
int i)
Write the response data to the given byte array, as if inside a QueryReply. |
void |
writeToStream(java.io.OutputStream os)
Like writeToArray(), but writes to an OutputStream. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Response(long index, long size, java.lang.String name)
public Response(long index, long size, java.lang.String name, LimeXMLDocument doc)
doc
- the metadata to includepublic Response(long index, long size, java.lang.String name, java.lang.String metadata)
metadata
- a string of metadata, typically XMLpublic Response(FileDesc fd)
fd
- the FileDesc containing the data to construct
this Response -- must not be nullMethod Detail |
public static Response createFromStream(java.io.InputStream is) throws java.io.IOException
is
- the InputStream to read from
IOException
- if there are any problems reading from
or writing to the stream
java.io.IOException
public int writeToArray(byte[] array, int i)
public void writeToStream(java.io.OutputStream os) throws java.io.IOException
java.io.IOException
public void setDocument(LimeXMLDocument doc)
public int getLength()
public long getIndex()
public long getSize()
public int getNameBytesSize()
storing the nameBytes is an optimization beacuse we do not want to call getBytes() on the name string every time we need the byte representation or the number of bytes in the name.
public int getMetaBytesSize()
public byte[] getNameBytes()
public byte[] getMetaBytes()
public java.lang.String getName()
public java.lang.String getMetadata()
public LimeXMLDocument getDocument()
public java.util.Set getUrns()
public java.util.Set getLocations()
public RemoteFileDesc toRemoteFileDesc(HostData data)
public boolean equals(java.lang.Object o)
public int hashCode()
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |