private void setFeatureValue(AnnotationFS annotationFS, Feature feature, Object o) {
if (feature != null && o != null) {
Type range = feature.getRange();
String rangeName = range.getName();
if (rangeName.equals(CAS.TYPE_NAME_STRING) && o instanceof String) {
annotationFS.setStringValue(feature, (String) o);
} else if (rangeName.equals(CAS.TYPE_NAME_INTEGER) && o instanceof Number) {
annotationFS.setIntValue(feature, ((Number) o).intValue());
} else if (rangeName.equals(CAS.TYPE_NAME_DOUBLE) && o instanceof Number) {
annotationFS.setDoubleValue(feature, ((Number) o).doubleValue());
} else if (rangeName.equals(CAS.TYPE_NAME_FLOAT) && o instanceof Number) {
annotationFS.setFloatValue(feature, ((Number) o).floatValue());
} else if (rangeName.equals(CAS.TYPE_NAME_BYTE) && o instanceof Number) {
annotationFS.setByteValue(feature, ((Number) o).byteValue());
} else if (rangeName.equals(CAS.TYPE_NAME_SHORT) && o instanceof Number) {
annotationFS.setShortValue(feature, ((Number) o).shortValue());
} else if (rangeName.equals(CAS.TYPE_NAME_LONG) && o instanceof Number) {
annotationFS.setLongValue(feature, ((Number) o).longValue());
} else if (rangeName.equals(CAS.TYPE_NAME_BOOLEAN) && o instanceof Boolean) {
annotationFS.setBooleanValue(feature, (Boolean) o);
} else if (rangeName.equals(CAS.TYPE_NAME_STRING) & o instanceof Type) {
annotationFS.setStringValue(feature, ((Type) o).getName());
}
} else {
throw new IllegalArgumentException("Not able to assign feature value: " + o + " -> "
+ feature);
}
}