public static Object[] getDocumentFields(SearchFactoryImplementor searchFactoryImplementor, Class<?> clazz, Document document, String[] fields) {
DocumentBuilderIndexedEntity<?> builderIndexedEntity = getDocumentBuilder( searchFactoryImplementor, clazz );
final int fieldNbr = fields.length;
Object[] result = new Object[fieldNbr];
ContextualException2WayBridge contextualBridge = new ContextualException2WayBridge();
contextualBridge.setClass( clazz );
if ( builderIndexedEntity.getIdKeywordName() != null ) {
final XMember member = builderIndexedEntity.getIdGetter();
final String fieldName = builderIndexedEntity.getIdKeywordName();
int matchingPosition = getFieldPosition( fields, fieldName );
if ( matchingPosition != -1 ) {
if ( member != null ) {
contextualBridge.pushMethod( member );
}
try {
populateResult(
fieldName,
builderIndexedEntity.getIdBridge(),
Store.YES,
fields,
result,
document,
contextualBridge,
matchingPosition
);
}
finally {
if ( member != null ) {
contextualBridge.popMethod();
}
}
}
}