/** * Returns the value of the bean's property with the given name. * <p> * The given name must be a {@link String} and must not be * null; otherwise, this method returns <code>null</code>. * If the bean defines a property with the given name, the value of * that property is returned. Otherwise, <code>null</code> is * returned. * <p> * Write-only properties will not be matched as the test operates against * property read methods. * * @param name the name of the property whose value to return * @return the value of the property with that name */ public override Object get(Object name) { if (bean != null) { java.lang.reflect.Method method = getReadMethod(name); if (method != null) { try { return(method.invoke(bean, NULL_ARGUMENTS)); } catch (java.lang.IllegalAccessException e) { logWarn(e); } catch (java.lang.IllegalArgumentException e) { logWarn(e); } catch (java.lang.reflect.InvocationTargetException e) { logWarn(e); } catch (java.lang.NullPointerException e) { logWarn(e); } } } return(null); }
/** * Sets the bean property with the given name to the given value. * * @param name the name of the property to set * @param value the value to set that property to * @return the previous value of that property * @throws IllegalArgumentException if the given name is null; * if the given name is not a {@link String}; if the bean doesn't * define a property with that name; or if the bean property with * that name is read-only */ public override Object put(Object name, Object value) {//throws IllegalArgumentException, ClassCastException { if (bean != null) { Object oldValue = get(name); java.lang.reflect.Method method = getWriteMethod(name); if (method == null) { throw new java.lang.IllegalArgumentException("The bean of type: " + bean.getClass().getName() + " has no property called: " + name); } try { Object[] arguments = createWriteMethodArguments(method, value); method.invoke(bean, arguments); Object newValue = get(name); firePropertyChange(name, oldValue, newValue); } catch (java.lang.reflect.InvocationTargetException e) { logInfo(e); throw new java.lang.IllegalArgumentException(e.getMessage()); } catch (java.lang.IllegalAccessException e) { logInfo(e); throw new java.lang.IllegalArgumentException(e.getMessage()); } return(oldValue); } return(null); }
/** * Transforms the input to result by invoking a method on the input. * * @param input the input object to transform * @return the transformed result, null if null input */ public Object transform(Object input) { if (input == null) { return(null); } try { // C# // Type c = input.GetType(); // MethodInfo mi = c.GetMethod(iMethodName, iParamTypes); // if (null == mi) throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" + input.GetType() + "' does not exist"); // return mi.Invoke(input, iArgs); // JavApi java.lang.Class cls = input.getClass(); java.lang.reflect.Method method = cls.getMethod(iMethodName, iParamTypes); return(method.invoke(input, iArgs)); } catch (java.lang.NoSuchMethodException) { throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" + input.getClass() + "' does not exist"); } catch (java.lang.IllegalAccessException) { throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" + input.GetType() + "' cannot be accessed"); } catch (Exception exc) { // HACK - How to add System.Exception in constructor... throw new FunctorException("InvokerTransformer: The method '" + iMethodName + "' on '" + input.GetType() + "' threw an exception " + exc.GetType());//, ex); } }
/** * Creates an object by calling the clone method. * * @return the new object */ public Object create() { // needed for post-serialization if (iCloneMethod == null) { findCloneMethod(); } try { return(iCloneMethod.invoke(iPrototype, (Object[])null)); } catch (java.lang.IllegalAccessException ex) { throw new FunctorException("PrototypeCloneFactory: Clone method must be public", ex); } catch (java.lang.reflect.InvocationTargetException ex) { throw new FunctorException("PrototypeCloneFactory: Clone method threw an exception", ex); } }