// save all parts before changetype line
List partList = new ArrayList();
if ( dnErrorToken != null )
{
partList.add( new LdifInvalidPart( dnErrorToken.getOffset(), dnErrorToken.getValue() ) );
}
for ( int i = 0; i < commentLines.length; i++ )
{
partList.add( commentLines[i] );
}
if ( controlLine != null )
{
partList.add( controlLine );
if ( !controlLine.isValid() )
{
LdifToken errorToken = this.cleanupLine();
if ( errorToken != null )
{
partList.add( new LdifInvalidPart( errorToken.getOffset(), errorToken.getValue() ) );
}
}
}
// save comments and controls before changetype line
while ( changeTypeLine == null && ( commentLines.length > 0 || controlLine != null ) )
{
commentLines = getCommentLines();
for ( int i = 0; i < commentLines.length; i++ )
{
partList.add( commentLines[i] );
}
controlLine = getControlLine();
if ( controlLine != null )
{
partList.add( controlLine );
if ( !controlLine.isValid() )
{
LdifToken errorToken = this.cleanupLine();
if ( errorToken != null )
{
partList.add( new LdifInvalidPart( errorToken.getOffset(), errorToken.getValue() ) );
}
}
}
changeTypeLine = getChangeTypeLine();
}
if ( changeTypeLine != null )
{
if ( changeTypeLine.isAdd() )
{
record = new LdifChangeAddRecord( dnLine );
append( record, partList );
record.setChangeType( changeTypeLine );
if ( !changeTypeLine.isValid() )
{
this.cleanupLine( record );
}
parseAttrValRecord( record );
}
else if ( changeTypeLine.isDelete() )
{
record = new LdifChangeDeleteRecord( dnLine );
append( record, partList );
record.setChangeType( changeTypeLine );
if ( !changeTypeLine.isValid() )
{
this.cleanupLine( record );
}
parseChangeDeleteRecord( record );
}
else if ( changeTypeLine.isModify() )
{
record = new LdifChangeModifyRecord( dnLine );
append( record, partList );
record.setChangeType( changeTypeLine );
if ( !changeTypeLine.isValid() )
{
this.cleanupLine( record );
}
parseChangeModifyRecord( ( LdifChangeModifyRecord ) record );
}
else if ( changeTypeLine.isModDn() )
{
record = new LdifChangeModDnRecord( dnLine );
append( record, partList );
record.setChangeType( changeTypeLine );
if ( !changeTypeLine.isValid() )
{
this.cleanupLine( record );
}
parseChangeModDnRecord( ( LdifChangeModDnRecord ) record );
}
else
{
record = new LdifChangeRecord( dnLine );
append( record, partList );
record.setChangeType( changeTypeLine );
if ( !changeTypeLine.isValid() )
{
this.cleanupLine( record );
}
}
}
else
{
record = new LdifChangeRecord( dnLine );
append( record, partList );
}
model.addContainer( record );
}
else
{
// match attr-val-record
LdifContentRecord record = new LdifContentRecord( dnLine );
if ( dnErrorToken != null )
{
record.addInvalid( new LdifInvalidPart( dnErrorToken.getOffset(), dnErrorToken.getValue() ) );
}
for ( int i = 0; i < commentLines.length; i++ )
{
record.addComment( commentLines[i] );
}