record.put( "payload", ByteBuffer.wrap( payload.bytes, payload.offset, payload.length ) );
return record;
}
else if ( attr instanceof KeywordAttribute ) {
GenericRecord record = new GenericData.Record( protocol.getType( "KeywordAttribute" ) );
KeywordAttribute narrowedAttr = (KeywordAttribute) attr;
record.put( "isKeyword", narrowedAttr.isKeyword() );
return record;
}
else if ( attr instanceof PositionIncrementAttribute ) {
GenericRecord record = new GenericData.Record( protocol.getType( "PositionIncrementAttribute" ) );
PositionIncrementAttribute narrowedAttr = (PositionIncrementAttribute) attr;
record.put( "positionIncrement", narrowedAttr.getPositionIncrement() );
return record;
}
else if ( attr instanceof FlagsAttribute ) {
GenericRecord record = new GenericData.Record( protocol.getType( "FlagsAttribute" ) );
FlagsAttribute narrowedAttr = (FlagsAttribute) attr;
record.put( "flags", narrowedAttr.getFlags() );
return record;
}
else if ( attr instanceof TypeAttribute ) {
GenericRecord record = new GenericData.Record( protocol.getType( "TypeAttribute" ) );
TypeAttribute narrowedAttr = (TypeAttribute) attr;
record.put( "type", narrowedAttr.type() );
return record;
}
else if ( attr instanceof OffsetAttribute ) {
GenericRecord record = new GenericData.Record( protocol.getType( "OffsetAttribute" ) );
OffsetAttribute narrowedAttr = (OffsetAttribute) attr;
record.put( "startOffset", narrowedAttr.startOffset() );
record.put( "endOffset", narrowedAttr.endOffset() );
return record;
}
else if ( attr instanceof Serializable ) {
return ByteBuffer.wrap( toByteArray( (Serializable) attr ) );
}