/** * Returns a Byte instance representing the specified byte. * Byte.valueOf was added in JDK 1.5. * * @param b a byte value. * @return a Byte instance representing b. */ protected static Byte valueOf(final byte b) { return new Byte(b); }
/** * Gets the value as a Byte instance. * * @return the value as a Byte, never null */ public Object getValue() { return new Byte(this.value); }
/** * <p>Converts an array of primitive bytes to objects.</p> * * <p>This method returns <code>null</code> for a <code>null</code> input array.</p> * * @param array a <code>byte</code> array * @return a <code>Byte</code> array, <code>null</code> if null array input */ public static Byte[] toObject(byte[] array) { if (array == null) { return null; } else if (array.length == 0) { return EMPTY_BYTE_OBJECT_ARRAY; } final Byte[] result = new Byte[array.length]; for (int i = 0; i < array.length; i++) { result[i] = new Byte(array[i]); } return result; }
/** * Gets this mutable as an instance of Byte. * * @return a Byte instance containing the value from this mutable */ public Byte toByte() { return new Byte(byteValue()); }
public String setByte() throws Exception { Field f = JLRFSetTheRestVariant.class.getDeclaredField("b"); f.set(this, new Byte("123")); return Byte.toString(b); }
/** * Creates a map of the classes fields. */ protected static Object getParamArg(Class cl) { if (!cl.isPrimitive()) return null; else if (boolean.class.equals(cl)) return Boolean.FALSE; else if (byte.class.equals(cl)) return new Byte((byte) 0); else if (short.class.equals(cl)) return new Short((short) 0); else if (char.class.equals(cl)) return new Character((char) 0); else if (int.class.equals(cl)) return Integer.valueOf(0); else if (long.class.equals(cl)) return Long.valueOf(0); else if (float.class.equals(cl)) return Float.valueOf(0); else if (double.class.equals(cl)) return Double.valueOf(0); else throw new UnsupportedOperationException(); }
Object getValue(ClassLoader cl, ClassPool cp, Method m) { return new Byte(getValue()); }
@Generates private Byte generateByteObject() { return new Byte(generateByte()); }
@Override public Object coerceElement(Class arrType, Object value) { if ( value instanceof Number ) { Number n = (Number) value; if ( arrType == Byte.class ) { return new Byte(n.byteValue()); } else if ( arrType == Short.class ) { return new Short(n.shortValue()); } else if ( arrType == Integer.class ) { return new Integer(n.intValue()); } else if ( arrType == Long.class ) { return new Long(n.longValue()); } else if ( arrType == Double.class ) { return new Double(n.doubleValue()); } else if ( arrType == Float.class ) { return new Float(n.floatValue()); } else if ( arrType == Character.class ) { return new Character((char) n.intValue()); } } return value; }
/** * Get a byte associated with the given configuration key. * * @param key The configuration key. * @param defaultValue The default value. * @return The associated byte. * @throws ClassCastException is thrown if the key maps to an * object that is not a Byte. * @throws NumberFormatException is thrown if the value mapped * by the key has not a valid number format. */ public byte getByte(String key, byte defaultValue) { return getByte(key, new Byte(defaultValue)).byteValue(); }
public Object read(InputStream in) { return new Byte(in.read_octet()); } }
public Object[] getSampleValues() { Object[] values = new Object[] { new Integer(1234), new Long(1298341928234L), new Double(123423.34), new Float(1213332.12f), new Short((short)134), new Byte((byte)10), new Character('a'), new Integer(1432), "SomeStringValue", objectInFullMap, BeanWithProperties.class, }; return values; }
public Object[] getNewSampleValues() { Object[] values = new Object[] { new Integer(223), new Long(23341928234L), new Double(23423.34), new Float(213332.12f), new Short((short)234), new Byte((byte)20), new Character('b'), new Integer(232), "SomeNewStringValue", new Object(), null, }; return values; }
/** * Sets the default value for Byte conversions. * @param newDefaultByte The default Byte value * @deprecated Register replacement converters for Byte.TYPE and * Byte.class instead */ @Deprecated public void setDefaultByte(final byte newDefaultByte) { defaultByte = new Byte(newDefaultByte); register(new ByteConverter(defaultByte), Byte.TYPE); register(new ByteConverter(defaultByte), Byte.class); }
/** * Sets the default value for Byte conversions. * @param newDefaultByte The default Byte value * @deprecated Register replacement converters for Byte.TYPE and * Byte.class instead */ @Deprecated public void setDefaultByte(final byte newDefaultByte) { defaultByte = new Byte(newDefaultByte); register(new ByteConverter(defaultByte), Byte.TYPE); register(new ByteConverter(defaultByte), Byte.class); }
@Test public void testByteType() { final Byte original = 0; final Byte copy = new Byte( (byte) 0 ); final Byte different = 9; runBasicTests( ByteType.INSTANCE, original, copy, different ); }
/** * @throws Exception If failed. */ @Test public void testByte() throws Exception { byte val = 10; assertEquals(new Byte(val), marshalUnmarshal(val)); }
public void testByteDataTypeAsDays() throws HiveException { GenericUDFDateAdd udf = new GenericUDFDateAdd(); ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector; ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaByteObjectInspector; ObjectInspector[] arguments = {valueOI1, valueOI2}; udf.initialize(arguments); DeferredObject valueObj1 = new DeferredJavaObject(new DateWritableV2(Date.of(109, 06, 20))); DeferredObject valueObj2 = new DeferredJavaObject(new Byte("4")); DeferredObject[] args = {valueObj1, valueObj2}; DateWritableV2 output = (DateWritableV2) udf.evaluate(args); assertEquals("date_add() test for BYTE failed ", "0109-06-24", output.toString()); }
public void testByteDataTypeAsDays() throws HiveException { GenericUDFDateSub udf = new GenericUDFDateSub(); ObjectInspector valueOI1 = PrimitiveObjectInspectorFactory.writableDateObjectInspector; ObjectInspector valueOI2 = PrimitiveObjectInspectorFactory.javaByteObjectInspector; ObjectInspector[] arguments = {valueOI1, valueOI2}; udf.initialize(arguments); DeferredObject valueObj1 = new DeferredJavaObject(new DateWritableV2(Date.of(109, 06, 20))); DeferredObject valueObj2 = new DeferredJavaObject(new Byte("4")); DeferredObject[] args = {valueObj1, valueObj2}; DateWritableV2 output = (DateWritableV2) udf.evaluate(args); assertEquals("date_add() test for BYTE failed ", "0109-06-16", output.toString()); }