/** * Gets the property accessor. * * @param property * the property * * @return the property accessor */ public static PropertyAccessor<?> getPropertyAccessor(Field property) { return getPropertyAccessor(property.getType()); }
public static final byte[] toBytes(Object o, Field f) { PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor(f); return accessor.toBytes(o); }
public static final Object getObject(Class<?> clazz) { PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor(clazz); return accessor.getInstance(clazz); }
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; }
public static final byte[] toBytes(Object o, Class c) { PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor(c); return accessor.toBytes(o); }
public static Object fromSourceToTargetClass(Class<?> targetClass, Class<?> sourceClass, Object o) { if (!targetClass.equals(sourceClass)) { PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(sourceClass); String s = accessor.toString(o); accessor = PropertyAccessorFactory.getPropertyAccessor(targetClass); return accessor.fromString(targetClass, s); } return o; }
public static String getString(Object o) { return o != null ? PropertyAccessorFactory.getPropertyAccessor(o.getClass()).toString(o) : null; }
public static byte[] getBytes(Object o) { return PropertyAccessorFactory.getPropertyAccessor(o.getClass()).toBytes(o); }
public static Object getObject(Class clazz, byte[] b) { return PropertyAccessorFactory.getPropertyAccessor(clazz).fromBytes(clazz, b); }
/** * Sets a byte-array onto a field. * * @param target * the target * @param field * the field * @param bytes * the bytes * * @throws PropertyAccessException * the property access exception */ public static void set(Object target, Field field, byte[] bytes) { PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(field); Object value = accessor.fromBytes(field.getType(), bytes); set(target, field, value); }
/** * Sets a byte-array onto a field. * * @param target * the target * @param field * the field * @param fieldVal * the field value * * @throws PropertyAccessException * the property access exception */ public static void set(Object target, Field field, String fieldVal) { PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(field); Object value = accessor.fromString(target.getClass(), fieldVal); set(target, field, value); }
value = PropertyAccessorFactory.getPropertyAccessor(clazz).fromString(clazz, value.toString()); return PropertyAccessorFactory.getPropertyAccessor(clazz).toBytes(value);
/** * Gets field value as byte-array. * * @param from * the from * @param field * the field * * @return the byte[] * * @throws PropertyAccessException * the property access exception */ public static byte[] get(Object from, Field field) { PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(field); return accessor.toBytes(getObject(from, field)); }
value = PropertyAccessorFactory.getPropertyAccessor(clazz).fromString(clazz, value.toString()); return PropertyAccessorFactory.getPropertyAccessor(clazz).toBytes(value);
/** * Gets the string. * * @param from * the from * @param field * the field * * @return the string * * @throws PropertyAccessException * the property access exception */ public static String getString(Object from, Field field) { PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(field); Object object = getObject(from, field); return object != null ? accessor.toString(object) : null; }
builder.append(PropertyAccessorFactory.getPropertyAccessor(fieldClazz).toString(value));
/** * Retutrns copy of object * * @param from * @param field * @return */ public static Object getObjectCopy(Object from, Field field) { if (!field.isAccessible()) { field.setAccessible(true); } try { PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(field); return accessor.getCopy(field.get(from)); } catch (IllegalArgumentException iarg) { throw new PropertyAccessException(iarg); } catch (IllegalAccessException iacc) { throw new PropertyAccessException(iacc); } }
/** * Gets the data type. * * @param entityMetadata * the entity metadata * @param arg1 * the arg1 * @return the data type * @throws PropertyAccessException * the property access exception */ private Object[] getDataType(EntityMetadata entityMetadata, Object... arg1) throws PropertyAccessException { Field idField = (Field) entityMetadata.getIdAttribute().getJavaMember(); PropertyAccessor<?> accessor = PropertyAccessorFactory.getPropertyAccessor(idField); Object[] pKeys = new Object[arg1.length]; int cnt = 0; for (Object r : arg1) { pKeys[cnt++] = accessor.fromString(idField.getClass(), r.toString()); } return pKeys; }
if (param.getPosition() == Integer.parseInt(paramName)) { Class<?> paramClass = param.getParameterType(); PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor(paramClass); Object paramValue = accessor.fromString(paramClass, value); q.setParameter(Integer.parseInt(paramName), paramValue); if (param.getName().equals(paramName)) { Class<?> paramClass = param.getParameterType(); PropertyAccessor accessor = PropertyAccessorFactory.getPropertyAccessor(paramClass); Object paramValue = accessor.fromString(paramClass, value); q.setParameter(paramName, paramValue);
value = PropertyAccessorFactory.getPropertyAccessor(clazz).fromString(clazz, value.toString()); return BytesType.instance.decompose(ByteBuffer.wrap(PropertyAccessorFactory.getPropertyAccessor(clazz) .toBytes(value)));