public void setProperty()

in src/java/org/apache/fulcrum/intake/model/Field.java [918:984]


    public void setProperty(Object obj) throws IntakeException
    {
        if (log.isDebugEnabled())
        {
            log.debug(name + ".setProperty(" + obj.getClass().getName() + ")");
        }

        if (!isValid())
        {
            throw new IntakeException(
                    "Attempted to assign an invalid input.");
        }
        if (isSet() && null != getTestValue())
        {
            valArray[0] = getTestValue();
            if (log.isDebugEnabled())
            {
                log.debug(name + ": Property is set, value is " + valArray[0]);
            }
        }
        else
        {
            valArray[0] = getSafeEmptyValue();
            if (log.isDebugEnabled())
            {
                log.debug(name + ": Property is not set, using emptyValue " + valArray[0]);
            }
        }

        try
        {
            /*
             * In the case we map a Group to an Object using mapToObject, and we
             * want to add an additional Field which should not be mapped, and
             * we leave the mapToProperty empty, we will get a NPE here. So we
             * have to double check, if we really have a setter set.
             */
            if(setter != null)
            {
                setter.invoke(obj, valArray);
            }
            else if (log.isDebugEnabled())
            {
                log.debug(name + ": has a null setter for the mapToProperty"
                        + " Attribute, although all Fields should be mapped"
                        + " to " + mapToObject + ". If this is unwanted, you"
                        + " should double check the mapToProperty Attribute, and"
                        + " consult the logs. The Turbine Intake Service will"
                        + " have logged a detailed Message with the error.");
            }
        }
        catch (IllegalAccessException e)
        {
            throwSetGetException("setter", obj, this.getDisplayName(),
                    this.group.getIntakeGroupName(), e);
        }
        catch (IllegalArgumentException e)
        {
            throwSetGetException("setter", obj, this.getDisplayName(),
                    this.group.getIntakeGroupName(), e);
        }
        catch (InvocationTargetException e)
        {
            throwSetGetException("setter", obj, this.getDisplayName(),
                    this.group.getIntakeGroupName(), e);
        }
    }