Class LdifParser
- All Implemented Interfaces:
- org.springframework.beans.factory.InitializingBean,- Parser
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 SummaryConstructorsConstructorDescriptionDefault constructor.LdifParser(boolean caseInsensitive) Creates a LdifParser with the indicated case sensitivity setting.LdifParser(File file) Convenience constructor: accepts a File object.LdifParser(org.springframework.core.io.Resource resource) Convenience constructor for resource specification.LdifParser(org.springframework.core.io.Resource resource, boolean caseInsensitive) Creates an LdifParser for the specified resource with the provided case sensitivity setting.
- 
Method SummaryModifier and TypeMethodDescriptionvoidvoidclose()Closes the resource after parsing.Parses the next record from the resource.booleanTrue if the resource contains more records; false otherwise.booleanisReady()Indicates whether or not the parser is ready to to return results.voidopen()Opens the resource: the resource must be opened prior to parsing.voidreset()Resets the line read parser.voidPolicy object enforcing the rules for acceptable attributes.voidsetCaseInsensitive(boolean caseInsensitive) Sets the control parameter for specifying case sensitivity on creation of theAttributesobject.voidsetRecordSpecification(Specification<LdapAttributes> specification) Policy object for enforcing rules to acceptable LDAP objects.voidsetResource(org.springframework.core.io.Resource resource) Sets the resource to parse.voidsetSeparatorPolicy(SeparatorPolicy separatorPolicy) Set the separator policy.
- 
Constructor Details- 
LdifParserpublic LdifParser()Default constructor.
- 
LdifParserpublic LdifParser(boolean caseInsensitive) Creates a LdifParser with the indicated case sensitivity setting.- Parameters:
- caseInsensitive- Case sensitivity setting for LdapAttributes objects returned by the parser.
 
- 
LdifParserpublic LdifParser(org.springframework.core.io.Resource resource, boolean caseInsensitive) Creates an LdifParser for the specified resource with the provided case sensitivity setting.- Parameters:
- resource- The resource to parse.
- caseInsensitive- Case sensitivity setting for LdapAttributes objects returned by the parser.
 
- 
LdifParserpublic LdifParser(org.springframework.core.io.Resource resource) Convenience constructor for resource specification.- Parameters:
- resource- The resource to parse.
 
- 
LdifParserConvenience constructor: accepts a File object.- Parameters:
- file- The file to parse.
 
 
- 
- 
Method Details- 
setSeparatorPolicySet the separator policy. The default separator policy should suffice for most needs.- Parameters:
- separatorPolicy- Separator policy.
 
- 
setAttributeValidationPolicyPolicy object enforcing the rules for acceptable attributes.- Parameters:
- avPolicy- Attribute validation policy.
 
- 
setRecordSpecificationPolicy object for enforcing rules to acceptable LDAP objects. This policy may be used to enforce schema restrictions.- Parameters:
- specification-
 
- 
setResourcepublic void setResource(org.springframework.core.io.Resource resource) Description copied from interface:ParserSets the resource to parse.- Specified by:
- setResourcein interface- Parser
- Parameters:
- resource- The resource to parse.
 
- 
setCaseInsensitivepublic void setCaseInsensitive(boolean caseInsensitive) Description copied from interface:ParserSets the control parameter for specifying case sensitivity on creation of theAttributesobject.- Specified by:
- setCaseInsensitivein interface- Parser
- Parameters:
- caseInsensitive- The resource to parse.
 
- 
openDescription copied from interface:ParserOpens the resource: the resource must be opened prior to parsing.- Specified by:
- openin interface- Parser
- Throws:
- IOException- if a problem is encountered while trying to open the resource.
 
- 
isReadyDescription copied from interface:ParserIndicates whether or not the parser is ready to to return results.- Specified by:
- isReadyin interface- Parser
- Returns:
- boolean indicator
- Throws:
- IOException- if there is a problem with the underlying resource.
 
- 
closeDescription copied from interface:ParserCloses the resource after parsing.- Specified by:
- closein interface- Parser
- Throws:
- IOException- if a problem is encountered while trying to close the resource.
 
- 
resetDescription copied from interface:ParserResets the line read parser.- Specified by:
- resetin interface- Parser
- Throws:
- IOException- if a problem is encountered while trying to reset the resource.
 
- 
hasMoreRecordsDescription copied from interface:ParserTrue if the resource contains more records; false otherwise.- Specified by:
- hasMoreRecordsin interface- Parser
- Returns:
- boolean indicating whether or not the end of record has been reached.
- Throws:
- IOException- if a problem is encountered while trying to validate the resource is ready.
 
- 
getRecordDescription copied from interface:ParserParses the next record from the resource.- Specified by:
- getRecordin interface- Parser
- Returns:
- LdapAttributes object representing the record parsed.
- Throws:
- IOException- if a problem is encountered while trying to read from the resource.
 
- 
afterPropertiesSet- Specified by:
- afterPropertiesSetin interface- org.springframework.beans.factory.InitializingBean
- Throws:
- Exception
 
 
-