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 Metadata<K>

    java.lang.Object
      lbg.protocol.data.Metadata<K>

Type Parameters:
  `K` - The type of the entry key

    public class Metadata<K>

extends java.lang.Object

Denotes metadata about a cache entry. An entry is typically represented by an ID, and has an insertion time and a size. While these metrics are often used, it wouldn't be possible to foresee every other metric that could possibly be used, or every side data that could be needed. For this reason, the `setExtra(String, Object)` and `getExtra(String)` methods offer a contract similar to `Map` to set what could be needed.

Author:
  Xavier Dalem

Field Summary
`K` | `id`

Constructor Summary
`Metadata(K id)` Creates a Metada, setting time to the current time.

Method Summary
`java.lang.Object` | `getExtra(java.lang.String key)`
`long` | `getTime()`
`long` | `getWeight()`
`java.lang.Object` | `setExtra(java.lang.String key, java.lang.Object value)`
`void` | `setTime()` Set the time from epoch.
`void` | `setTime(long time)` Sets the creation time of this Metadata.
`void` | `setWeight(long weight)` Sets the weight of this metadata.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### id

    public final K id

Constructor Detail

### Metadata

    public Metadata(K id)

  Creates a Metada, setting time to the current time. Weight is initalized to 0.

  See Also:
    `setWeight(long)`, `setTime(long)`

Method Detail

### setTime

    public void setTime()

  Set the time from epoch.

  See Also:
    `setTime(long)`

### setTime

    public void setTime(long time)

  Sets the creation time of this Metadata. Time should be relative to a defined moment. It can be epoch (as returned by `System.currentTimeMillis()` but can very well be any other convention as long as it is consistent.

  Parameters:
    `time` - The time in milliseconds

### getTime

    public long getTime()

### setWeight

    public void setWeight(long weight)

  Sets the weight of this metadata. If the metadata is associated with a file, the weight could be the size in bytes of that file.

  Parameters:
    `weight` - The weight to set.

### getWeight

    public long getWeight()

### setExtra

    public java.lang.Object setExtra(java.lang.String key,
                                     java.lang.Object value)

### getExtra

    public java.lang.Object getExtra(java.lang.String key)

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.