private void buildLuceneDocument(SerializableDocument document, LuceneWorksBuilder hydrator) {
hydrator.defineDocument( document.getBoost() );
for ( SerializableFieldable field : document.getFieldables() ) {
if ( field instanceof SerializableCustomFieldable ) {
SerializableCustomFieldable safeField = ( SerializableCustomFieldable ) field;
hydrator.addFieldable( safeField.getInstance() );
}
else if ( field instanceof SerializableNumericField ) {
SerializableNumericField safeField = ( SerializableNumericField ) field;
if ( field instanceof SerializableIntField ) {
hydrator.addIntNumericField(
( ( SerializableIntField ) field ).getValue(),
safeField.getName(),
safeField.getPrecisionStep(),
safeField.getStore(),
safeField.isIndexed(),
safeField.isOmitNorms(),
safeField.isOmitTermFreqAndPositions()
);
}
else if ( field instanceof SerializableLongField ) {
hydrator.addLongNumericField(
( ( SerializableLongField ) field ).getValue(),
safeField.getName(),
safeField.getPrecisionStep(),
safeField.getStore(),
safeField.isIndexed(),
safeField.isOmitNorms(),
safeField.isOmitTermFreqAndPositions()
);
}
else if ( field instanceof SerializableFloatField ) {
hydrator.addFloatNumericField(
( ( SerializableFloatField ) field ).getValue(),
safeField.getName(),
safeField.getPrecisionStep(),
safeField.getStore(),
safeField.isIndexed(),
safeField.isOmitNorms(),
safeField.isOmitTermFreqAndPositions()
);
}
else if ( field instanceof SerializableDoubleField ) {
hydrator.addDoubleNumericField(
( ( SerializableDoubleField ) field ).getValue(),
safeField.getName(),
safeField.getPrecisionStep(),
safeField.getStore(),
safeField.isIndexed(),
safeField.isOmitNorms(),
safeField.isOmitTermFreqAndPositions()
);
}
else {
throw new SearchException( "Unknown SerializableNumericField: " + field.getClass() );
}
}
else if ( field instanceof SerializableField ) {
SerializableField safeField = ( SerializableField ) field;
Field luceneField;
if ( field instanceof SerializableBinaryField ) {
SerializableBinaryField reallySafeField = ( SerializableBinaryField ) field;
hydrator.addFieldWithBinaryData(
reallySafeField.getName(),
reallySafeField.getValue(),
reallySafeField.getOffset(),
reallySafeField.getLength(),
safeField.getBoost(),
safeField.isOmitNorms(),
safeField.isOmitTermFreqAndPositions()
);
}
else if ( field instanceof SerializableStringField ) {
SerializableStringField reallySafeField = ( SerializableStringField ) field;
hydrator.addFieldWithStringData(
reallySafeField.getName(),
reallySafeField.getValue(),
reallySafeField.getStore(),
reallySafeField.getIndex(),
reallySafeField.getTermVector(),
safeField.getBoost(),
safeField.isOmitNorms(),
safeField.isOmitTermFreqAndPositions()
);
}
else if ( field instanceof SerializableTokenStreamField ) {
SerializableTokenStreamField reallySafeField = ( SerializableTokenStreamField ) field;
hydrator.addFieldWithTokenStreamData(
reallySafeField.getName(),
reallySafeField.getValue().getStream(),
reallySafeField.getTermVector(),
safeField.getBoost(),
safeField.isOmitNorms(),
safeField.isOmitTermFreqAndPositions()
);
}
else if ( field instanceof SerializableReaderField ) {
SerializableReaderField reallySafeField = ( SerializableReaderField ) field;
hydrator.addFieldWithSerializableReaderData(
reallySafeField.getName(),
reallySafeField.getValue(),
reallySafeField.getTermVector(),
safeField.getBoost(),
safeField.isOmitNorms(),
safeField.isOmitTermFreqAndPositions()
);
}
else {
throw new SearchException( "Unknown SerializableField: " + field.getClass() );
}