fieldables.add( field );
}
private Object buildAttributeImpl(AttributeImpl attr) {
if ( attr instanceof AnalysisRequestHandlerBase.TokenTrackingAttributeImpl ) {
GenericRecord record = new GenericData.Record( protocol.getType( "TokenTrackingAttribute" ) );
int[] positions = ( (AnalysisRequestHandlerBase.TokenTrackingAttributeImpl) attr ).getPositions();
List<Integer> fullPositions = new ArrayList<Integer>( positions.length );
for ( int position : positions ) {
fullPositions.add( position );
}
record.put( "positions", fullPositions );
return record;
}
else if (attr instanceof CharTermAttributeImpl) {
GenericRecord record = new GenericData.Record( protocol.getType( "CharTermAttribute" ) );
CharTermAttribute charAttr = (CharTermAttribute) attr;
record.put( "sequence", charAttr.toString() );
return record;
}
else if (attr instanceof PayloadAttribute) {
GenericRecord record = new GenericData.Record( protocol.getType( "PayloadAttribute" ) );
PayloadAttribute payloadAttr = (PayloadAttribute) attr;
record.put( "payload", ByteBuffer.wrap( payloadAttr.getPayload().toByteArray() ) );
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( attr ) );
}