public static LdifContentRecord entryToLdifContentRecord( IEntry entry )
{
LdifContentRecord record = LdifContentRecord.create( entry.getDn().toString() );
IAttribute[] attributes = entry.getAttributes();
for ( int i = 0; i < attributes.length; i++ )
{
String name = attributes[i].getDescription();
IValue[] values = attributes[i].getValues();
for ( int ii = 0; ii < values.length; ii++ )
{
IValue value = values[ii];
if ( value.getRawValue() instanceof LdifPart )
{
LdifPart part = ( LdifPart ) value.getRawValue();
if ( part instanceof LdifCommentLine )
{
record.addComment( ( LdifCommentLine ) part );
}
}
else if ( value.isString() )
{
record.addAttrVal( LdifAttrValLine.create( name, value.getStringValue() ) );
}
else
{
record.addAttrVal( LdifAttrValLine.create( name, value.getBinaryValue() ) );
}
}
}
record.finish( LdifSepLine.create() );
return record;
}