Store content in string so saved file is easily readable.

This commit is contained in:
Joshua Kissoon 2014-04-06 17:01:27 +05:30
parent 1a5991404d
commit eaeffeb0ba
5 changed files with 8 additions and 7 deletions

View File

@ -96,6 +96,7 @@ public class DHT
/* We have this content, but not the latest version, lets delete it so the new version will be added below */
try
{
System.out.println("Removing older content to update it");
this.remove(content.getContentMetadata());
}
catch (ContentNotFoundException ex)

View File

@ -9,7 +9,7 @@ package kademlia.dht;
public class StorageEntry
{
private final byte[] content;
private final String content;
private final StorageEntryMetadata metadata;
public StorageEntry(KadContent content)
@ -19,11 +19,11 @@ public class StorageEntry
public StorageEntry(KadContent content, StorageEntryMetadata metadata)
{
this.content = content.toBytes();
this.content = new String(content.toBytes());
this.metadata = metadata;
}
public byte[] getContent()
public String getContent()
{
return this.content;
}

View File

@ -43,7 +43,7 @@ public class ContentSendingTest
List<StorageEntry> conte = kad2.get(gp, 4);
for (StorageEntry cc : conte)
{
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent()));
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent().getBytes()));
System.out.println("Content Metadata: " + cc.getContentMetadata());
}

View File

@ -38,7 +38,7 @@ public class ContentUpdatingTest
List<StorageEntry> conte = kad2.get(gp, 4);
for (StorageEntry cc : conte)
{
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent()));
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent().getBytes()));
System.out.println("Content Metadata: " + cc.getContentMetadata());
}
@ -51,7 +51,7 @@ public class ContentUpdatingTest
conte = kad2.get(gp, 4);
for (StorageEntry cc : conte)
{
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent()));
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent().getBytes()));
System.out.println("Content Metadata: " + cc.getContentMetadata());
}

View File

@ -57,7 +57,7 @@ public class SaveStateTest2
if (!content.isEmpty())
{
DHTContentImpl cc = new DHTContentImpl().fromBytes(content.get(0).getContent());
DHTContentImpl cc = new DHTContentImpl().fromBytes(content.get(0).getContent().getBytes());
System.out.println("Content received: " + cc);
}
else