public final class LdapUtils extends Object
Modifier and Type | Field and Description |
---|---|
private static String |
CLASSPATH_PREFIX
Prefix used to indicate a classpath resource.
|
private static Pattern |
CNTRL_PATTERN
Pattern that matches control characters.
|
private static 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 Pattern |
IPV4_PATTERN
Pattern to match ipv4 addresses.
|
private static Pattern |
IPV6_HEX_COMPRESSED_PATTERN
Pattern to match ipv6 hex compressed addresses.
|
private static 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(Object o1,
Object o2)
Determines equality of the supplied objects.
|
static byte[] |
base64Decode(String value)
This will decode the supplied value as a base64 encoded string to a byte[].
|
static String |
base64Encode(byte[] value)
This will convert the supplied value to a base64 encoded string.
|
static String |
base64Encode(String value)
This will convert the supplied value to a base64 encoded string.
|
static int |
computeHashCode(int seed,
Object... objects)
Computes a hash code for the supplied objects using the supplied seed.
|
private static int |
computeHashCode(Object object)
Computes a hash code for the supplied object.
|
static <T> T[] |
concatArrays(T[] first,
T[]... rest)
Concatenates multiple arrays together.
|
static InputStream |
getResource(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(String s)
Returns whether the supplied string represents an IP address.
|
static boolean |
isResource(String s)
Returns whether the supplied string starts with
CLASSPATH_PREFIX or FILE_PREFIX . |
static String |
percentDecode(String value)
Implementation of percent decoding as described in RFC 3986 section 2.1.
|
static String |
percentEncode(String value)
Implementation of percent encoding as described in RFC 3986 section 2.1.
|
static String |
percentEncodeControlChars(String value)
Converts all characters <= 0x1F and 0x7F to percent encoded hex.
|
static byte[] |
readInputStream(InputStream is)
Reads the data in the supplied stream and returns it as a byte array.
|
static byte[] |
readURL(URL url)
Reads the data at the supplied URL and returns it as a byte array.
|
static String |
utf8Encode(byte[] value)
This will convert the supplied value to a UTF-8 encoded string.
|
static byte[] |
utf8Encode(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 Pattern IPV4_PATTERN
private static final Pattern IPV6_STD_PATTERN
private static final Pattern IPV6_HEX_COMPRESSED_PATTERN
private static final Pattern CNTRL_PATTERN
private static final String CLASSPATH_PREFIX
private static final String FILE_PREFIX
public static String base64Encode(byte[] value)
value
- to base64 encodepublic static String base64Encode(String value)
value
- to base64 encodepublic static String utf8Encode(byte[] value)
value
- to UTF-8 encodepublic static byte[] utf8Encode(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 String percentEncode(String value)
value
- to encodepublic static String percentEncodeControlChars(String value)
value
- to encode control characters inpublic static byte[] base64Decode(String value)
value
- to base64 decodepublic static byte[] hexDecode(char[] value)
value
- to hex decodepublic static String percentDecode(String value)
value
- to decodepublic static byte[] readURL(URL url) throws IOException
url
- to readIOException
- if an error occurs reading datapublic static byte[] readInputStream(InputStream is) throws IOException
is
- stream to readIOException
- 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(Object o1, Object o2)
o1
- to test equality ofo2
- to test equality ofpublic static int computeHashCode(int seed, Object... objects)
seed
- odd/prime numberobjects
- to calculate hashCode forprivate static int computeHashCode(Object object)
Arrays
class. Otherwise Object.hashCode()
is invoked.object
- to calculate hash code forpublic static boolean isIPAddress(String s)
s
- to matchpublic static boolean isResource(String s)
CLASSPATH_PREFIX
or FILE_PREFIX
.s
- to inspectpublic static InputStream getResource(String path) throws IOException
path
- that designates a resourceIOException
- if the resource cannot be readIllegalArgumentException
- if path is not prefixed with either 'classpath:' or 'file:'Copyright © 2003-2019 Virginia Tech. All Rights Reserved.