/** * Indicates if the value needs to be encoded as Base64 * * @param value the value to check * @return true if the value needs to be encoded as Base64 */ public static boolean needsBase64Encoding( Object value ) { if ( value instanceof Value ) { return false; } else if ( value instanceof byte[] ) { return true; } else if ( value instanceof String ) { return !LdifUtils.isLDIFSafe( ( String ) value ); } return true; }
if ( !LdifUtils.isLDIFSafe( str ) )
if ( !LdifUtils.isLDIFSafe( str ) )
if ( !LdifUtils.isLDIFSafe( str ) )
/** * Convert an Entry as LDIF * * @param entry the Entry to convert * @param length the expected line length * @return the corresponding LDIF code as a String */ public static String convertToLdif( Entry entry, int length ) { StringBuilder sb = new StringBuilder(); if ( entry.getDn() != null ) { // First, dump the Dn if ( isLDIFSafe( entry.getDn().getName() ) ) { sb.append( stripLineToNChars( "dn: " + entry.getDn().getName(), length ) ); } else { sb.append( stripLineToNChars( "dn:: " + encodeBase64( entry.getDn().getName() ), length ) ); } sb.append( '\n' ); } // Then all the attributes for ( Attribute attribute : entry ) { sb.append( convertToLdif( attribute, length ) ); } return sb.toString(); }
/** * Convert an Entry as LDIF * * @param entry the Entry to convert * @param length the expected line length * @return the corresponding LDIF code as a String */ public static String convertToLdif( Entry entry, int length ) { StringBuilder sb = new StringBuilder(); if ( entry.getDn() != null ) { // First, dump the Dn if ( isLDIFSafe( entry.getDn().getName() ) ) { sb.append( stripLineToNChars( "dn: " + entry.getDn().getName(), length ) ); } else { sb.append( stripLineToNChars( "dn:: " + encodeBase64( entry.getDn().getName() ), length ) ); } sb.append( '\n' ); } // Then all the attributes for ( Attribute attribute : entry ) { sb.append( convertToLdif( attribute, length ) ); } return sb.toString(); }
/** * Convert an Entry as LDIF * * @param entry the Entry to convert * @param length the expected line length * @return the corresponding LDIF code as a String */ public static String convertToLdif( Entry entry, int length ) { StringBuilder sb = new StringBuilder(); if ( entry.getDn() != null ) { // First, dump the Dn if ( isLDIFSafe( entry.getDn().getName() ) ) { sb.append( stripLineToNChars( "dn: " + entry.getDn().getName(), length ) ); } else { sb.append( stripLineToNChars( "dn:: " + encodeBase64( entry.getDn().getName() ), length ) ); } sb.append( '\n' ); } // Then all the attributes for ( Attribute attribute : entry ) { sb.append( convertToLdif( attribute, length ) ); } return sb.toString(); }
if ( LdifUtils.isLDIFSafe( dnStr ) )
if ( LdifUtils.isLDIFSafe( dnStr ) )
if ( LdifUtils.isLDIFSafe( dnStr ) )
if ( isLDIFSafe( entry.getDn().getName() ) )
if ( isLDIFSafe( entry.getDn().getName() ) )
if ( isLDIFSafe( entry.getDn().getName() ) )