lbg.protocol.data
Class InlineGridData
java.lang.Object
lbg.protocol.data.GridData
lbg.protocol.data.InlineGridData
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable<GridData>
public class InlineGridData
- extends GridData
Grid data class where the data is actually contained by the class itself.
Nice for User to Peer communication, where the file will be sent once
- Author:
- Xavier Dalem
- See Also:
- Serialized Form
Constructor Summary |
InlineGridData(java.lang.String id,
byte[] data)
Create an InlineGridData with given id and data. |
Method Summary |
byte[] |
getChecksum()
Get checksum from data. |
java.io.InputStream |
getInputStream()
Get an input stream to read the data |
void |
toFile(java.io.File file)
Save data in a file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InlineGridData
public InlineGridData(java.lang.String id,
byte[] data)
throws GridException
- Create an InlineGridData with given id and data.
- Parameters:
id
- The file ID. For restrictions on this, see GridDatadata
- The data as an array of bytes
- Throws:
GridException
- See Also:
GridData
toFile
public void toFile(java.io.File file)
throws GridException
- Description copied from class:
GridData
- Save data in a file.
This call is blocking.
- Specified by:
toFile
in class GridData
- Parameters:
file
- The file where to put data
- Throws:
GridException
getChecksum
public byte[] getChecksum()
throws GridException
- Description copied from class:
GridData
- Get checksum from data. It must be the checksum from the real
data, not of data and combined details like it is the case for torrents.
The used algorithm is specified by HASHING_ALGORITHM.
- Specified by:
getChecksum
in class GridData
- Throws:
GridException
- See Also:
GridData.HASHING_ALGORITHM
getInputStream
public java.io.InputStream getInputStream()
- Description copied from class:
GridData
- Get an input stream to read the data
- Specified by:
getInputStream
in class GridData
Copyright (c) 2005-2008, Cyril Briquet, parts Xavier Dalem.