View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.core.api.uif;
17  
18  import org.kuali.rice.core.api.CoreConstants;
19  import org.w3c.dom.Element;
20  
21  import javax.xml.bind.annotation.XmlAccessType;
22  import javax.xml.bind.annotation.XmlAccessorType;
23  import javax.xml.bind.annotation.XmlAnyElement;
24  import javax.xml.bind.annotation.XmlElement;
25  import javax.xml.bind.annotation.XmlRootElement;
26  import javax.xml.bind.annotation.XmlType;
27  import java.util.Collection;
28  
29  /**
30   * A textarea control type.
31   */
32  @XmlRootElement(name = RemotableTextarea.Constants.ROOT_ELEMENT_NAME)
33  @XmlAccessorType(XmlAccessType.NONE)
34  @XmlType(name = RemotableTextarea.Constants.TYPE_NAME, propOrder = {
35          RemotableTextarea.Elements.ROWS,
36          RemotableTextarea.Elements.COLS,
37          RemotableTextarea.Elements.WATERMARK,
38  		CoreConstants.CommonElements.FUTURE_ELEMENTS })
39  public final class RemotableTextarea extends RemotableAbstractControl implements Watermarked, RowsCols {
40  
41      @XmlElement(name = Elements.ROWS, required = false)
42      private final Integer rows;
43  
44      @XmlElement(name = Elements.COLS, required = false)
45      private final Integer cols;
46  
47      @XmlElement(name = Elements.WATERMARK, required = false)
48      private final String watermark;
49  
50      @SuppressWarnings("unused")
51      @XmlAnyElement
52      private final Collection<Element> _futureElements = null;
53  
54      /**
55       * Should only be invoked by JAXB.
56       */
57      @SuppressWarnings("unused")
58      private RemotableTextarea() {
59          rows = null;
60          cols = null;
61          watermark = null;
62      }
63  
64      private RemotableTextarea(Builder b) {
65          rows = b.rows;
66          cols = b.cols;
67          watermark = b.watermark;
68      }
69  
70      @Override
71      public Integer getRows() {
72          return rows;
73      }
74  
75      @Override
76      public Integer getCols() {
77          return cols;
78      }
79  
80      @Override
81      public String getWatermark() {
82          return watermark;
83      }
84  
85      public static final class Builder extends RemotableAbstractControl.Builder implements Watermarked, RowsCols {
86          private Integer rows;
87          private Integer cols;
88          private String watermark;
89  
90          private Builder() {
91              super();
92          }
93  
94          public static Builder create() {
95              return new Builder();
96          }
97  
98          @Override
99          public Integer getRows() {
100             return rows;
101         }
102 
103         public void setRows(Integer rows) {
104             if (rows != null && rows < 1) {
105                 throw new IllegalArgumentException("rows was < 1");
106             }
107 
108             this.rows = rows;
109         }
110 
111         @Override
112         public Integer getCols() {
113             return cols;
114         }
115 
116         public void setCols(Integer cols) {
117             if (cols != null && cols < 1) {
118                 throw new IllegalArgumentException("cols was < 1");
119             }
120 
121             this.cols = cols;
122         }
123 
124         @Override
125         public String getWatermark() {
126             return watermark;
127         }
128 
129         public void setWatermark(String watermark) {
130             this.watermark = watermark;
131         }
132 
133         @Override
134         public RemotableTextarea build() {
135             return new RemotableTextarea(this);
136         }
137     }
138 
139     /**
140      * Defines some internal constants used on this class.
141      */
142     static final class Constants {
143         static final String TYPE_NAME = "TextareaType";
144         final static String ROOT_ELEMENT_NAME = "textarea";
145     }
146 
147     static final class Elements {
148         static final String COLS = "cols";
149         static final String ROWS = "rows";
150         static final String WATERMARK = "watermark";
151     }
152 }