{
try
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream( baos );
// First, the Dn
Dn dn = entry.getDn();
// Write the Rdn of the Dn
if ( dn.isEmpty() )
{
out.writeByte( 0 );
}
else
{
out.writeByte( 1 );
Rdn rdn = dn.getRdn();
rdn.writeExternal( out );
}
// Then the attributes.
out.writeInt( entry.getAttributes().size() );
// Iterate through the keys. We store the Attribute
// here, to be able to restore it in the readExternal :
// we need access to the registries, which are not available
// in the ServerAttribute class.
for ( Attribute attribute : entry.getAttributes() )
{
AttributeType attributeType = attribute.getAttributeType();
// Write the oid to be able to restore the AttributeType when deserializing
// the attribute
String oid = attributeType.getOid();
out.writeUTF( oid );
// Write the attribute
attribute.writeExternal( out );
}
out.flush();
// Note : we don't store the ObjectClassAttribute. It has already
// been stored as an attribute.
if ( IS_DEBUG )