当前位置: 首页>>代码示例>>Java>>正文


Java KadSerializer类代码示例

本文整理汇总了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;
}
 
开发者ID:JoshuaKissoon,项目名称:Kademlia,代码行数:11,代码来源:DHT.java

示例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;
}
 
开发者ID:JoshuaKissoon,项目名称:SocialKademlia,代码行数:16,代码来源:JSocialKademliaDHT.java

示例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);
}
 
开发者ID:JoshuaKissoon,项目名称:SuperDosna,代码行数:44,代码来源:SomeTest.java

示例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();
 
开发者ID:JoshuaKissoon,项目名称:Kademlia,代码行数:7,代码来源:KademliaDHT.java

示例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();
 
开发者ID:JoshuaKissoon,项目名称:SocialKademlia,代码行数:7,代码来源:SocialKademliaDHT.java


注:本文中的kademlia.util.serializer.KadSerializer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。