public static final byte[] toBytes(Object o, Field f) { PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor(f); return accessor.toBytes(o); }
public static final byte[] toBytes(Object o, Class c) { PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor(c); return accessor.toBytes(o); }
public static Object fromDate(Class<?> targetClass, Class<?> sourceClass, Object o) { if (!targetClass.equals(sourceClass)) { PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(sourceClass); byte[] b = accessor.toBytes(o); accessor = PropertyAccessorFactory.getPropertyAccessor(targetClass); return accessor.fromBytes(targetClass, b); } return o; }
/** * Test method for {@link com.impetus.kundera.property.accessor.StringAccessor#toBytes(java.lang.Object)}. */ @Test public void testToBytes() { Assert.assertNull(accessor.toBytes(null)); String d1 = new String("AAA"); byte[] b = accessor.toBytes(d1); String d2 = accessor.fromBytes(String.class, b); Assert.assertEquals(d1, d2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.IntegerAccessor#toBytes(java.lang.Object)}. */ @Test public void testToBytes() { Assert.assertNull(accessor.toBytes(null)); Integer d1 = new Integer(4); byte[] b = accessor.toBytes(d1); Integer d2 = accessor.fromBytes(Integer.class, b); Assert.assertEquals(d1, d2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.FloatAccessor#toBytes(java.lang.Object)}. */ @Test public void testToBytes() { Assert.assertNull(accessor.toBytes(null)); Float f1 = new Float(4.555); byte[] b = accessor.toBytes(f1); Float f2 = accessor.fromBytes(Float.class, b); Assert.assertEquals(f1, f2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.UUIDAccessor#toBytes(java.lang.Object)}. */ @Test public void testToBytes() { Assert.assertNull(accessor.toBytes(null)); UUID uuid = UUID.randomUUID(); byte[] b = accessor.toBytes(uuid); UUID uuid2 = accessor.fromBytes(UUID.class, b); Assert.assertEquals(uuid, uuid2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.SQLDateAccessor#toBytes(java.lang.Object)}. */ @Test public void testToBytes() { Assert.assertNull(accessor.toBytes(null)); long l = System.currentTimeMillis(); Date d = new Date(l); byte[] b = accessor.toBytes(d); Date d2 = accessor.fromBytes(Date.class, b); Assert.assertEquals(d, d2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.ByteAccessor#toBytes(java.lang.Object)}. */ @Test public void testToBytes() { Assert.assertNull(accessor.toBytes(null)); Byte v1 = new Byte("7"); byte[] b = accessor.toBytes(v1); Byte v2 = accessor.fromBytes(Byte.class, b); Assert.assertEquals(v1, v2); }
@Test public void testFromBytes() { byte[] bytes = new byte[] {}; Assert.assertNull(accessor.fromBytes(LongAccessor.class, bytes)); Long l = 49L; bytes = accessor.toBytes(l); Assert.assertEquals(l, accessor.fromBytes(LongAccessor.class, bytes)); l = 12l; bytes = accessor.toBytes(l); Assert.assertEquals(l, (Long) accessor.fromBytes(LongAccessor.class, bytes)); }
/** * Test method for {@link com.impetus.kundera.property.accessor.SQLTimestampAccessor#fromBytes(java.lang.Class, byte[])}. */ @Test public void testFromBytes() { Assert.assertNull(accessor.fromBytes(Timestamp.class, null)); long l = System.currentTimeMillis(); Timestamp t = new Timestamp(l); byte[] b = accessor.toBytes(t); Timestamp t2 = accessor.fromBytes(Timestamp.class, b); Assert.assertEquals(t, t2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.UUIDAccessor#fromBytes(java.lang.Class, byte[])}. */ @Test public void testFromBytes() { Assert.assertNull(accessor.fromBytes(UUID.class, null)); UUID uuid = UUID.randomUUID(); byte[] b = accessor.toBytes(uuid); UUID uuid2 = accessor.fromBytes(UUID.class, b); Assert.assertEquals(uuid, uuid2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.ByteAccessor#fromBytes(java.lang.Class, byte[])}. */ @Test public void testFromBytes() { Assert.assertNull(accessor.fromBytes(Byte.class, null)); Byte v1 = new Byte("7"); byte[] b = accessor.toBytes(v1); Byte v2 = accessor.fromBytes(Byte.class, b); Assert.assertEquals(v1, v2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.StringAccessor#fromBytes(java.lang.Class, byte[])}. */ @Test public void testFromBytes() { Assert.assertNull(accessor.fromBytes(String.class, null)); String d1 = new String("AAA"); byte[] b = accessor.toBytes(d1); String d2 = accessor.fromBytes(String.class, b); Assert.assertEquals(d1, d2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.BigIntegerAccessor#toBytes(java.lang.Object)}. */ @Test public void testToBytes() { Assert.assertNull(accessor.toString(null)); BigInteger v1 = new BigInteger("1111111111"); byte[] b = accessor.toBytes(v1); BigInteger v2 = accessor.fromBytes(BigInteger.class, b); Assert.assertEquals(v1, v2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.DoubleAccessor#fromBytes(java.lang.Class, byte[])}. */ @Test public void testFromBytes() { Assert.assertEquals(0.0, accessor.fromBytes(Double.class, null)); Double d1 = new Double(4.555); byte[] b = accessor.toBytes(d1); Double d2 = accessor.fromBytes(Double.class, b); Assert.assertEquals(d1, d2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.BigDecimalAccessor#fromBytes(java.lang.Class, byte[])}. */ @Test public void testFromBytes() { Assert.assertNull(accessor.fromBytes(BigDecimal.class, null)); BigDecimal v1 = new BigDecimal(1111111111.11111); byte[] b = accessor.toBytes(v1); BigDecimal v2 = accessor.fromBytes(BigDecimal.class, b); Assert.assertEquals(v1, v2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.BigIntegerAccessor#fromBytes(java.lang.Class, byte[])}. */ @Test public void testFromBytes() { Assert.assertNull(accessor.fromBytes(BigInteger.class, null)); BigInteger v1 = new BigInteger("1111111111"); byte[] b = accessor.toBytes(v1); BigInteger v2 = accessor.fromBytes(BigInteger.class, b); Assert.assertEquals(v1, v2); }
/** * Test method for {@link com.impetus.kundera.property.accessor.BigDecimalAccessor#toBytes(java.lang.Object)}. */ @Test public void testToBytes() { Assert.assertNull(accessor.toString(null)); BigDecimal v1 = new BigDecimal(1111111111); byte[] b = accessor.toBytes(v1); BigDecimal v2 = accessor.fromBytes(BigDecimal.class, b); Assert.assertEquals(v1, v2); }