KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > swing > data > StringMetaData


1 /*
2  * $Id: StringMetaData.java,v 1.3 2004/09/10 21:54:49 aim Exp $
3  *
4  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
5  * Santa Clara, California 95054, U.S.A. All rights reserved.
6  */

7
8 package org.jdesktop.swing.data;
9
10 /**
11  * <p>
12  * Class for representing meta-data for data fields which contain string
13  * values.
14  * Example usage:<br>
15  * <pre><code>
16  * StringMetaData metaData = new StringMetaData(&quot;streetaddress&quot;,
17  * &quot;Street Address&quot;);
18  * metaData.setRequired(true);
19  * metaData.setMaxLength(32);
20  * </code></pre>
21  * </p>
22
23  * @author Amy Fowler
24  * @version 1.0
25  */

26
27 public class StringMetaData extends MetaData {
28     private boolean multiLine = false;
29     protected int minLength = 0;
30     protected int maxLength = Integer.MAX_VALUE;
31
32     public StringMetaData() {
33         super("stringvalue");
34     }
35
36     public StringMetaData(String JavaDoc name) {
37         super(name);
38     }
39
40     public StringMetaData(String JavaDoc name, String JavaDoc label) {
41         super(name, String JavaDoc.class, label);
42     }
43
44     /**
45      * Gets the meta-data's &quot;minLength&quot; property, which indicates
46      * the minimum number of characters permitted for the data field. The default
47      * is 0, which means there is no minimum.
48      * @see #setMinLength
49      * @return integer indicating the minimum number of characters permitted for
50      * the data field
51      */

52      public int getMinLength() {
53          return minLength;
54      }
55
56      /**
57       * Sets the meta-data's &quot;minLength&quot; property.
58       * @param minLength integer indicating the minimum number of characters permitted for
59       * the data field
60       */

61      public void setMinLength(int minLength) {
62          int oldMinLength = this.minLength;
63          this.minLength = minLength;
64          firePropertyChange("minLength", oldMinLength, minLength);
65      }
66
67      /**
68       * Gets the meta-data's &quot;maxLength&quot; property, which indicates
69       * the maximum number of characters permitted for the data field. The default
70       * is <code>Integer.MAX_VALUE</code>, which means there is no maximum.
71       * @see #setMaxLength
72       * @return integer indicating the maximum number of characters permitted for
73       * the data field
74       */

75       public int getMaxLength() {
76           return maxLength;
77       }
78
79       /**
80        * Sets the meta-data's &quot;maxLength&quot; property.
81        * @param maxLength integer indicating the maximum number of characters
82        * permitted for the data field
83        */

84       public void setMaxLength(int maxLength) {
85           int oldMaxLength = this.maxLength;
86           this.maxLength = maxLength;
87           firePropertyChange("maxLength", oldMaxLength, maxLength);
88       }
89
90       /**
91        *
92        * @return boolean indicating whether or not the value can be a multi-line string
93        */

94       public boolean isMultiLine() {
95           return multiLine;
96       }
97
98       /**
99        * Sets the meta-data's &quot;multLine&quot; property.
100        * @param multiLine boolean indicating whether or not the value can be a
101        * multi-line string
102        */

103       public void setMultiLine(boolean multiLine) {
104           boolean oldMultiLine = this.multiLine;
105           this.multiLine = multiLine;
106           firePropertyChange("multiLine", oldMultiLine, multiLine);
107       }
108 }
Popular Tags