|
Spring LDAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.ldap.ldif.parser.LdifParser
public class LdifParser
The LdifParser
is the main class of the org.springframework.ldap.ldif
package.
This class reads lines from a resource and assembles them into an LdapAttributes
object.
The LdifParser
does ignores changetype LDIF entries as their usefulness in the
context of an application has yet to be determined.
Design
LdifParser
provides the main interface for operation but requires three supporting classes to
enable operation:
SeparatorPolicy
- establishes the mechanism by which lines are assembled into attributes.AttributeValidationPolicy
- ensures that attributes are correctly structured prior to parsing.Specification
- provides a mechanism by which object structure can be validated after assembly.
Usage
getRecord()
reads the next available record from the resource. Lines are read and
passed to the SeparatorPolicy
for interpretation. The parser continues to read
lines and appends them to the buffer until it encounters the start of a new attribute or an end of record
delimiter. When the new attribute or end of record is encountered, the buffer is passed to the
AttributeValidationPolicy
which ensures the buffer conforms to a valid
attribute definition as defined in RFC2849 and returns an LdapAttribute
object
which is then added to the record, an LdapAttributes
object. Upon encountering the
end of record, the record is validated by the Specification
policy and,
if valid, returned to the requester.
NOTE: By default, objects are not validated. If validation is required, an appropriate specification object must be set.
The parser requires the resource to be open()
prior to an invocation of getRecord()
.
hasMoreRecords()
can be used to loop over the resource until all records have been
retrieved. Likewise, the reset()
method will reset the resource.
Objects implementing the Attributes
interface are required to support a case sensitivity setting
which controls whether or not the attribute IDs of the object are case sensitive. The caseInsensitive
setting of the LdifParser
is passed to the constructor of any Attributes
created. The
default value for this setting is true so that case insensitive objects are created.
Constructor Summary | |
---|---|
LdifParser()
Default constructor. |
|
LdifParser(boolean caseInsensitive)
Creates a LdifParser with the indicated case sensitivity setting. |
|
LdifParser(File file)
Convenience constructor: accepts a File object. |
|
LdifParser(Resource resource)
Convenience constructor for resource specification. |
|
LdifParser(Resource resource,
boolean caseInsensitive)
Creates an LdifParser for the specified resource with the provided case sensitivity setting. |
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
void |
close()
Closes the resource after parsing. |
LdapAttributes |
getRecord()
Parses the next record from the resource. |
boolean |
hasMoreRecords()
True if the resource contains more records; false otherwise. |
boolean |
isReady()
Indicates whether or not the parser is ready to to return results. |
void |
open()
Opens the resource: the resource must be opened prior to parsing. |
void |
reset()
Resets the line read parser. |
void |
setAttributeValidationPolicy(AttributeValidationPolicy avPolicy)
Policy object enforcing the rules for acceptable attributes. |
void |
setCaseInsensitive(boolean caseInsensitive)
Sets the control parameter for specifying case sensitivity on creation of the Attributes object. |
void |
setRecordSpecification(Specification<LdapAttributes> specification)
Policy object for enforcing rules to acceptable LDAP objects. |
void |
setResource(Resource resource)
Sets the resource to parse. |
void |
setSeparatorPolicy(SeparatorPolicy separatorPolicy)
Set the separator policy. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LdifParser()
public LdifParser(boolean caseInsensitive)
caseInsensitive
- Case sensitivity setting for LdapAttributes objects returned by the parser.public LdifParser(Resource resource, boolean caseInsensitive)
resource
- The resource to parse.caseInsensitive
- Case sensitivity setting for LdapAttributes objects returned by the parser.public LdifParser(Resource resource)
resource
- The resource to parse.public LdifParser(File file)
file
- The file to parse.Method Detail |
---|
public void setSeparatorPolicy(SeparatorPolicy separatorPolicy)
separatorPolicy
- Separator policy.public void setAttributeValidationPolicy(AttributeValidationPolicy avPolicy)
avPolicy
- Attribute validation policy.public void setRecordSpecification(Specification<LdapAttributes> specification)
specification
- public void setResource(Resource resource)
Parser
setResource
in interface Parser
resource
- The resource to parse.public void setCaseInsensitive(boolean caseInsensitive)
Parser
Attributes
object.
setCaseInsensitive
in interface Parser
caseInsensitive
- The resource to parse.public void open() throws IOException
Parser
open
in interface Parser
IOException
- if a problem is encountered while trying to open the resource.public boolean isReady() throws IOException
Parser
isReady
in interface Parser
IOException
- if there is a problem with the underlying resource.public void close() throws IOException
Parser
close
in interface Parser
IOException
- if a problem is encountered while trying to close the resource.public void reset() throws IOException
Parser
reset
in interface Parser
IOException
public boolean hasMoreRecords() throws IOException
Parser
hasMoreRecords
in interface Parser
IOException
- if a problem is encountered while trying to validate the resource is ready.public LdapAttributes getRecord() throws IOException
Parser
getRecord
in interface Parser
IOException
- if a problem is encountered while trying to read from the resource.public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface InitializingBean
Exception
|
Spring LDAP | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |