/** * instanceVariableName is converted to Field type. */ public void initializeAttributes(Class theJavaClass) throws DescriptorException { if (getAttributeName() == null) { throw DescriptorException.attributeNameNotSpecified(); } try { setAttributeField(Helper.getField(theJavaClass, getAttributeName())); } catch (NoSuchFieldException exception) { throw DescriptorException.noSuchFieldWhileInitializingAttributesInInstanceVariableAccessor(getAttributeName(), theJavaClass.getName(), exception); } catch (SecurityException exception) { throw DescriptorException.securityWhileInitializingAttributesInInstanceVariableAccessor(getAttributeName(), theJavaClass.getName(), exception); } }
/** * instanceVariableName is converted to Field type. */ @Override public void initializeAttributes(Class theJavaClass) throws DescriptorException { if (getAttributeName() == null) { throw DescriptorException.attributeNameNotSpecified(); } try { setAttributeField(Helper.getField(theJavaClass, getAttributeName())); } catch (NoSuchFieldException exception) { throw DescriptorException.noSuchFieldWhileInitializingAttributesInInstanceVariableAccessor(getAttributeName(), theJavaClass.getName(), exception); } catch (SecurityException exception) { throw DescriptorException.securityWhileInitializingAttributesInInstanceVariableAccessor(getAttributeName(), theJavaClass.getName(), exception); } }
/** * instanceVariableName is converted to Field type. */ public void initializeAttributes(Class theJavaClass) throws DescriptorException { if (getAttributeName() == null) { throw DescriptorException.attributeNameNotSpecified(); } try { setAttributeField(Helper.getField(theJavaClass, getAttributeName())); } catch (NoSuchFieldException exception) { throw DescriptorException.noSuchFieldWhileInitializingAttributesInInstanceVariableAccessor(getAttributeName(), theJavaClass.getName(), exception); } catch (SecurityException exception) { throw DescriptorException.securityWhileInitializingAttributesInInstanceVariableAccessor(getAttributeName(), theJavaClass.getName(), exception); } }
/** * Returns the value of the attribute on the specified object. */ public Object getAttributeValueFromObject(Object anObject) throws DescriptorException { try { // PERF: Direct variable access. if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { return AccessController.doPrivileged(new PrivilegedGetValueFromField(this.attributeField, anObject)); } catch (PrivilegedActionException exception) { throw DescriptorException.illegalAccesstWhileGettingValueThruInstanceVaraibleAccessor(getAttributeName(), anObject.getClass().getName(), exception.getException()); } } else { // PERF: Direct-var access. return this.attributeField.get(anObject); } } catch (IllegalArgumentException exception) { throw DescriptorException.illegalArgumentWhileGettingValueThruInstanceVariableAccessor(getAttributeName(), getAttributeType().getName(), anObject.getClass().getName(), exception); } catch (IllegalAccessException exception) { throw DescriptorException.illegalAccesstWhileGettingValueThruInstanceVaraibleAccessor(getAttributeName(), anObject.getClass().getName(), exception); } catch (NullPointerException exception) { String className = null; if (anObject != null) { // Some JVM's throw this exception for some very odd reason className = anObject.getClass().getName(); } throw DescriptorException.nullPointerWhileGettingValueThruInstanceVariableAccessor(getAttributeName(), className, exception); } }
/** * Returns the value of the attribute on the specified object. */ public Object getAttributeValueFromObject(Object anObject) throws DescriptorException { try { // PERF: Direct variable access. if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { return AccessController.doPrivileged(new PrivilegedGetValueFromField(this.attributeField, anObject)); } catch (PrivilegedActionException exception) { throw DescriptorException.illegalAccesstWhileGettingValueThruInstanceVaraibleAccessor(getAttributeName(), anObject.getClass().getName(), exception.getException()); } } else { // PERF: Direct-var access. return this.attributeField.get(anObject); } } catch (IllegalArgumentException exception) { throw DescriptorException.illegalArgumentWhileGettingValueThruInstanceVariableAccessor(getAttributeName(), getAttributeType().getName(), anObject.getClass().getName(), exception); } catch (IllegalAccessException exception) { throw DescriptorException.illegalAccesstWhileGettingValueThruInstanceVaraibleAccessor(getAttributeName(), anObject.getClass().getName(), exception); } catch (NullPointerException exception) { String className = null; if (anObject != null) { // Some JVM's throw this exception for some very odd reason className = anObject.getClass().getName(); } throw DescriptorException.nullPointerWhileGettingValueThruInstanceVariableAccessor(getAttributeName(), className, exception); } }
/** * Returns the value of the attribute on the specified object. */ @Override public Object getAttributeValueFromObject(Object anObject) throws DescriptorException { try { // PERF: Direct variable access. if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try { return AccessController.doPrivileged(new PrivilegedGetValueFromField(this.attributeField, anObject)); } catch (PrivilegedActionException exception) { throw DescriptorException.illegalAccesstWhileGettingValueThruInstanceVaraibleAccessor(getAttributeName(), anObject.getClass().getName(), exception.getException()); } } else { // PERF: Direct-var access. return this.attributeField.get(anObject); } } catch (IllegalArgumentException exception) { throw DescriptorException.illegalArgumentWhileGettingValueThruInstanceVariableAccessor(getAttributeName(), getAttributeType().getName(), anObject.getClass().getName(), exception); } catch (IllegalAccessException exception) { throw DescriptorException.illegalAccesstWhileGettingValueThruInstanceVaraibleAccessor(getAttributeName(), anObject.getClass().getName(), exception); } catch (NullPointerException exception) { String className = null; if (anObject != null) { // Some JVM's throw this exception for some very odd reason className = anObject.getClass().getName(); } throw DescriptorException.nullPointerWhileGettingValueThruInstanceVariableAccessor(getAttributeName(), className, exception); } }
AccessController.doPrivileged(new PrivilegedSetValueInField(this.attributeField, anObject, value)); } catch (PrivilegedActionException exception) { throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception.getException()); AccessController.doPrivileged(new PrivilegedSetValueInField(this.attributeField, anObject, ConversionManager.getDefaultManager().convertObject(new Integer(0), fieldClass))); } catch (PrivilegedActionException exc) { throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exc.getException()); throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception); throw DescriptorException.illegalArgumentWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), getAttributeType().getName(), value, exception); } catch (IllegalAccessException exception) { if (value == null) { return; throw DescriptorException.illegalAccessWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), anObject.getClass().getName(), value, exception); } catch (NullPointerException exception) { try { AccessController.doPrivileged(new PrivilegedSetValueInField(this.attributeField, anObject, ConversionManager.getDefaultManager().convertObject(new Integer(0), fieldClass))); } catch (PrivilegedActionException exc) { throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exc.getException()); throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception); throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception); throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception);
AccessController.doPrivileged(new PrivilegedSetValueInField(this.attributeField, anObject, value)); } catch (PrivilegedActionException exception) { throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception.getException()); AccessController.doPrivileged(new PrivilegedSetValueInField(this.attributeField, anObject, ConversionManager.getDefaultManager().convertObject(Integer.valueOf(0), fieldClass))); } catch (PrivilegedActionException exc) { throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), null, exc.getException()); throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), null, exception); throw DescriptorException.illegalArgumentWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), getAttributeType().getName(), value, exception); } catch (IllegalAccessException exception) { if (value == null) { return; throw DescriptorException.illegalAccessWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), anObject.getClass().getName(), value, exception); } catch (NullPointerException exception) { try { AccessController.doPrivileged(new PrivilegedSetValueInField(this.attributeField, anObject, ConversionManager.getDefaultManager().convertObject(Integer.valueOf(0), fieldClass))); } catch (PrivilegedActionException exc) { throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), null, exc.getException()); throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception); throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception); throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception);
AccessController.doPrivileged(new PrivilegedSetValueInField(this.attributeField, anObject, value)); } catch (PrivilegedActionException exception) { throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception.getException()); AccessController.doPrivileged(new PrivilegedSetValueInField(this.attributeField, anObject, ConversionManager.getDefaultManager().convertObject(Integer.valueOf(0), fieldClass))); } catch (PrivilegedActionException exc) { throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exc.getException()); throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception); throw DescriptorException.illegalArgumentWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), getAttributeType().getName(), value, exception); } catch (IllegalAccessException exception) { if (value == null) { return; throw DescriptorException.illegalAccessWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), anObject.getClass().getName(), value, exception); } catch (NullPointerException exception) { try { AccessController.doPrivileged(new PrivilegedSetValueInField(this.attributeField, anObject, ConversionManager.getDefaultManager().convertObject(Integer.valueOf(0), fieldClass))); } catch (PrivilegedActionException exc) { throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exc.getException()); throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception); throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception); throw DescriptorException.nullPointerWhileSettingValueThruInstanceVariableAccessor(getAttributeName(), value, exception);
field = mapping.getDescriptor().getJavaClass().getDeclaredField(attributeAccessor.getAttributeName());
field = mapping.getDescriptor().getJavaClass().getDeclaredField(attributeAccessor.getAttributeName());