Difference between revisions of "Resource Serialization"

From Developer Documents
Jump to navigation Jump to search
m (Created page with '; Serializing a resource <source lang="java"> long serializeResource(RequestProcessor processor, Resource resource) throws DatabaseException { SerialisationSupport ss...')
 
 
Line 20: Line 20:
 
     }
 
     }
 
</source>
 
</source>
 +
 +
[[Category: Database Development]]

Latest revision as of 15:55, 28 January 2011

Serializing a resource

<source lang="java">

   long serializeResource(RequestProcessor processor, Resource resource) throws DatabaseException {
       SerialisationSupport ss = processor.getService(SerialisationSupport.class);
       return ss.getRandomAccessId(resource);
   }
   String serializeResourceToString(RequestProcessor processor, Resource resource) throws DatabaseException {
       return String.valueOf(serializeResource(processor, resource));
   }

</source>

Deserializing a resource

<source lang="java">

   Resource deserializeResource(ReadGraph graph, long randomAccessId) throws DatabaseException {
       SerialisationSupport ss = session.getService(SerialisationSupport.class);
       return rs.getResource(randomAccessId);
   }
   Resource deserializeResource(ReadGraph graph, String randomAccessId) throws DatabaseException, NumberFormatException {
       return deserializeResource(graph, Long.parseLong(randomAccessId));
   }

</source>