org.apache.directory.shared.ldap.ldif
Class LdifUtils

java.lang.Object
  extended by org.apache.directory.shared.ldap.ldif.LdifUtils

public class LdifUtils
extends java.lang.Object

Some LDIF useful methods


Constructor Summary
LdifUtils()
           
 
Method Summary
static java.lang.String convertToLdif(javax.naming.directory.Attributes attrs)
          Convert an Attributes as LDIF
static boolean isLDIFSafe(java.lang.String str)
          Checks if the input String contains only safe values, that is, the data does not need to be encoded for use with LDIF.
static java.lang.String stripLineToNChars(java.lang.String str, int nbChars)
          Strips the String every n specified characters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LdifUtils

public LdifUtils()
Method Detail

isLDIFSafe

public static boolean isLDIFSafe(java.lang.String str)
Checks if the input String contains only safe values, that is, the data does not need to be encoded for use with LDIF. The rules for checking safety are based on the rules for LDIF (LDAP Data Interchange Format) per RFC 2849. The data does not need to be encoded if all the following are true: The data cannot start with the following char values: 00 (NUL) 10 (LF) 13 (CR) 32 (SPACE) 58 (:) 60 (<) Any character with value greater than 127 The data cannot contain any of the following char values: 00 (NUL) 10 (LF) 13 (CR) Any character with value greater than 127 The data cannot end with a space.

Parameters:
str - the String to be checked
Returns:
true if encoding not required for LDIF

convertToLdif

public static java.lang.String convertToLdif(javax.naming.directory.Attributes attrs)
                                      throws javax.naming.NamingException
Convert an Attributes as LDIF

Parameters:
attrs - the Attributes to convert
Returns:
the corresponding LDIF code as a String
Throws:
javax.naming.NamingException - If a naming exception is encountered.

stripLineToNChars

public static java.lang.String stripLineToNChars(java.lang.String str,
                                                 int nbChars)
Strips the String every n specified characters

Parameters:
str - the string to strip
nbChars - the number of characters
Returns:
the stripped String


Copyright © 2004-2011. All Rights Reserved.