@ThreadSafety(level=COMPLETELY_THREADSAFE) public final class ScriptUtils extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
addBinaryAttribute(com.unboundid.ldap.sdk.Entry entry,
java.lang.String attrName,
java.sql.Blob value,
int maxBytes)
Adds an
Attribute with the given attribute name and Blob
value to the given entry if the underlying byte array is not null or empty. |
static void |
addBooleanAttribute(com.unboundid.ldap.sdk.Entry entry,
java.lang.String attrName,
java.lang.Boolean value)
Adds an
Attribute with the given attribute name and boolean value
to the given entry if the value is not null. |
static void |
addDateAttribute(com.unboundid.ldap.sdk.Entry entry,
java.lang.String attrName,
java.util.Date date,
boolean includeMilliseconds)
Adds an
Attribute with the given attribute name and Date
value to the given entry if the value is not null. |
static void |
addNumericAttribute(com.unboundid.ldap.sdk.Entry entry,
java.lang.String attrName,
java.lang.Number value)
Adds an
Attribute with the given attribute name and numeric value
to the given entry if the value is not null. |
static void |
addStringAttribute(com.unboundid.ldap.sdk.Entry entry,
java.lang.String attrName,
java.lang.String value)
Adds an
Attribute with the given attribute name and string value to
the given entry if the value is not null. |
static boolean |
containsAnyValue(com.unboundid.ldap.sdk.Attribute attr,
java.lang.String... values)
Returns true if the given attribute is not null and contains any one or
more of the given string values; returns false otherwise.
|
static java.util.Map<java.lang.String,java.lang.String> |
dnToMap(com.unboundid.ldap.sdk.DN identifiableInfo)
Takes an identifier DN (such as the output from
idStringToDN(String,String) and
creates a hash map of the components (RDN attributes) to their respective
values. |
static java.sql.Timestamp |
getTimestampFromString(java.lang.String value)
Returns a SQL
Timestamp based on the string value that is passed
in. |
static com.unboundid.ldap.sdk.DN |
idStringToDN(java.lang.String identifiableInfo,
java.lang.String delimiter)
Takes an identifier string (for example from the database changelog table)
and creates a DN from the components.
|
static boolean |
isNullOrEmpty(java.lang.String value)
String helper method to check if a value is a null object
or empty string.
|
public static void addStringAttribute(com.unboundid.ldap.sdk.Entry entry, java.lang.String attrName, java.lang.String value)
Attribute
with the given attribute name and string value to
the given entry if the value is not null.entry
- an LDAP entry instance. May be null.attrName
- the name of the attribute to add to the entry. May not be
null.value
- the value for the attribute to add to the entry. May be null.public static void addNumericAttribute(com.unboundid.ldap.sdk.Entry entry, java.lang.String attrName, java.lang.Number value)
Attribute
with the given attribute name and numeric value
to the given entry if the value is not null.entry
- an LDAP entry instance. May be null.attrName
- the name of the attribute to add to the entry. May not be
null.value
- the value for the attribute to add to the entry. May be null.public static void addBooleanAttribute(com.unboundid.ldap.sdk.Entry entry, java.lang.String attrName, java.lang.Boolean value)
Attribute
with the given attribute name and boolean value
to the given entry if the value is not null. If the boolean is
true
, the attribute value will be the string "true", otherwise
it will be the string "false".entry
- an LDAP entry instance. May be null.attrName
- the name of the attribute to add to the entry. May not be
null.value
- the value for the attribute to add to the entry. May be null.public static void addDateAttribute(com.unboundid.ldap.sdk.Entry entry, java.lang.String attrName, java.util.Date date, boolean includeMilliseconds)
Attribute
with the given attribute name and Date
value to the given entry if the value is not null. The date is formatted
using the generalized time syntax with a four-digit year and an optional
milliseconds component (i.e. yyyyMMddHHmmss[.SSS]'Z').entry
- entry an LDAP entry instance. May be null.attrName
- the name of the attribute to add to the entry. May not be
null.date
- the Date value for the attribute to add to the entry. May be null.includeMilliseconds
- whether to include the milliseconds component in the attribute
valuepublic static void addBinaryAttribute(com.unboundid.ldap.sdk.Entry entry, java.lang.String attrName, java.sql.Blob value, int maxBytes)
Attribute
with the given attribute name and Blob
value to the given entry if the underlying byte array is not null or empty.
This method calls free()
on the Blob object after the
attribute has been added to the entry.entry
- an LDAP entry instance. May be null.attrName
- the name of the attribute to add to the entry. May not be
null.value
- the value for the attribute to add to the entry. May be null.maxBytes
- the maximum number of bytes to extract from the Blob
and add to the entry.public static boolean containsAnyValue(com.unboundid.ldap.sdk.Attribute attr, java.lang.String... values)
attr
- the Attribute
whose values to checkvalues
- the value(s) you are looking forpublic static boolean isNullOrEmpty(java.lang.String value)
value
- the String object to checkpublic static java.sql.Timestamp getTimestampFromString(java.lang.String value)
Timestamp
based on the string value that is passed
in. The string is parsed using generalized time syntax first with and then
without milliseconds (i.e. yyyyMMddHHmmss[.SSS]'Z'). If the string cannot
be parsed, null
is returned.value
- a string that represents a timestamp in generalized time formatpublic static com.unboundid.ldap.sdk.DN idStringToDN(java.lang.String identifiableInfo, java.lang.String delimiter)
The resulting DN will contain a RDN per component, and the relative order of RDNs will be consistent with the order of the components in the original identifier string. The components here are usually primary keys for the entry in the database.
identifiableInfo
- the identifier string for a given database entry. This cannot be
null.delimiter
- The delimiter used to split separate components of the
identifiable info. If this is null, the default of "%%" will be
used.public static java.util.Map<java.lang.String,java.lang.String> dnToMap(com.unboundid.ldap.sdk.DN identifiableInfo)
idStringToDN(String,String)
and
creates a hash map of the components (RDN attributes) to their respective
values. Each RDN will have a separate entry in the resulting map.
This method is meant to handle database entry identifier DNs, and as such does not handle DNs with multi-valued RDNs (i.e. pk1=John+pk2=Doe,groupID=123).
identifiableInfo
- the identifier DN for a particular database entry. This cannot be
null.