001    package net.sf.jolene.dom;
002    
003    /**
004     * A checkbox in a html document.
005     *
006     * @author Dan Howard
007     * @since Oct 14, 2005 6:18:36 AM
008     */
009    public final class CheckBox extends HTMLElement {
010        /**
011         * Default constructor.
012         */
013        public CheckBox() {
014            setAttribute("type", "checkbox");
015        }
016    
017        /**
018         * Construct a checkbox with the specified name.
019         *
020         * @param name name of the checkbox.
021         */
022        public CheckBox(String name) {
023            setName(name);
024            setAttribute("type", "checkbox");
025        }
026    
027        /**
028         * Returns a clone of the checkbox object.
029         *
030         * @return CheckBox object.
031         */
032        @Override
033        public CheckBox clone() {
034            return (CheckBox) super.clone();
035        }
036    
037        /**
038         * Sets the name of the checkbox.
039         *
040         * @param name name of the checkbox.
041         */
042        @Override
043        public void setName(String name) {
044            super.setName(name);
045            setAttribute("name", name);
046        }
047    
048        /**
049         * Sets the value of the checbox. See setChecked to indicate it has been checked.
050         *
051         * @param value value of the checkbox.
052         * @see net.sf.jolene.dom.HTMLElement#setChecked(boolean)
053         */
054        @Override
055        public void setValue(String value) {
056            super.setValue(value);
057            setAttribute("value", value);
058        }
059    }