/**
* Resolves the cell that the {@link Exchange} refers to.
*/
private HBaseRow resolveRow(Message message, int index) {
HBaseRow hRow = new HBaseRow();
HBaseCell hCell = new HBaseCell();
if (message != null) {
Object id = message.getHeader(HbaseAttribute.HBASE_ROW_ID.asHeader(index));
String rowClassName = message.getHeader(HbaseAttribute.HBASE_ROW_TYPE.asHeader(index), String.class);
Class<?> rowClass = rowClassName == null || rowClassName.isEmpty() ? String.class : message.getExchange().getContext().getClassResolver().resolveClass(rowClassName);
String columnFamily = (String) message.getHeader(HbaseAttribute.HBASE_FAMILY.asHeader(index));
String columnName = (String) message.getHeader(HbaseAttribute.HBASE_QUALIFIER.asHeader(index));
Object value = message.getHeader(HbaseAttribute.HBASE_VALUE.asHeader(index));
String valueClassName = message.getHeader(HbaseAttribute.HBASE_VALUE_TYPE.asHeader(index), String.class);
Class<?> valueClass = valueClassName == null || valueClassName.isEmpty() ? String.class : message.getExchange().getContext().getClassResolver().resolveClass(valueClassName);
//Id can be accepted as null when using get, scan etc.
if (id == null && columnFamily == null && columnName == null) {
return null;
}
hRow.setId(id);
hRow.setRowType(rowClass);
if (columnFamily != null && columnName != null) {
hCell.setQualifier(columnName);
hCell.setFamily(columnFamily);
hCell.setValue(value);
// String is the default value type
hCell.setValueType((valueClass != null) ? valueClass : String.class);
hRow.getCells().add(hCell);
}
}
return hRow;
}