use of com.amazon.ion.impl._Private_ScalarConversions.CantConvertException in project ion-java by amzn.
the class IonReaderTextSystemX method cast_cached_value.
private final void cast_cached_value(int new_type) {
// this should only be called when it actually has to do some work
assert !_v.hasValueOfType(new_type);
if (_v.isNull()) {
return;
}
if (IonType.SYMBOL.equals(_value_type)) {
switch(new_type) {
case AS_TYPE.string_value:
int sid = _v.getInt();
String sym = getSymbolTable().findKnownSymbol(sid);
_v.addValue(sym);
break;
case AS_TYPE.int_value:
sym = _v.getString();
sid = getSymbolTable().findSymbol(sym);
_v.addValue(sid);
break;
default:
{
String message = "can't cast symbol from " + getValueTypeName(_v.getAuthoritativeType()) + " to " + getValueTypeName(new_type);
throw new CantConvertException(message);
}
}
} else {
if (!_v.can_convert(new_type)) {
String message = "can't cast from " + getValueTypeName(_v.getAuthoritativeType()) + " to " + getValueTypeName(new_type);
throw new CantConvertException(message);
}
int fnid = _v.get_conversion_fnid(new_type);
_v.cast(fnid);
}
}
Aggregations