Package org.ldaptive.io
Class Dsmlv1Reader
- java.lang.Object
-
- org.ldaptive.io.Dsmlv1Reader
-
- All Implemented Interfaces:
SearchResultReader
public class Dsmlv1Reader extends Object implements SearchResultReader
Reads DSML version 1 from aReader
and returns aSearchResult
.
-
-
Field Summary
Fields Modifier and Type Field Description private static DocumentBuilderFactory
DOC_BUILDER_FACTORY
Document builder factory.private Reader
dsmlReader
Reader to read from.private SortBehavior
sortBehavior
Sort behavior.
-
Constructor Summary
Constructors Constructor Description Dsmlv1Reader(Reader reader)
Creates a new dsml reader.Dsmlv1Reader(Reader reader, SortBehavior sb)
Creates a new dsml reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected LdapAttribute
createLdapAttribute(String name, NodeList nodes)
Returns an ldap attribute derived from the supplied node list.protected LdapEntry
createLdapEntry(Element entryElement)
Converts the supplied DSML entry element into an ldap entry object.protected SearchResult
createSearchResult(Document doc)
Creates a search result that corresponds to the supplied DSML document.protected Object
getAttrValue(Element valueElement, boolean base64)
Returns the value of the supplied element taking into account whether the value needs to be base64 decoded.SearchResult
read()
Reads DSML data from the reader and returns a search result.
-
-
-
Field Detail
-
DOC_BUILDER_FACTORY
private static final DocumentBuilderFactory DOC_BUILDER_FACTORY
Document builder factory.
-
dsmlReader
private final Reader dsmlReader
Reader to read from.
-
sortBehavior
private final SortBehavior sortBehavior
Sort behavior.
-
-
Constructor Detail
-
Dsmlv1Reader
public Dsmlv1Reader(Reader reader)
Creates a new dsml reader.- Parameters:
reader
- to read DSML from
-
Dsmlv1Reader
public Dsmlv1Reader(Reader reader, SortBehavior sb)
Creates a new dsml reader.- Parameters:
reader
- to read DSML fromsb
- sort behavior of the ldap result
-
-
Method Detail
-
read
public SearchResult read() throws IOException
Reads DSML data from the reader and returns a search result.- Specified by:
read
in interfaceSearchResultReader
- Returns:
- search result derived from the DSML
- Throws:
IOException
- if an error occurs using the reader
-
createSearchResult
protected SearchResult createSearchResult(Document doc)
Creates a search result that corresponds to the supplied DSML document.- Parameters:
doc
- DSML to parse- Returns:
- search result
-
createLdapEntry
protected LdapEntry createLdapEntry(Element entryElement)
Converts the supplied DSML entry element into an ldap entry object.- Parameters:
entryElement
- to parse- Returns:
- ldap entry
-
createLdapAttribute
protected LdapAttribute createLdapAttribute(String name, NodeList nodes)
Returns an ldap attribute derived from the supplied node list.- Parameters:
name
- of the ldap attributenodes
- to parse- Returns:
- ldap attribute
-
getAttrValue
protected Object getAttrValue(Element valueElement, boolean base64)
Returns the value of the supplied element taking into account whether the value needs to be base64 decoded.- Parameters:
valueElement
- to read value frombase64
- whether to base64 decode the value- Returns:
- String or byte[] depending on the base64 flag
-
-