@Test(expected = NumberFormatException.class) public void testValueOfNotIllegalInput() { formatter.valueOf("new Foo()", getVM().mirrorOf(10.0).type(), new HashMap<>()); fail("Set value for object is not supported."); }
@Override public Value valueOf(String value, Type type, Map<String, Object> options) { VirtualMachine vm = type.virtualMachine(); char signature0 = type.signature().charAt(0); if (signature0 == LONG || signature0 == INT || signature0 == SHORT || signature0 == BYTE) { long number = parseNumber(value); if (signature0 == LONG) { return vm.mirrorOf(number); } else if (signature0 == INT) { return vm.mirrorOf((int) number); } else if (signature0 == SHORT) { return vm.mirrorOf((short) number); } else if (signature0 == BYTE) { return vm.mirrorOf((byte) number); } } else if (hasFraction(signature0)) { double doubleNumber = parseFloatDouble(value); if (signature0 == DOUBLE) { return vm.mirrorOf(doubleNumber); } else { return vm.mirrorOf((float) doubleNumber); } } throw new UnsupportedOperationException(String.format("%s is not a numeric type.", type.name())); }
NumericFormatter implements IValueFormatter { @Override public Value valueOf(String value, Type type, Map<String, Object> options) { VirtualMachine vm = type.virtualMachine(); char signature0 = type.signature().charAt(0); if (signature0 == LONG || signature0 == INT || signature0 == SHORT || signature0 == BYTE) { long number = parseNumber(value); if (signature0 == LONG) { return vm.mirrorOf(number); } else if (signature0 == INT) { return vm.mirrorOf((int) number); } else if (signature0 == SHORT) { return vm.mirrorOf((short) number); } else if (signature0 == BYTE) { return vm.mirrorOf((byte) number); } } else if (hasFraction(signature0)) { double doubleNumber = parseFloatDouble(value); if (signature0 == DOUBLE) { return vm.mirrorOf(doubleNumber); } else { return vm.mirrorOf((float) doubleNumber); } } throw new UnsupportedOperationException(String.format("%s is not a numeric type.", type.name())); } }
NumericFormatter implements IValueFormatter { @Override public Value valueOf(String value, Type type, Map<String, Object> options) { VirtualMachine vm = type.virtualMachine(); char signature0 = type.signature().charAt(0); if (signature0 == LONG || signature0 == INT || signature0 == SHORT || signature0 == BYTE) { long number = parseNumber(value); if (signature0 == LONG) { return vm.mirrorOf(number); } else if (signature0 == INT) { return vm.mirrorOf((int) number); } else if (signature0 == SHORT) { return vm.mirrorOf((short) number); } else if (signature0 == BYTE) { return vm.mirrorOf((byte) number); } } else if (hasFraction(signature0)) { double doubleNumber = parseFloatDouble(value); if (signature0 == DOUBLE) { return vm.mirrorOf(doubleNumber); } else { return vm.mirrorOf((float) doubleNumber); } } throw new UnsupportedOperationException(String.format("%s is not a numeric type.", type.name())); }  }
NumericFormatter implements IValueFormatter { @Override public Value valueOf(String value, Type type, Map<String, Object> options) { VirtualMachine vm = type.virtualMachine(); char signature0 = type.signature().charAt(0); if (signature0 == LONG || signature0 == INT || signature0 == SHORT || signature0 == BYTE) { long number = parseNumber(value); if (signature0 == LONG) { return vm.mirrorOf(number); } else if (signature0 == INT) { return vm.mirrorOf((int) number); } else if (signature0 == SHORT) { return vm.mirrorOf((short) number); } else if (signature0 == BYTE) { return vm.mirrorOf((byte) number); } } else if (hasFraction(signature0)) { double doubleNumber = parseFloatDouble(value); if (signature0 == DOUBLE) { return vm.mirrorOf(doubleNumber); } else { return vm.mirrorOf((float) doubleNumber); } } throw new UnsupportedOperationException(String.format("%s is not a numeric type.", type.name())); }  @Override String toString(Object obj, Map<String, Object> options); @Override Value valueOf(String value, Type type, Map<String, Object> options); @Override boolean acceptType(Type type, Map<String, Object> options); @Override Map<String, Object> getDefaultOptions(); }
NumericFormatter implements IValueFormatter { @Override public Value valueOf(String value, Type type, Map<String, Object> options) { VirtualMachine vm = type.virtualMachine(); char signature0 = type.signature().charAt(0); if (signature0 == LONG || signature0 == INT || signature0 == SHORT || signature0 == BYTE) { long number = parseNumber(value); if (signature0 == LONG) { return vm.mirrorOf(number); } else if (signature0 == INT) { return vm.mirrorOf((int) number); } else if (signature0 == SHORT) { return vm.mirrorOf((short) number); } else if (signature0 == BYTE) { return vm.mirrorOf((byte) number); } } else if (hasFraction(signature0)) { double doubleNumber = parseFloatDouble(value); if (signature0 == DOUBLE) { return vm.mirrorOf(doubleNumber); } else { return vm.mirrorOf((float) doubleNumber); } } throw new UnsupportedOperationException(String.format("%s is not a numeric type.", type.name())); }  @Override String toString(Object obj, Map<String, Object> options); @Override Value valueOf(String value, Type type, Map<String, Object> options); @Override boolean acceptType(Type type, Map<String, Object> options); @Override Map<String, Object> getDefaultOptions(); static final String NUMERIC_FORMAT_OPTION; static final String NUMERIC_PRECISION_OPTION; }