001    package net.sf.jolene.dom;
002    
003    import net.sf.jolene.constants.Tags;
004    
005    /**
006     * A TextArea in a html document.
007     *
008     * @author Dan Howard
009     * @since Oct 11, 2003
010     */
011    public final class TextArea extends HTMLElement {
012    
013        /**
014         * Default constructor.
015         */
016        public TextArea() {
017            tag = Tags.textarea;
018        }
019    
020    
021        /**
022         * Construct a textarea with the specified name.
023         *
024         * @param name name of the textarea.
025         */
026        public TextArea(String name) {
027            this();
028            setName(name);
029        }
030    
031    
032        /**
033         * Returns a clone of the textarea object.
034         *
035         * @return TextArea object.
036         */
037        @Override
038        public TextArea clone() {
039            return (TextArea) super.clone();
040        }
041    
042    
043        /**
044         * Sets the text of the textarea. Same as setValue.
045         *
046         * @param text text value to set on TextArea.
047         */
048        @Override
049        public void setContent(String text) {
050            super.setContent(text);
051            setValue(text);
052        }
053    
054        /**
055         * Sets the name of the textarea.
056         *
057         * @param name name of the textarea.
058         */
059        @Override
060        public void setName(String name) {
061            super.setName(name);
062            setAttribute("name", name);
063        }
064    
065        /**
066         * Renders the textarea.
067         *
068         * @return The textarea as a html string.
069         */
070        @Override
071        public String toString() {
072    
073            if (swapWith != null) {
074                return swapWith;
075            }
076    
077            if (!isRenderable() && !log.isDebugEnabled()) {
078                return "";
079            }
080    
081            return super.toString() + getValue() + "</" + tag + '>';
082        }
083    }