Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Lightweight Bartering Grid
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## lbg.protocol.data
Class GridData

    java.lang.Object
      lbg.protocol.data.GridData

All Implemented Interfaces:
  java.io.Serializable, java.lang.Comparable<GridData>

Direct Known Subclasses:
  FTPGridData, InlineGridData, SimulatedGridData, TorrentGridData

    public abstract class GridData

extends java.lang.Object
implements java.lang.Comparable<GridData>, java.io.Serializable

Parent class for all grid data. Offers some basic functionnality for subclasses and forces others.

Author:
  Xavier Dalem, Cyril Briquet
See Also:
  Serialized Form

Field Summary
`protected java.lang.String` | `client_hostname`
`static java.lang.String` | `HASHING_ALGORITHM` The name of the hashing algorithm that is used by all subclasses.
`java.lang.String` | `id` Data ID.
`long` | `size` Size (in bytes) of GridData.

Constructor Summary
`protected` | `GridData(java.lang.String id, long size)` Make a new GridData

Method Summary
`int` | `compareTo(GridData other)`
`abstract byte[]` | `getChecksum()` Get checksum from data.
`abstract java.io.InputStream` | `getInputStream()` Get an input stream to read the data
`abstract 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`

Field Detail

### id

    public final java.lang.String id

  Data ID. Should be of the form `requestingpeerID.userID.original_filename`

### size

    public final long size

  Size (in bytes) of GridData.

### client_hostname

    protected java.lang.String client_hostname

### HASHING_ALGORITHM

    public static final java.lang.String HASHING_ALGORITHM

  The name of the hashing algorithm that is used by all subclasses. Refer to the API from java.security.MessageDigest for valid names.

  See Also:
    Constant Field Values

Constructor Detail

### GridData

    protected GridData(java.lang.String id,
                       long size)
                throws GridException

  Make a new GridData

  Parameters:
    `id` - The unique ID for the file. It should be of the form `requestingpeerID.userID.filename`
  Throws:
    `GridException` - if the ID is invalid

Method Detail

### compareTo

    public final int compareTo(GridData other)

  Specified by:
    `compareTo` in interface `java.lang.Comparable<GridData>`

### toFile

    public abstract void toFile(java.io.File file)
                         throws GridException

  Save data in a file. This call is blocking.

  Parameters:
    `file` - The file where to put data
  Throws:
    `GridException`

### getChecksum

    public abstract byte[] getChecksum()
                                throws GridException

  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.

  Throws:
    `GridException`
  See Also:
    `HASHING_ALGORITHM`

### getInputStream

    public abstract java.io.InputStream getInputStream()
                                                throws GridException

  Get an input stream to read the data

  Throws:
    `GridException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Lightweight Bartering Grid
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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