public final static Character coerceToCharacter(final Object obj) throws IllegalArgumentException { if (obj == null || "".equals(obj)) { return new Character((char) 0); } if (obj instanceof String) { return new Character(((String) obj).charAt(0)); } if (ELArithmetic.isNumber(obj)) { return new Character((char) ((Number) obj).shortValue()); } Class objType = obj.getClass(); if (obj instanceof Character || objType == Character.TYPE) { return (Character) obj; } throw new IllegalArgumentException(MessageFactory.get("error.convert", obj, objType, Character.class)); }
public final static Character coerceToCharacter(final Object obj) throws IllegalArgumentException { if (obj == null || "".equals(obj)) { return new Character((char) 0); } if (obj instanceof String) { return new Character(((String) obj).charAt(0)); } if (ELArithmetic.isNumber(obj)) { return new Character((char) ((Number) obj).shortValue()); } Class objType = obj.getClass(); if (obj instanceof Character || objType == Character.TYPE) { return (Character) obj; } throw new IllegalArgumentException(MessageFactory.get("error.convert", obj, objType, Character.class)); }
public final static Character coerceToCharacter(final Object obj) throws IllegalArgumentException { if (obj == null || "".equals(obj)) { return new Character((char) 0); } if (obj instanceof String) { return new Character(((String) obj).charAt(0)); } if (ELArithmetic.isNumber(obj)) { return new Character((char) ((Number) obj).shortValue()); } Class objType = obj.getClass(); if (obj instanceof Character || objType == Character.TYPE) { return (Character) obj; } throw new IllegalArgumentException(MessageFactory.get("error.convert", obj, objType, Character.class)); }
protected final Number coerce(final Object obj) { if (isNumber(obj)) { return coerce((Number) obj); } if (obj instanceof String) { return coerce((String) obj); } if (obj == null || "".equals(obj)) { return coerce(ZERO); } Class objType = obj.getClass(); if (Character.class.equals(objType) || Character.TYPE == objType) { return coerce(new Short((short) ((Character) obj).charValue())); } throw new IllegalArgumentException(MessageFactory.get("el.convert", obj, objType)); }
protected final Number coerce(final Object obj) { if (isNumber(obj)) { return coerce((Number) obj); } if (obj instanceof String) { return coerce((String) obj); } if (obj == null || "".equals(obj)) { return coerce(ZERO); } Class objType = obj.getClass(); if (Character.class.equals(objType) || Character.TYPE == objType) { return coerce(new Short((short) ((Character) obj).charValue())); } throw new IllegalArgumentException(MessageFactory.get("el.convert", obj, objType)); }
protected final Number coerce(final Object obj) { if (isNumber(obj)) { return coerce((Number) obj); } if (obj instanceof String) { return coerce((String) obj); } if (obj == null || "".equals(obj)) { return coerce(ZERO); } Class objType = obj.getClass(); if (Character.class.equals(objType) || Character.TYPE == objType) { return coerce(new Short((short) ((Character) obj).charValue())); } throw new IllegalArgumentException(MessageFactory.get("el.convert", obj, objType)); }
public final static Number coerceToNumber(final Object obj, final Class type) throws IllegalArgumentException { if (obj == null || "".equals(obj)) { return coerceToNumber(ZERO, type); } if (obj instanceof String) { return coerceToNumber((String) obj, type); } if (ELArithmetic.isNumber(obj)) { return coerceToNumber((Number) obj, type); } Class objType = obj.getClass(); if (Character.class.equals(objType) || Character.TYPE == objType) { return coerceToNumber(new Short((short) ((Character) obj) .charValue()), type); } throw new IllegalArgumentException(MessageFactory.get("error.convert", obj, objType, type)); }
public final static Number coerceToNumber(final Object obj, final Class type) throws IllegalArgumentException { if (obj == null || "".equals(obj)) { if (type == Number.class) return null; else return coerceToNumber(ZERO, type); } if (obj instanceof String) { return coerceToNumber((String) obj, type); } if (ELArithmetic.isNumber(obj)) { return coerceToNumber((Number) obj, type); } Class objType = obj.getClass(); if (Character.class.equals(objType) || Character.TYPE == objType) { return coerceToNumber(new Short((short) ((Character) obj) .charValue()), type); } throw new IllegalArgumentException(MessageFactory.get("error.convert", obj, objType, type)); }
public final static Number coerceToNumber(final Object obj, final Class type) throws IllegalArgumentException { if (obj == null || "".equals(obj)) { if (type == Number.class) return null; else return coerceToNumber(ZERO, type); } if (obj instanceof String) { return coerceToNumber((String) obj, type); } if (ELArithmetic.isNumber(obj)) { return coerceToNumber((Number) obj, type); } Class objType = obj.getClass(); if (Character.class.equals(objType) || Character.TYPE == objType) { return coerceToNumber(new Short((short) ((Character) obj) .charValue()), type); } throw new IllegalArgumentException(MessageFactory.get("error.convert", obj, objType, type)); }