org.apache.directory.shared.ldap.codec.util
Class LdapURL

java.lang.Object
  extended by org.apache.directory.shared.ldap.codec.util.LdapURL

public class LdapURL
extends java.lang.Object

Decodes a LdapUrl, and checks that it complies with the RFC 2255. The grammar is the following : ldapurl = scheme "://" [hostport] ["/" [dn ["?" [attributes] ["?" [scope] ["?" [filter] ["?" extensions]]]]]] scheme = "ldap" attributes = attrdesc *("," attrdesc) scope = "base" / "one" / "sub" dn = LdapDN hostport = hostport from Section 5 of RFC 1738 attrdesc = AttributeDescription from Section 4.1.5 of RFC 2251 filter = filter from Section 4 of RFC 2254 extensions = extension *("," extension) extension = ["!"] extype ["=" exvalue] extype = token / xtoken exvalue = LDAPString token = oid from section 4.1 of RFC 2252 xtoken = ("X-" / "x-") token

Author:
Apache Directory Project

Field Summary
static LdapURL EMPTY_URL
          A null LdapURL
 
Constructor Summary
LdapURL()
          Construct an empty LdapURL
LdapURL(byte[] bytes)
          Create a new LdapURL after having parsed it.
LdapURL(java.lang.String string)
          Create a new LdapURL from a String after having parsed it.
 
Method Summary
static byte[] getAsciiBytes(java.lang.String data)
          Converts the specified string to byte array of ASCII characters.
 java.util.ArrayList getAttributes()
           
 byte[] getBytes()
           
 java.util.HashMap getCriticalExtensions()
           
 LdapDN getDn()
           
 java.util.HashMap getExtensions()
           
 java.lang.String getFilter()
           
 java.lang.String getHost()
           
 int getNbBytes()
           
 int getPort()
           
 java.lang.String getScheme()
           
 int getScope()
           
 java.lang.String getString()
           
static java.lang.String getString(byte[] data, int offset, int length, java.lang.String charset)
          From commons-httpclients.
static java.lang.String getString(byte[] data, java.lang.String charset)
          From commons-httpclients.
 void parse(char[] chars)
          Parse a LdapURL
 java.lang.String toString()
          Get a string representation of a LdapURL.
static java.lang.String urlEncode(java.lang.String string, boolean doubleEncode)
          Encode a String to avoid special characters *NOTE* : this is an ugly function, just needed because the RFC 2255 is VERY unclear about the way LDAP searches are to be encoded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_URL

public static final transient LdapURL EMPTY_URL
A null LdapURL

Constructor Detail

LdapURL

public LdapURL()
Construct an empty LdapURL


LdapURL

public LdapURL(java.lang.String string)
        throws LdapURLEncodingException
Create a new LdapURL from a String after having parsed it.

Parameters:
string - TheString that contains the LDAPURL
Throws:
LdapURLEncodingException - If the String does not comply with RFC 2255

LdapURL

public LdapURL(byte[] bytes)
        throws LdapURLEncodingException
Create a new LdapURL after having parsed it.

Parameters:
bytes - The byte buffer that contains the LDAPURL
Throws:
LdapURLEncodingException - If the byte array does not comply with RFC 2255
Method Detail

parse

public void parse(char[] chars)
           throws LdapURLEncodingException
Parse a LdapURL

Parameters:
chars - The chars containing the URL
Throws:
LdapURLEncodingException - If the URL is invalid

getString

public static java.lang.String getString(byte[] data,
                                         int offset,
                                         int length,
                                         java.lang.String charset)
From commons-httpclients. Converts the byte array of HTTP content characters to a string. If the specified charset is not supported, default system encoding is used.

Parameters:
data - the byte array to be encoded
offset - the index of the first byte to encode
length - the number of bytes to encode
charset - the desired character encoding
Returns:
The result of the conversion.
Since:
3.0

getString

public static java.lang.String getString(byte[] data,
                                         java.lang.String charset)
From commons-httpclients. Converts the byte array of HTTP content characters to a string. If the specified charset is not supported, default system encoding is used.

Parameters:
data - the byte array to be encoded
charset - the desired character encoding
Returns:
The result of the conversion.
Since:
3.0

getAsciiBytes

public static byte[] getAsciiBytes(java.lang.String data)
Converts the specified string to byte array of ASCII characters.

Parameters:
data - the string to be encoded
Returns:
The string as a byte array.
Since:
3.0

urlEncode

public static java.lang.String urlEncode(java.lang.String string,
                                         boolean doubleEncode)
Encode a String to avoid special characters *NOTE* : this is an ugly function, just needed because the RFC 2255 is VERY unclear about the way LDAP searches are to be encoded. Some references to RFC 1738 are made, but they are really useless and inadequat.

Parameters:
string - The String to encode
doubleEncode - Set if we need to encode the comma
Returns:
An encoded string

toString

public java.lang.String toString()
Get a string representation of a LdapURL.

Overrides:
toString in class java.lang.Object
Returns:
A LdapURL string

getAttributes

public java.util.ArrayList getAttributes()
Returns:
Returns the attributes.

getCriticalExtensions

public java.util.HashMap getCriticalExtensions()
Returns:
Returns the criticalExtensions.

getDn

public LdapDN getDn()
Returns:
Returns the dn.

getExtensions

public java.util.HashMap getExtensions()
Returns:
Returns the extensions.

getFilter

public java.lang.String getFilter()
Returns:
Returns the filter.

getHost

public java.lang.String getHost()
Returns:
Returns the host.

getPort

public int getPort()
Returns:
Returns the port.

getScope

public int getScope()
Returns:
Returns the scope.

getScheme

public java.lang.String getScheme()
Returns:
Returns the scheme.

getNbBytes

public int getNbBytes()
Returns:
the number of bytes for this LdapURL

getBytes

public byte[] getBytes()
Returns:
the bytes representing this LdapURL

getString

public java.lang.String getString()
Returns:
the LdapURL as a String


Copyright © 2004-2010. All Rights Reserved.