本文整理汇总了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();