Lightweight Bartering Grid

lbg.protocol.data
Class InlineGridData

java.lang.Object
  extended by lbg.protocol.data.GridData
      extended by 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

Field Summary
 
Fields inherited from class lbg.protocol.data.GridData
client_hostname, HASHING_ALGORITHM, id, size
 
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 lbg.protocol.data.GridData
compareTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 GridData
data - The data as an array of bytes
Throws:
GridException
See Also:
GridData
Method Detail

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

Lightweight Bartering Grid

Copyright (c) 2005-2008, Cyril Briquet, parts Xavier Dalem.