org.apache.directory.server.core.entry
Class ServerEntrySerializer

java.lang.Object
  extended by org.apache.directory.server.core.entry.ServerEntrySerializer
All Implemented Interfaces:
java.io.Serializable, Serializer

public class ServerEntrySerializer
extends java.lang.Object
implements Serializer

Version:
$Rev$, $Date$
Author:
Apache Directory Project
See Also:
Serialized Form

Constructor Summary
ServerEntrySerializer(Registries registries)
          Creates a new instance of ServerEntrySerializer.
 
Method Summary
 java.lang.Object deserialize(byte[] bytes)
          Deserialize a ServerEntry.
 byte[] serialize(java.lang.Object object)
           This is the place where we serialize entries, and all theirs elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerEntrySerializer

public ServerEntrySerializer(Registries registries)
Creates a new instance of ServerEntrySerializer.

Parameters:
registries - The reference to the global registries
Method Detail

serialize

public byte[] serialize(java.lang.Object object)
                 throws java.io.IOException

This is the place where we serialize entries, and all theirs elements. the reason why we don't call the underlying methods (ServerAttribute.write(), Value.write()) is that we need access to the registries to read back the values.

The structure used to store the entry is the following :

  • [DN length] : can be -1 if we don't have a DN, 0 if the DN is empty, otherwise contains the DN's length.

    NOTE :This should be unnecessary, as the DN should always exists

  • DN : The entry's DN. Can be empty (rootDSE)

  • [nb attributes] The number of attributes

  • For each attribute :
  • [upId] The attribute user provided ID (it can't be null)
  • [nb values] The number of values

  • For each value :
  • [is valid] if the value is valid
  • [HR flag] if the value is a String
  • [Streamed flag] if the value is streamed
  • [UP value] the user provided value
  • [Norm value] (will be null if normValue == upValue)
  • Specified by:
    serialize in interface Serializer
    Parameters:
    object - Object to serialize
    Returns:
    a byte array representing the object's state
    Throws:
    java.io.IOException

    deserialize

    public java.lang.Object deserialize(byte[] bytes)
                                 throws java.io.IOException
    Deserialize a ServerEntry.

    Specified by:
    deserialize in interface Serializer
    Parameters:
    bytes - the byte array containing the serialized entry
    Returns:
    An instance of a ServerEntry object
    Throws:
    java.io.IOException - if we can't deserialize the ServerEntry


    Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.