net.tomp2p.storage
Class Data

java.lang.Object
  extended by net.tomp2p.storage.Data
All Implemented Interfaces:
Serializable

public class Data
extends Object
implements Serializable

This class holds the data for the transport. The data is already serialized and a hash may be created. It is reasonable to create the hash on the remote peer, but not on the local peer. The remote peer uses the hash to tell the other peers, which version is stored and its used quite often.

Author:
draft
See Also:
Serialized Form

Field Summary
static PublicKey FROM_MESSAGE
           
 
Constructor Summary
Data(byte[] data)
           
Data(byte[] data, int offset, int length, PeerAddress originator)
           
Data(byte[] data, PeerAddress originator)
           
Data(Object object)
           
Data(Object object, PeerAddress originator)
           
 
Method Summary
 long getCreated()
           
 byte[] getData()
           
 PublicKey getDataPublicKey()
          This public key is set by the storage class and not by the decoding class
 long getExpirationMillis()
           
 Number160 getHash()
           
 int getLength()
           
 Object getObject()
           
 int getOffset()
           
 PeerAddress getPeerAddress()
           
 byte[] getSignature()
           
 int getTTLSeconds()
           
 boolean isDirectReplication()
           
 boolean isProtectedEntry()
           
 void setDataPublicKey(PublicKey dataPublicKey)
          This public key is set by the storage class and not by the decoding class
 void setDirectReplication(boolean directReplication)
           
 void setPeerAddress(PeerAddress originator)
           
 void setProtectedEntry(boolean protectedEntry)
           
 void setSignature(byte[] signature)
           
 void setTTLSeconds(int ttlSeconds)
           
 void signAndSetPublicKey(KeyPair keyPair)
           
 String toString()
           
 boolean verify(PublicKey public1)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FROM_MESSAGE

public static final PublicKey FROM_MESSAGE
Constructor Detail

Data

public Data(Object object)
     throws IOException
Throws:
IOException

Data

public Data(Object object,
            PeerAddress originator)
     throws IOException
Throws:
IOException

Data

public Data(byte[] data)

Data

public Data(byte[] data,
            PeerAddress originator)

Data

public Data(byte[] data,
            int offset,
            int length,
            PeerAddress originator)
Method Detail

getData

public byte[] getData()

getObject

public Object getObject()
                 throws ClassNotFoundException,
                        IOException
Throws:
ClassNotFoundException
IOException

getCreated

public long getCreated()

getTTLSeconds

public int getTTLSeconds()

setTTLSeconds

public void setTTLSeconds(int ttlSeconds)

getHash

public Number160 getHash()

getOffset

public int getOffset()

getLength

public int getLength()

getExpirationMillis

public long getExpirationMillis()

getDataPublicKey

public PublicKey getDataPublicKey()
This public key is set by the storage class and not by the decoding class

Returns:
PublicKey

setDataPublicKey

public void setDataPublicKey(PublicKey dataPublicKey)
This public key is set by the storage class and not by the decoding class

Parameters:
publicKey -

signAndSetPublicKey

public void signAndSetPublicKey(KeyPair keyPair)
                         throws NoSuchAlgorithmException,
                                InvalidKeyException,
                                SignatureException
Throws:
NoSuchAlgorithmException
InvalidKeyException
SignatureException

verify

public boolean verify(PublicKey public1)
               throws NoSuchAlgorithmException,
                      InvalidKeyException,
                      SignatureException
Throws:
NoSuchAlgorithmException
InvalidKeyException
SignatureException

setSignature

public void setSignature(byte[] signature)

getSignature

public byte[] getSignature()

isProtectedEntry

public boolean isProtectedEntry()

setProtectedEntry

public void setProtectedEntry(boolean protectedEntry)

setDirectReplication

public void setDirectReplication(boolean directReplication)

isDirectReplication

public boolean isDirectReplication()

toString

public String toString()
Overrides:
toString in class Object

getPeerAddress

public PeerAddress getPeerAddress()

setPeerAddress

public void setPeerAddress(PeerAddress originator)


Copyright © 2011. All Rights Reserved.