本文整理匯總了Java中kademlia.util.serializer.KadSerializer類的典型用法代碼示例。如果您正苦於以下問題:Java KadSerializer類的具體用法?Java KadSerializer怎麽用?Java KadSerializer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
KadSerializer類屬於kademlia.util.serializer包,在下文中一共展示了KadSerializer類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSerializer
import kademlia.util.serializer.KadSerializer; //導入依賴的package包/類
@Override
public KadSerializer<JKademliaStorageEntry> getSerializer()
{
if (null == serializer)
{
serializer = new JsonSerializer<>();
}
return serializer;
}
示例2: getSerializer
import kademlia.util.serializer.KadSerializer; //導入依賴的package包/類
/**
* Creates a new Serializer or returns an existing serializer
*
* @return The new ContentSerializer
*/
@Override
public KadSerializer<JSocialKademliaStorageEntry> getSerializer()
{
if (null == serializer)
{
serializer = new JsonSerializer<>();
}
return serializer;
}
示例3: SomeTest
import kademlia.util.serializer.KadSerializer; //導入依賴的package包/類
public SomeTest() throws IOException, ClassNotFoundException
{
Actor actor = new Actor("Some User");
Actor a2 = new Actor("joshy");
Actor a3 = new Actor("safi");
actor.addConnection(a2.getId());
actor.addConnection(a3.getId());
Status s1 = Status.createNew(actor, "Some status 1");
Status s2 = Status.createNew(actor, "Some status 12");
Status s3 = Status.createNew(actor, "Some status 123");
Status s4 = Status.createNew(actor, "Some status 1234");
actor.getContentManager().addContentToActorContentSet(s1);
actor.getContentManager().addContentToActorContentSet(s2);
actor.getContentManager().addContentToActorContentSet(s3);
actor.getContentManager().addContentToActorContentSet(s4);
JSocialKademliaStorageEntry entry = new JSocialKademliaStorageEntry(actor);
System.out.println(entry);
System.out.println("\n\n\n");
entry = StorageEntryCompressor.compress(entry);
System.out.println("Entry: " + entry);
System.out.println("\n\n\n");
KadSerializer<JSocialKademliaStorageEntry> serializer = new JsonSerializer<>();
String fileName = "some file.kct";
try (FileOutputStream fout = new FileOutputStream(fileName);
DataOutputStream dout = new DataOutputStream(fout))
{
serializer.write(entry, dout);
}
DataInputStream din = new DataInputStream(new FileInputStream(fileName));
JSocialKademliaStorageEntry retrievedEntry = serializer.read(din);
retrievedEntry = StorageEntryCompressor.decompress(retrievedEntry);
System.out.println(retrievedEntry);
}
示例4: getSerializer
import kademlia.util.serializer.KadSerializer; //導入依賴的package包/類
/**
* Creates a new Serializer or returns an existing serializer
*
* @return The new ContentSerializer
*/
public KadSerializer<JKademliaStorageEntry> getSerializer();
示例5: getSerializer
import kademlia.util.serializer.KadSerializer; //導入依賴的package包/類
/**
* Creates a new Serializer or returns an existing serializer
*
* @return The new ContentSerializer
*/
public KadSerializer<JSocialKademliaStorageEntry> getSerializer();