Class EntryReader
- Since:
- 14.5
- Author:
- mst
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
getBER
(AttributeType at) Get the ASN1 BER value for the given single-valued attribute typebyte[]
Get the binary representation for the given single-valued attribute type.Returns a Boolean representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.getBoolean
(AttributeType at, Boolean def) Returns a Boolean representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.int
getInt
(AttributeType at, int def) Returns an int representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.Returns an Integer representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.getInteger
(AttributeType at, Integer def) Returns an Integer representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.Returns the String representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.getString
(AttributeType at, String def) Returns the String representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.Return all values from multi valued attribute specified by AttributeType as an ArrayList of strings or null when attribute is not set or has no valuesgetStringArrayList
(AttributeType at, ArrayList<String> def) Return all values from multi valued attribute specified by AttributeType as an ArrayList of stringsboolean
has
(AttributeType at) Return true when entry contains attribute of specific type (trying to get it).boolean
has
(AttributeType at, String value) Return true when entry contains attribute of specific type and contains specified value.boolean
has
(AttributeType at, Collection<String> values) Return true when entry contains attribute of specific type and contains specified values.
-
Constructor Details
-
EntryReader
Default constructor.- Parameters:
entry
- entry to read (cannot be null)- Throws:
NullPointerException
- if entry is null
-
-
Method Details
-
getString
public String getString(AttributeType at, String def) throws BadAttributeTypeException, UnexpectedMultiValuedAttributeException Returns the String representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.If no such attribute exists, then def is returned.
Note that this method may only be used for AttributeTypes which have printable syntax.
- Parameters:
at
- AttributeType (not null)def
- default value returned when attribute is not set or has no value (may be null)- Throws:
BadAttributeTypeException
- if attribute type is not printableUnexpectedMultiValuedAttributeException
- if attribute has more than one valueNullPointerException
- if attribute type is nullNativeLibraryException
- if an unrecoverable error was detected by the native library
-
getString
public String getString(AttributeType at) throws BadAttributeTypeException, UnexpectedMultiValuedAttributeException Returns the String representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.If no such attribute exists, then null is returned.
Note that this method may only be used for AttributeTypes which have printable syntax.
- Parameters:
at
- AttributeType (not null)- Throws:
BadAttributeTypeException
- if attribute type is not printableUnexpectedMultiValuedAttributeException
- if attribute has more than one valueNullPointerException
- if attribute type is nullNativeLibraryException
- if an unrecoverable error was detected by the native library
-
getStringArrayList
public ArrayList<String> getStringArrayList(AttributeType at, ArrayList<String> def) throws BadAttributeTypeException Return all values from multi valued attribute specified by AttributeType as an ArrayList of strings- Parameters:
at
- AttributeType (not null)def
- default value returned when attribute is not set or has no value (may be null)- Throws:
BadAttributeTypeException
- if attribute type is not printableNullPointerException
- if attribute type is nullNativeLibraryException
- if an unrecoverable error was detected by the native library
-
getStringArrayList
Return all values from multi valued attribute specified by AttributeType as an ArrayList of strings or null when attribute is not set or has no values- Parameters:
at
- AttributeType (not null)- Throws:
BadAttributeTypeException
- if attribute type is not printableNullPointerException
- if attribute type is nullNativeLibraryException
- if an unrecoverable error was detected by the native library
-
getInteger
public Integer getInteger(AttributeType at, Integer def) throws BadAttributeTypeException, UnexpectedMultiValuedAttributeException Returns an Integer representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.If no such attribute exists, or if the attribute does exist but has a String representation which does not correspond to an integer, or has a String representation of zero length, then def is returned.
- Parameters:
at
- AttributeType (not null)def
- default value returned when attribute is not set or has no value (may be null)- Throws:
BadAttributeTypeException
- if attribute type is not printableUnexpectedMultiValuedAttributeException
- if attribute has more than one valueNullPointerException
- if attribute type is nullNativeLibraryException
- if an unrecoverable error was detected by the native library
-
getInteger
public Integer getInteger(AttributeType at) throws BadAttributeTypeException, UnexpectedMultiValuedAttributeException Returns an Integer representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.If no such attribute exists, or if the attribute does exist but has a String representation which does not correspond to an integer, or has a String representation of zero length, then null is returned.
- Parameters:
at
- AttributeType (not null)- Throws:
BadAttributeTypeException
- if attribute type is not printableUnexpectedMultiValuedAttributeException
- if attribute has more than one valueNullPointerException
- if attribute type is nullNativeLibraryException
- if an unrecoverable error was detected by the native library
-
getInt
public int getInt(AttributeType at, int def) throws BadAttributeTypeException, UnexpectedMultiValuedAttributeException Returns an int representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.If no such attribute exists, or if the attribute does exist but has a String representation which does not correspond to an integer, or has a String representation of zero length, then def is returned.
- Parameters:
at
- AttributeType (not null)def
- default value returned when attribute is not set or has no value- Returns:
- Int representation of the specified attribute
- Throws:
BadAttributeTypeException
- if attribute type is not printableUnexpectedMultiValuedAttributeException
- if attribute has more than one value- Since:
- 15.0
-
getBoolean
public Boolean getBoolean(AttributeType at, Boolean def) throws BadAttributeTypeException, UnexpectedMultiValuedAttributeException Returns a Boolean representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.If no such attribute exists, or if the attribute does exist but has a String representation which does not correspond to a boolean (allowed string values are case insensitive "true" or "false" only), then def is returned.
- Parameters:
at
- AttributeType (not null)def
- default value returned when attribute is not set or has no/bad value (may be null)- Returns:
- Boolean value
- Throws:
BadAttributeTypeException
- if attribute type is not printableUnexpectedMultiValuedAttributeException
- if attribute has more than one valueNullPointerException
- if attribute type is nullNativeLibraryException
- if an unrecoverable error was detected by the native library
-
getBoolean
public Boolean getBoolean(AttributeType at) throws BadAttributeTypeException, UnexpectedMultiValuedAttributeException Returns a Boolean representation of the specified attribute, provided that the entry contains such an attribute and that the attribute has a single value.If no such attribute exists, or if the attribute does exist but has a String representation which does not correspond to a boolean (allowed string values are case insensitive "true" or "false" only), then
null
value is returned.- Parameters:
at
- AttributeType (not null)- Returns:
- Boolean value
- Throws:
BadAttributeTypeException
- if attribute type is not printableUnexpectedMultiValuedAttributeException
- if attribute has more than one valueNullPointerException
- if attribute type is nullNativeLibraryException
- if an unrecoverable error was detected by the native library
-
getBinary
Get the binary representation for the given single-valued attribute type.- Parameters:
at
- attribute type- Returns:
- binary representation of the String value for the attribute
if it has one, or
null<,code> if there is no attribute in the entry, there is no values, or if there is no String representation
- Throws:
UnexpectedMultiValuedAttributeException
- if this function is called for a multivalued attribute- Since:
- 15.0
-
getBER
Get the ASN1 BER value for the given single-valued attribute type- Parameters:
at
- attribute type- Returns:
- ASN1 value for the attribute if it has a BER representation,
or
null
if there is no such attribute - Throws:
UnexpectedMultiValuedAttributeException
- if this function is called for a multivalued attribute- Since:
- 15.0
-
has
Return true when entry contains attribute of specific type and contains specified values.- Parameters:
at
- attribute typevalues
- values searched within entry- Returns:
- true when entry contains specific attribute and values
- Throws:
BadAttributeTypeException
- if attribute type is not printable- Since:
- 15.0
-
has
Return true when entry contains attribute of specific type and contains specified value.- Parameters:
at
- attribute typevalue
- value searched within entry- Returns:
- true when entry contains specific attribute and value
- Throws:
BadAttributeTypeException
- if attribute type is not printable- Since:
- 15.0
-
has
Return true when entry contains attribute of specific type (trying to get it).- Parameters:
at
- attribute type- Returns:
- true when attribute is within entry otherwise false
- Since:
- 15.0
-