List<FieldImpl> result )
{
int next = startOffsetInclusive;
while ( next < endOffsetExclusive )
{
PlexOfField startPlexOfField = plexOfFields.get( next );
if ( startPlexOfField.getFld().getBoundaryType() != FieldDescriptor.FIELD_BEGIN_MARK )
{
/* Start mark seems to be missing */
next++;
continue;
}
/*
* we have start node. end offset points to next node, separator or
* end
*/
int nextNodePositionInList = binarySearch( plexOfFields, next + 1,
endOffsetExclusive, startPlexOfField.getFcEnd() );
if ( nextNodePositionInList < 0 )
{
/*
* too bad, this start field mark doesn't have corresponding end
* field mark or separator field mark in fields table
*/
next++;
continue;
}
PlexOfField nextPlexOfField = plexOfFields
.get( nextNodePositionInList );
switch ( nextPlexOfField.getFld().getBoundaryType() )
{
case FieldDescriptor.FIELD_SEPARATOR_MARK:
{
PlexOfField separatorPlexOfField = nextPlexOfField;
int endNodePositionInList = binarySearch( plexOfFields,
nextNodePositionInList, endOffsetExclusive,
separatorPlexOfField.getFcEnd() );
if ( endNodePositionInList < 0 )
{
/*
* too bad, this separator field mark doesn't have
* corresponding end field mark in fields table
*/
next++;
continue;
}
PlexOfField endPlexOfField = plexOfFields
.get( endNodePositionInList );
if ( endPlexOfField.getFld().getBoundaryType() != FieldDescriptor.FIELD_END_MARK )
{
/* Not and ending mark */
next++;
continue;
}
FieldImpl field = new FieldImpl( startPlexOfField,
separatorPlexOfField, endPlexOfField );
result.add( field );
// adding included fields
if ( startPlexOfField.getFcStart() + 1 < separatorPlexOfField
.getFcStart() - 1 )
{
parseFieldStructureImpl( plexOfFields, next + 1,
nextNodePositionInList, result );
}
if ( separatorPlexOfField.getFcStart() + 1 < endPlexOfField
.getFcStart() - 1 )
{
parseFieldStructureImpl( plexOfFields,
nextNodePositionInList + 1, endNodePositionInList,
result );