AbstractPropertyData<?> property = null;
if (propDef != null) {
switch (propDef.getPropertyType()) {
case STRING:
property = new PropertyStringImpl();
{
List<String> propertyValues = null;
if (values != null) {
propertyValues = new ArrayList<String>();
for (Object obj : values) {
if (obj instanceof String) {
propertyValues.add(obj.toString());
} else {
throw new CmisRuntimeException("Invalid property value: " + obj);
}
}
}
((PropertyStringImpl) property).setValues(propertyValues);
}
break;
case ID:
property = new PropertyIdImpl();
{
List<String> propertyValues = null;
if (values != null) {
propertyValues = new ArrayList<String>();
for (Object obj : values) {
if (obj instanceof String) {
propertyValues.add(obj.toString());
} else {
throw new CmisRuntimeException("Invalid property value: " + obj);
}
}
}
((PropertyIdImpl) property).setValues(propertyValues);
}
break;
case BOOLEAN:
property = new PropertyBooleanImpl();
{
List<Boolean> propertyValues = null;
if (values != null) {
propertyValues = new ArrayList<Boolean>();
for (Object obj : values) {
if (obj instanceof Boolean) {
propertyValues.add((Boolean) obj);
} else {
throw new CmisRuntimeException("Invalid property value: " + obj);
}
}
}
((PropertyBooleanImpl) property).setValues(propertyValues);
}
break;
case INTEGER:
property = new PropertyIntegerImpl();
{
List<BigInteger> propertyValues = null;
if (values != null) {
propertyValues = new ArrayList<BigInteger>();
for (Object obj : values) {
if (obj instanceof BigInteger) {
propertyValues.add((BigInteger) obj);
} else {
throw new CmisRuntimeException("Invalid property value: " + obj);
}
}
}
((PropertyIntegerImpl) property).setValues(propertyValues);
}
break;
case DECIMAL:
property = new PropertyDecimalImpl();
{
List<BigDecimal> propertyValues = null;
if (values != null) {
propertyValues = new ArrayList<BigDecimal>();
for (Object obj : values) {
if (obj instanceof BigDecimal) {
propertyValues.add((BigDecimal) obj);
} else if (obj instanceof BigInteger) {
propertyValues.add(new BigDecimal((BigInteger) obj));
} else {
throw new CmisRuntimeException("Invalid property value: " + obj);
}
}
}
((PropertyDecimalImpl) property).setValues(propertyValues);
}
break;
case DATETIME:
property = new PropertyDateTimeImpl();
{
List<GregorianCalendar> propertyValues = null;
if (values != null) {
propertyValues = new ArrayList<GregorianCalendar>();
for (Object obj : values) {
if (obj instanceof Number) {
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
cal.setTimeInMillis(((Number) obj).longValue());
propertyValues.add(cal);
} else {
throw new CmisRuntimeException("Invalid property value: " + obj);
}
}
}
((PropertyDateTimeImpl) property).setValues(propertyValues);
}
break;
case HTML:
property = new PropertyHtmlImpl();
{
List<String> propertyValues = null;
if (values != null) {
propertyValues = new ArrayList<String>();
for (Object obj : values) {
if (obj instanceof String) {
propertyValues.add(obj.toString());
} else {
throw new CmisRuntimeException("Invalid property value: " + obj);
}
}
}
((PropertyHtmlImpl) property).setValues(propertyValues);
}
break;
case URI:
property = new PropertyUriImpl();
{
List<String> propertyValues = null;
if (values != null) {
propertyValues = new ArrayList<String>();
for (Object obj : values) {
if (obj instanceof String) {
propertyValues.add(obj.toString());
} else {
throw new CmisRuntimeException("Invalid property value: " + obj);
}
}
}
((PropertyUriImpl) property).setValues(propertyValues);
}
break;
}
property.setId(id);
property.setDisplayName(propDef.getDisplayName());
property.setQueryName(propDef.getQueryName());
property.setLocalName(propDef.getLocalName());
} else {
// this else block should only be reached in rare circumstances
// it may return incorrect types
if (values == null) {
property = new PropertyStringImpl();
((PropertyStringImpl) property).setValues(null);
} else {
Object firstValue = values.get(0);
if (firstValue instanceof Boolean) {
property = new PropertyBooleanImpl();
List<Boolean> propertyValues = new ArrayList<Boolean>();
for (Object obj : values) {
if (obj instanceof Boolean) {
propertyValues.add((Boolean) obj);
} else {
throw new CmisRuntimeException("Invalid property value: " + obj);
}
}
((PropertyBooleanImpl) property).setValues(propertyValues);
} else if (firstValue instanceof BigInteger) {
property = new PropertyIntegerImpl();
List<BigInteger> propertyValues = new ArrayList<BigInteger>();
for (Object obj : values) {
if (obj instanceof BigInteger) {
propertyValues.add((BigInteger) obj);
} else {
throw new CmisRuntimeException("Invalid property value: " + obj);
}
}
((PropertyIntegerImpl) property).setValues(propertyValues);
} else if (firstValue instanceof BigDecimal) {
property = new PropertyDecimalImpl();
List<BigDecimal> propertyValues = new ArrayList<BigDecimal>();
for (Object obj : values) {
if (obj instanceof BigDecimal) {
propertyValues.add((BigDecimal) obj);
} else if (obj instanceof BigInteger) {
propertyValues.add(new BigDecimal((BigInteger) obj));
} else {
throw new CmisRuntimeException("Invalid property value: " + obj);
}
}
((PropertyDecimalImpl) property).setValues(propertyValues);
} else {
property = new PropertyStringImpl();
List<String> propertyValues = new ArrayList<String>();
for (Object obj : values) {
if (obj instanceof String) {
propertyValues.add((String) obj);
} else {