StringMetaData.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:4k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: StringMetaData.java,v 1.3 2005/10/10 17:01:09 rbair Exp $
  3.  *
  4.  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
  5.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.  */
  21. package org.jdesktop.binding.metadata;
  22. /**
  23.  * <p>
  24.  * Class for representing meta-data for data fields which contain string
  25.  * values.
  26.  * Example usage:<br>
  27.  * <pre><code>
  28.  *     StringMetaData metaData = new StringMetaData(&quot;streetaddress&quot;,
  29.  *                                                  &quot;Street Address&quot;);
  30.  *     metaData.setRequired(true);
  31.  *     metaData.setMaxLength(32);
  32.  * </code></pre>
  33.  * </p>
  34.  * @author Amy Fowler
  35.  * @version 1.0
  36.  */
  37. public class StringMetaData extends MetaData {
  38.     private boolean multiLine = false;
  39.     protected int minLength = 0;
  40.     protected int maxLength = Integer.MAX_VALUE;
  41.     public StringMetaData() {
  42.         super("stringvalue");
  43.     }
  44.     public StringMetaData(String name) {
  45.         super(name);
  46.     }
  47.     public StringMetaData(String name, String label) {
  48.         super(name, String.class, label);
  49.     }
  50.     /**
  51.      * Gets the meta-data's &quot;minLength&quot; property, which indicates
  52.      * the minimum number of characters permitted for the data field.  The default
  53.      * is 0, which means there is no minimum.
  54.      * @see #setMinLength
  55.      * @return integer indicating the minimum number of characters permitted for
  56.      *         the data field
  57.      */
  58.      public int getMinLength() {
  59.          return minLength;
  60.      }
  61.      /**
  62.       * Sets the meta-data's &quot;minLength&quot; property.
  63.       * @param minLength integer indicating the minimum number of characters permitted for
  64.       *         the data field
  65.       */
  66.      public void setMinLength(int minLength) {
  67.          int oldMinLength = this.minLength;
  68.          this.minLength = minLength;
  69.          firePropertyChange("minLength", oldMinLength, minLength);
  70.      }
  71.      /**
  72.       * Gets the meta-data's &quot;maxLength&quot; property, which indicates
  73.       * the maximum number of characters permitted for the data field.  The default
  74.       * is <code>Integer.MAX_VALUE</code>, which means there is no maximum.
  75.       * @see #setMaxLength
  76.       * @return integer indicating the maximum number of characters permitted for
  77.       *         the data field
  78.       */
  79.       public int getMaxLength() {
  80.           return maxLength;
  81.       }
  82.       /**
  83.        * Sets the meta-data's &quot;maxLength&quot; property.
  84.        * @param maxLength integer indicating the maximum number of characters
  85.        *        permitted for the data field
  86.        */
  87.       public void setMaxLength(int maxLength) {
  88.           int oldMaxLength = this.maxLength;
  89.           this.maxLength = maxLength;
  90.           firePropertyChange("maxLength", oldMaxLength, maxLength);
  91.       }
  92.       /**
  93.        *
  94.        * @return boolean indicating whether or not the value can be a multi-line string
  95.        */
  96.       public boolean isMultiLine() {
  97.           return multiLine;
  98.       }
  99.       /**
  100.        * Sets the meta-data's &quot;multLine&quot; property.
  101.        * @param multiLine boolean indicating whether or not the value can be a
  102.        *        multi-line string
  103.        */
  104.       public void setMultiLine(boolean multiLine) {
  105.           boolean oldMultiLine = this.multiLine;
  106.           this.multiLine = multiLine;
  107.           firePropertyChange("multiLine", oldMultiLine, multiLine);
  108.       }
  109. }