當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。