// handle lists
if (instanceType.getSimpleVariety() == SchemaType.LIST)
return ((SimpleValue)obj).getListValue();
SimpleValue base = (SimpleValue)obj;
switch (instanceType.getPrimitiveType().getBuiltinTypeCode())
{
case SchemaType.BTC_BOOLEAN:
return base.getBooleanValue() ? Boolean.TRUE : Boolean.FALSE;
case SchemaType.BTC_BASE_64_BINARY:
case SchemaType.BTC_HEX_BINARY:
return base.getByteArrayValue();
case SchemaType.BTC_QNAME:
return base.getQNameValue();
case SchemaType.BTC_FLOAT:
return new Float(base.getFloatValue());
case SchemaType.BTC_DOUBLE:
return new Double(base.getDoubleValue());
case SchemaType.BTC_DECIMAL:
{
switch (instanceType.getDecimalSize())
{
case SchemaType.SIZE_BYTE:
return new Byte(base.getByteValue());
case SchemaType.SIZE_SHORT:
return new Short(base.getShortValue());
case SchemaType.SIZE_INT:
return new Integer(base.getIntValue());
case SchemaType.SIZE_LONG:
return new Long(base.getLongValue());
case SchemaType.SIZE_BIG_INTEGER:
return base.getBigIntegerValue();
default:
assert(false) : "invalid numeric bit count";
// fallthrough
case SchemaType.SIZE_BIG_DECIMAL:
return base.getBigDecimalValue();
}
}
case SchemaType.BTC_ANY_URI:
return base.getStringValue();
case SchemaType.BTC_DURATION:
return base.getGDurationValue();
case SchemaType.BTC_DATE_TIME:
case SchemaType.BTC_TIME:
case SchemaType.BTC_DATE:
case SchemaType.BTC_G_YEAR_MONTH:
case SchemaType.BTC_G_YEAR:
case SchemaType.BTC_G_MONTH_DAY:
case SchemaType.BTC_G_DAY:
case SchemaType.BTC_G_MONTH:
return base.getCalendarValue();
default:
assert(false) : "encountered nonprimitive type.";
// fallthrough
// NB: for string enums we just do java.lang.String
// when in the context of unions. It's easier on users.
case SchemaType.BTC_NOTATION:
case SchemaType.BTC_STRING:
case SchemaType.BTC_ANY_SIMPLE:
// return base.getStringValue();
return base.getStringValue();
}
}