// Synthesize a DataModel around our current value if possible
// TODO - for jsf 1.2 use method from superclass ?
Object current = getValue();
DataModel model;
if (current == null) {
model = new SequenceDataModel(new ListDataModel(Collections.EMPTY_LIST));
} else if (current instanceof ExtendedDataModel) {
model = (DataModel) current;
} else if (current instanceof DataModel) {
model = new SequenceDataModel((DataModel) current);
} else if (current instanceof List) {
model = new SequenceDataModel(new ListDataModel((List<?>) current));
} else if (Object[].class.isAssignableFrom(current.getClass())) {
model = new SequenceDataModel(new ArrayDataModel((Object[]) current));
} else if (current instanceof ResultSet) {
model = new SequenceDataModel(new ResultSetDataModel((ResultSet) current));
} else if (current instanceof Result) {
model = new SequenceDataModel(new ResultDataModel((Result) current));
} else {
model = new SequenceDataModel(new ScalarDataModel(current));
}
return (model);
}