public final class LdapUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
CLASSPATH_PREFIX
Prefix used to indicate a classpath resource.
|
private static java.lang.String |
FILE_PREFIX
Prefix used to indicate a file resource.
|
private static int |
HASH_CODE_PRIME
Prime number to assist in calculating hash codes.
|
private static java.util.regex.Pattern |
IPV4_PATTERN
Pattern to match ipv4 addresses.
|
private static java.util.regex.Pattern |
IPV6_HEX_COMPRESSED_PATTERN
Pattern to match ipv6 hex compressed addresses.
|
private static java.util.regex.Pattern |
IPV6_STD_PATTERN
Pattern to match ipv6 addresses.
|
private static int |
READ_BUFFER_SIZE
Size of buffer in bytes to use when reading files.
|
| Modifier | Constructor and Description |
|---|---|
private |
LdapUtils()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
areEqual(java.lang.Object o1,
java.lang.Object o2)
Determines equality of the supplied objects by delegating to their hashCode methods.
|
static byte[] |
base64Decode(java.lang.String value)
This will decode the supplied value as a base64 encoded string to a byte[].
|
static java.lang.String |
base64Encode(byte[] value)
This will convert the supplied value to a base64 encoded string.
|
static java.lang.String |
base64Encode(java.lang.String value)
This will convert the supplied value to a base64 encoded string.
|
static int |
computeHashCode(int seed,
java.lang.Object... objects)
Computes a hash code for the supplied objects using the supplied seed.
|
private static int |
computeHashCode(java.lang.Object object)
Computes a hash code for the supplied object.
|
static <T> T[] |
concatArrays(T[] first,
T[]... rest)
Concatenates multiple arrays together.
|
static java.io.InputStream |
getResource(java.lang.String path)
Parses the supplied path and returns an input stream based on the prefix in the path.
|
static byte[] |
hexDecode(char[] value)
This will decode the supplied value as a hex encoded string to a byte[].
|
static char[] |
hexEncode(byte[] value)
This will convert the supplied value to a hex encoded string.
|
static char[] |
hexEncode(char... value)
This will convert the supplied value to a hex encoded string.
|
static boolean |
isIPAddress(java.lang.String s)
Returns whether the supplied string represents an IP address.
|
static java.lang.String |
percentDecode(java.lang.String value)
Implementation of percent decoding as described in RFC 3986 section 2.1.
|
static java.lang.String |
percentEncode(java.lang.String value)
Implementation of percent encoding as described in RFC 3986 section 2.1.
|
static byte[] |
readInputStream(java.io.InputStream is)
Reads the data in the supplied stream and returns it as a byte array.
|
static byte[] |
readURL(java.net.URL url)
Reads the data at the supplied URL and returns it as a byte array.
|
static java.lang.String |
utf8Encode(byte[] value)
This will convert the supplied value to a UTF-8 encoded string.
|
static byte[] |
utf8Encode(java.lang.String value)
This will convert the supplied value to a UTF-8 encoded byte array.
|
private static final int READ_BUFFER_SIZE
private static final int HASH_CODE_PRIME
private static final java.util.regex.Pattern IPV4_PATTERN
private static final java.util.regex.Pattern IPV6_STD_PATTERN
private static final java.util.regex.Pattern IPV6_HEX_COMPRESSED_PATTERN
private static final java.lang.String CLASSPATH_PREFIX
private static final java.lang.String FILE_PREFIX
public static java.lang.String base64Encode(byte[] value)
value - to base64 encodepublic static java.lang.String base64Encode(java.lang.String value)
value - to base64 encodepublic static java.lang.String utf8Encode(byte[] value)
value - to UTF-8 encodepublic static byte[] utf8Encode(java.lang.String value)
value - to UTF-8 encodepublic static char[] hexEncode(byte[] value)
value - to hex encodepublic static char[] hexEncode(char... value)
value - to hex encodepublic static java.lang.String percentEncode(java.lang.String value)
value - to encodepublic static byte[] base64Decode(java.lang.String value)
value - to base64 decodepublic static byte[] hexDecode(char[] value)
value - to hex decodepublic static java.lang.String percentDecode(java.lang.String value)
value - to decodepublic static byte[] readURL(java.net.URL url)
throws java.io.IOException
url - to readjava.io.IOException - if an error occurs reading datapublic static byte[] readInputStream(java.io.InputStream is)
throws java.io.IOException
is - stream to readjava.io.IOException - if an error occurs reading datapublic static <T> T[] concatArrays(T[] first,
T[]... rest)
T - type of arrayfirst - array to concatenate. Cannot be null.rest - of the arrays to concatenate. May be null.public static boolean areEqual(java.lang.Object o1,
java.lang.Object o2)
o1 - to test equality ofo2 - to test equality ofpublic static int computeHashCode(int seed,
java.lang.Object... objects)
seed - odd/prime numberobjects - to calculate hashCode forprivate static int computeHashCode(java.lang.Object object)
Arrays class. Otherwise Object.hashCode() is invoked.object - to calculate hash code forpublic static boolean isIPAddress(java.lang.String s)
s - to matchpublic static java.io.InputStream getResource(java.lang.String path)
throws java.io.IOException
path - that designates a resourcejava.io.IOException - if the resource cannot be readjava.lang.IllegalArgumentException - if path is not prefixed with either 'classpath:' or 'file:'