⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hasrunneridbo.java

📁 A Java web application, based on Struts and Hibernate, that serves as an online running log. Users m
💻 JAVA
字号:
/* @LICENSE_COPYRIGHT@ */package net.sf.irunninglog.businessobject;import java.util.List;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import net.sf.irunninglog.canonical.HasRunnerId;import net.sf.irunninglog.util.ConversionException;import net.sf.irunninglog.util.DTO;import net.sf.irunninglog.validation.ValidationUtilities;/** * Business object (BO) representaion of any object containing a * <em>runner id</em> field.  This abstract class provides all of the * funtionality needed to access, update, and validate the value of the * <em>runner id</em> field. * * @author <a href="mailto:allan_e_lewis@yahoo.com">Allan Lewis</a> * @version $Revision: 1.1.1.1 $ $Date: 2005/06/23 01:48:54 $ * @since iRunningLog 1.0 */public abstract class HasRunnerIdBO extends BaseBO {    /** <code>Log</code> instance for this class. */    private static final Log LOG = LogFactory.getLog(HasRunnerIdBO.class);    /** The BO's <em>runner id</em> field. */    private String mRunnerId;    /**     * Get the value of the BO's <em>runner id</em> field.     *     * @return The current value of the <em>id</em> field     */    public String getRunnerId() {        return mRunnerId;    }    /**     * Set the value of the BO's <em>runner id</em> field.     *     * @param value The value to be set onto the <em>id</em> field     */    public void setRunnerId(String value) {        mRunnerId = value;    }    /**     * Get a data transfer objects containing values that represent the current     * state of this BO.  This is a template method that is called from the     * final method <code>getValues</code> in <code>BaseBO</code>.     *     * @return The data transfer object, populated with the appropriate values     * @see BaseBO#getValues()     */    protected DTO getValuesInternal() {        DTO valueObject = super.getValuesInternal();        String value = null;        if (LOG.isDebugEnabled()) {            LOG.debug("getValuesInternal: Contents of the value object "                      + " (before) " + valueObject);        }        value = getRunnerId();        valueObject.setValue(HasRunnerId.FIELD_RUNNER_ID, value);        if (LOG.isDebugEnabled()) {            LOG.debug("getValuesInternal: Contents of the value object (after) "                      + valueObject);        }        return valueObject;    }    /**     * Update the BO's fields with the values provided in a data transfer     * object.  This is a template method that is called from the final     * <code>setValue</code> method in <code>BaseBO</code>.     *     * @param valueObject The data transfer object containing values to be     *                    used in updating this BO     * @throws ConversionException If a conversion error occurrs while setting     *                             the fields     * @see BaseBO#setValues(DTO)     */    protected void setValuesInternal(DTO valueObject)                                                   throws ConversionException {        if (LOG.isDebugEnabled()) {            LOG.debug("setValuesInternal: Contents of the value object "                      + valueObject);        }        super.setValuesInternal(valueObject);        String value = null;        value = valueObject.getValue(HasRunnerId.FIELD_RUNNER_ID);        setRunnerId(value);    }    /**     * Validate the values contained in a data transfer object.  This method     * is reponsible for perofrming all validations on the transfer object, and     * should be called before updating the BO's fields to avoid     * bad data and/or errors.     *     * @param valueObject The data transfer object whose fields are to be     *                    validated     * @return A list consisting of any errors found while validating the     *         transfer object     */    protected List validateValues(DTO valueObject) {        List errors = super.validateValues(valueObject);        if (LOG.isDebugEnabled()) {            LOG.debug("validateValues: Before validations, error list contains"                      + errors.size() + " error(s)");        }        validateRunnerIdValue(valueObject, errors);        if (LOG.isDebugEnabled()) {            LOG.debug("validateValues: After validations, error list contains"                      + errors.size() + " error(s)");        }        return errors;    }    /**     * Validate the <code>id</code> field value on a data transfer     * object.     *     * @param valueObject The data transfer object containing the value(s) to     *                    be validated     * @param errors An error list, which this method may add to if there are     *               any validation errors     */    private void validateRunnerIdValue(DTO valueObject, List errors) {        String fieldName = HasRunnerId.FIELD_RUNNER_ID;        ValidationUtilities.executeRequiredFieldValidation(valueObject,                                                           fieldName,                                                           errors);        ValidationUtilities.executeMaxLengthValidation(valueObject,                                                       fieldName,                                                       errors);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -