public ValuesAccessor(DatabaseMapping mapping) { super(); this.mapping = mapping; setAttributeName(mapping.getAttributeName()); }
public Object getAttributeValueFromObject(Object entity) throws DescriptorException { Object value = getRawValue(entity); return value == NULL_VALUE ? null : value; }
/** * Access the Object[] from the {@link DynamicEntity}. * <p> * If the length of the array is incorrect this is where it will be lazily * fixed. */ private Object[] getValues(Object entity) { Object[] values = ((DynamicEntityImpl) entity).values; if (getIndex() >= values.length) { Object[] newValues = new Object[getType().getNumberOfProperties()]; System.arraycopy(values, 0, newValues, 0, values.length); ((DynamicEntityImpl) entity).values = newValues; values = newValues; } return values; }
/** * Update the targetMapping to have the same accessor as the originMapping * @param originMapping * @param targetMapping */ private static void copyAccessorToMapping(DatabaseMapping originMapping, DatabaseMapping targetMapping) { if (originMapping.getAttributeAccessor().isVirtualAttributeAccessor()) { VirtualAttributeAccessor accessor = new VirtualAttributeAccessor(); accessor.setGetMethodName(originMapping.getGetMethodName()); accessor.setSetMethodName(originMapping.getSetMethodName()); targetMapping.setAttributeAccessor(accessor); } if (originMapping.getAttributeAccessor().isValuesAccessor()) { ValuesAccessor accessor = new ValuesAccessor(originMapping); accessor.setAttributeName(originMapping.getAttributeAccessor().getAttributeName()); targetMapping.setAttributeAccessor(accessor); } else { targetMapping.setAttributeName(originMapping.getAttributeName()); targetMapping.setGetMethodName(originMapping.getGetMethodName()); targetMapping.setSetMethodName(originMapping.getSetMethodName()); } }
mapping.setAttributeAccessor(new ValuesAccessor(mapping));
@Override public Class<?> getAttributeClass() { if (getMapping().isForeignReferenceMapping()) { ForeignReferenceMapping refMapping = (ForeignReferenceMapping) getMapping(); if (refMapping.isCollectionMapping()) { return ((CollectionMapping) refMapping).getContainerPolicy().getContainerClass(); } if (refMapping.usesIndirection()) { return ValueHolderInterface.class; } return refMapping.getReferenceClass(); } else { if (getMapping().getAttributeClassification() == null) { return ClassConstants.OBJECT; } return getMapping().getAttributeClassification(); } } }
/** * Update the targetMapping to have the same accessor as the originMapping * @param originMapping * @param targetMapping */ private static void copyAccessorToMapping(DatabaseMapping originMapping, DatabaseMapping targetMapping) { if (originMapping.getAttributeAccessor().isVirtualAttributeAccessor()) { VirtualAttributeAccessor accessor = new VirtualAttributeAccessor(); accessor.setGetMethodName(originMapping.getGetMethodName()); accessor.setSetMethodName(originMapping.getSetMethodName()); targetMapping.setAttributeAccessor(accessor); } if (originMapping.getAttributeAccessor().isValuesAccessor()) { ValuesAccessor accessor = new ValuesAccessor(originMapping); accessor.setAttributeName(originMapping.getAttributeAccessor().getAttributeName()); targetMapping.setAttributeAccessor(accessor); } else { targetMapping.setAttributeName(originMapping.getAttributeName()); targetMapping.setGetMethodName(originMapping.getGetMethodName()); targetMapping.setSetMethodName(originMapping.getSetMethodName()); } }
mapping.setAttributeAccessor(new ValuesAccessor(mapping));
mapping.setAttributeAccessor(new ValuesAccessor(getType(), mapping, index));
public ValuesAccessor(DatabaseMapping mapping) { super(); this.mapping = mapping; setAttributeName(mapping.getAttributeName()); }
/** * <b>INTERNAL</b>: Direct access to the value in the Object[] for this * mapping. This method is provided for advanced users and BYPASSES THE USE * OF NULL_VALUE. All application access should be done using the * {@link DynamicEntity} API */ public void setRawValue(Object entity, Object value) { getValues(entity)[getIndex()] = value; }
/** * <b>INTERNAL</b>: Direct access to the value in the Object[] for this * mapping. This method is provided for advanced users and can provide * direct access to he NULL_VALUE. All application access should be done * using the {@link DynamicEntity} get/set API. */ public Object getRawValue(Object entity) { return getValues(entity)[getIndex()]; }