List of usage examples for java.lang Byte valueOf
public static Byte valueOf(String s) throws NumberFormatException
From source file:org.op4j.functions.FnLong.java
/** * <p>/*from w w w. ja v a 2s . com*/ * It divides the target element by the given divisor and returns the * remainder (target % divisor) * </p> * * @param divisor the divisor * @return the remainder of target/divisor */ public final static Function<Long, Long> remainder(byte divisor) { return remainder(Byte.valueOf(divisor)); }
From source file:org.op4j.functions.FnShort.java
/** * <p>//from w w w . j a va 2 s . c o m * It divides the target element by the given divisor and returns the * remainder (target % divisor) * </p> * * @param divisor the divisor * @return the remainder of target/divisor */ public final static Function<Short, Short> remainder(byte divisor) { return remainder(Byte.valueOf(divisor)); }
From source file:org.op4j.functions.FnInteger.java
/** * <p>// w w w . jav a 2 s. c o m * It divides the target element by the given divisor and returns the * remainder (target % divisor) * </p> * * @param divisor the divisor * @return the remainder of target/divisor */ public final static Function<Integer, Integer> remainder(byte divisor) { return remainder(Byte.valueOf(divisor)); }
From source file:org.apache.openjpa.meta.FieldMetaData.java
/** * Return the string value converted to the given type code. The string * must be non-null and trimmed.// w ww . ja v a 2s. c om */ private Object transform(String val, int typeCode) { if ("null".equals(val)) return null; switch (typeCode) { case JavaTypes.BOOLEAN: case JavaTypes.BOOLEAN_OBJ: return Boolean.valueOf(val); case JavaTypes.BYTE: case JavaTypes.BYTE_OBJ: return Byte.valueOf(val); case JavaTypes.INT: case JavaTypes.INT_OBJ: return Integer.valueOf(val); case JavaTypes.LONG: case JavaTypes.LONG_OBJ: return Long.valueOf(val); case JavaTypes.SHORT: case JavaTypes.SHORT_OBJ: return Short.valueOf(val); case JavaTypes.DOUBLE: case JavaTypes.DOUBLE_OBJ: return Double.valueOf(val); case JavaTypes.FLOAT: case JavaTypes.FLOAT_OBJ: return Float.valueOf(val); case JavaTypes.CHAR: case JavaTypes.CHAR_OBJ: return Character.valueOf(val.charAt(0)); case JavaTypes.STRING: return val; case JavaTypes.ENUM: return Enum.valueOf((Class<? extends Enum>) getDeclaredType(), val); } throw new MetaDataException(_loc.get("bad-external-type", this)); }
From source file:com.draagon.meta.manager.db.driver.GenericSQLDriver.java
/** * Sets a specific value on a prepared statement *//*from w w w. j a va 2 s . c o m*/ protected void setStatementValue(PreparedStatement s, MetaField f, int index, Object value) throws SQLException { int j = index; switch (f.getType()) { case MetaField.BOOLEAN: { if (value == null) { s.setNull(j, Types.BIT); } else if (value instanceof Boolean) { s.setBoolean(j, ((Boolean) value).booleanValue()); } else { s.setBoolean(j, Boolean.valueOf(value.toString()).booleanValue()); } } break; case MetaField.BYTE: { if (value == null) { s.setNull(j, Types.TINYINT); } else if (value instanceof Byte) { s.setByte(j, ((Byte) value).byteValue()); } else { s.setByte(j, Byte.valueOf(value.toString()).byteValue()); } } break; case MetaField.SHORT: { if (value == null) { s.setNull(j, Types.SMALLINT); } else if (value instanceof Short) { s.setShort(j, ((Short) value).shortValue()); } else { s.setShort(j, Short.valueOf(value.toString()).shortValue()); } } break; case MetaField.INT: { if (value == null) { s.setNull(j, Types.INTEGER); } else if (value instanceof Integer) { s.setInt(j, ((Integer) value).intValue()); } else { s.setInt(j, Integer.valueOf(value.toString()).intValue()); } } break; case MetaField.DATE: // NOTE DATE IS TREATED AS LONG! { if (value == null) { s.setNull(j, Types.TIMESTAMP); } else if (value instanceof java.util.Date) { s.setTimestamp(j, new Timestamp(((java.util.Date) value).getTime())); } else { s.setTimestamp(j, new Timestamp(Long.valueOf(value.toString()).longValue())); } } break; case MetaField.LONG: { if (value == null) { s.setNull(j, Types.BIGINT); } else if (value instanceof Long) { s.setLong(j, ((Long) value).longValue()); } else { s.setLong(j, Long.valueOf(value.toString()).longValue()); } } break; // WARNING: This should not be a valid key case MetaField.FLOAT: { if (value == null) { s.setNull(j, Types.FLOAT); } else if (value instanceof Float) { s.setFloat(j, ((Float) value).floatValue()); } else { s.setFloat(j, Float.valueOf(value.toString()).floatValue()); } } break; // WARNING: This should not be a valid key case MetaField.DOUBLE: { if (value == null) { s.setNull(j, Types.DOUBLE); } else if (value instanceof Double) { s.setDouble(j, ((Double) value).doubleValue()); } else { s.setDouble(j, Double.valueOf(value.toString()).doubleValue()); } } break; case MetaField.STRING: if (value == null) { s.setNull(j, Types.VARCHAR); } else { s.setString(j, value.toString()); } break; case MetaField.OBJECT: //if ( value == null ) // s.setNull( j, Types.BLOB ); //else s.setObject(j, value); break; } }
From source file:org.op4j.functions.FnFloat.java
/** * <p>/* ww w. ja va 2 s. co m*/ * It multiplies target by multiplicand and returns its value. The result precision * and {@link RoundingMode} is specified by the given {@link MathContext} * </p> * * @param multiplicand the multiplicand * @param mathContext the {@link MathContext} to define {@link RoundingMode} and precision * @return the result of target * multiplicand */ public final static Function<Float, Float> multiplyBy(byte multiplicand, MathContext mathContext) { return multiplyBy(Byte.valueOf(multiplicand), mathContext); }
From source file:org.op4j.functions.FnLong.java
/** * <p>/*w w w . ja v a2 s . c o m*/ * It multiplies target by multiplicand and returns its value * </p> * * @param multiplicand the multiplicand * @return the result of target * multiplicand */ public final static Function<Long, Long> multiplyBy(byte multiplicand) { return multiplyBy(Byte.valueOf(multiplicand)); }
From source file:org.op4j.functions.FnShort.java
/** * <p>/* w w w.jav a2s . c o m*/ * It multiplies target by multiplicand and returns its value * </p> * * @param multiplicand the multiplicand * @return the result of target * multiplicand */ public final static Function<Short, Short> multiplyBy(byte multiplicand) { return multiplyBy(Byte.valueOf(multiplicand)); }
From source file:org.op4j.functions.FnInteger.java
/** * <p>/*from w w w . j a v a 2 s . c om*/ * It multiplies target by multiplicand and returns its value * </p> * * @param multiplicand the multiplicand * @return the result of target * multiplicand */ public final static Function<Integer, Integer> multiplyBy(byte multiplicand) { return multiplyBy(Byte.valueOf(multiplicand)); }
From source file:org.op4j.functions.FnLong.java
/** * <p>// ww w. ja v a2s .co m * It multiplies target by multiplicand and returns its value. The result precision * and {@link RoundingMode} is specified by the given {@link MathContext} * </p> * * @param multiplicand the multiplicand * @param mathContext the {@link MathContext} to define {@link RoundingMode} and precision * @return the result of target * multiplicand */ public final static Function<Long, Long> multiplyBy(byte multiplicand, MathContext mathContext) { return multiplyBy(Byte.valueOf(multiplicand), mathContext); }