View Javadoc
1   /*
2    * File:    StringAttribute.java
3    * Created: 9.5.2007 07:47:19
4    *
5    * Copyright 2007 Michal Burda.
6    *
7    * This program is free software; you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation; either version 2 of the License, or
10   * (at your option) any later version.
11   *
12   * This program 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
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, write to the Free Software
19   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20   */
21  
22  package net.sf.webmancer.db;
23  
24  import net.sf.webmancer.util.ContractChecker;
25  
26  /**
27   * @author Michal Burda
28   */
29  public class StringAttribute extends AbstractAttribute {
30  
31      /**
32       * 
33       */
34      private int maxLength;
35  
36      /**
37       * Constructs the StringAttribute.
38       *
39       * @param id
40       */
41      public StringAttribute() {
42          this.maxLength = -1;
43      }
44  
45      /**
46       * Sets the maximum input length.
47       *
48       * @param maxLength the maximum input length to set
49       */
50      public void setMaximumInputLength(int maxLength) {
51          this.maxLength = maxLength;
52      }
53      
54      /**
55       * @see net.sf.webmancer.db.AbstractAttribute#getMaximumInputLength()
56       */
57      @Override
58      public int getMaximumInputLength() {
59          return this.maxLength;
60      }
61  
62      /**
63       * @see net.sf.webmancer.db.AbstractAttribute#convertInternalToInput(java.lang.Object)
64       */
65      @Override
66      public String convertInternalToInput(Object internal) {
67          ContractChecker.mustBeInstanceOf(internal, String.class, "internal");
68          return (String) internal;
69      }
70  
71      /**
72       * @see net.sf.webmancer.db.AbstractAttribute#convertInternalToOutput(java.lang.Object)
73       */
74      @Override
75      public String convertInternalToOutput(Object internal) {
76          ContractChecker.mustBeInstanceOf(internal, String.class, "internal");
77          return (String) internal;
78      }
79  
80      /**
81       * @see net.sf.webmancer.db.AbstractAttribute#convertDbToInternal(java.lang.Object)
82       */
83      @Override
84      public Object convertDbToInternal(Object dbValue) {
85          // TODO Auto-generated method stub
86          throw new UnsupportedOperationException("convertDbToInternal");
87      }
88  
89  }