View Javadoc
1   /**
2    * Copyright 2005-2015 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 text input control type.
31   */
32  @XmlRootElement(name = RemotableTextInput.Constants.ROOT_ELEMENT_NAME)
33  @XmlAccessorType(XmlAccessType.NONE)
34  @XmlType(name = RemotableTextInput.Constants.TYPE_NAME, propOrder = {
35          RemotableTextInput.Elements.SIZE,
36          RemotableTextInput.Elements.WATERMARK,
37  		CoreConstants.CommonElements.FUTURE_ELEMENTS })
38  public final class RemotableTextInput extends RemotableAbstractControl implements Sized, Watermarked {
39  
40      @XmlElement(name = Elements.SIZE, required = false)
41      private final Integer size;
42  
43      @XmlElement(name = Elements.WATERMARK, required = false)
44      private final String watermark;
45  
46      @SuppressWarnings("unused")
47      @XmlAnyElement
48      private final Collection<Element> _futureElements = null;
49  
50      /**
51       * Should only be invoked by JAXB.
52       */
53      @SuppressWarnings("unused")
54      private RemotableTextInput() {
55          size = null;
56          watermark = null;
57      }
58  
59      private RemotableTextInput(Builder b) {
60          size = b.size;
61          watermark = b.watermark;
62      }
63      @Override
64      public Integer getSize() {
65          return size;
66      }
67  
68      @Override
69      public String getWatermark() {
70          return watermark;
71      }
72  
73      public static final class Builder extends RemotableAbstractControl.Builder implements Sized, Watermarked {
74          private Integer size;
75          private String watermark;
76  
77          private Builder() {
78              super();
79          }
80  
81          public static Builder create() {
82              return new Builder();
83          }
84  
85          @Override
86          public Integer getSize() {
87              return size;
88          }
89  
90          public void setSize(Integer size) {
91              if (size != null && size < 1) {
92                  throw new IllegalArgumentException("size was < 1");
93              }
94  
95              this.size = size;
96          }
97  
98          @Override
99          public String getWatermark() {
100             return watermark;
101         }
102 
103         public void setWatermark(String watermark) {
104             this.watermark = watermark;
105         }
106 
107         @Override
108         public RemotableTextInput build() {
109             return new RemotableTextInput(this);
110         }
111     }
112 
113     /**
114      * Defines some internal constants used on this class.
115      */
116     static final class Constants {
117         static final String TYPE_NAME = "TextInputType";
118         final static String ROOT_ELEMENT_NAME = "textInput";
119     }
120 
121     static final class Elements {
122         static final String SIZE = "size";
123         static final String WATERMARK = "watermark";
124     }
125 }