KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > datatypes > LengthDataType


1 /*
2
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8
9 */

10 package org.mmbase.datatypes;
11
12 import java.util.*;
13
14 import org.mmbase.bridge.*;
15 import org.mmbase.util.Casting;
16 import org.mmbase.util.logging.*;
17
18 /**
19  * A LengthDataType is a datatype that defines a length for its values ({@link #getLength(Object)}) ,
20  * and restrictions on that (minimal an maximal length). Sometimes you may think 'size' in stead of
21  * length, but we think that there is is not much difference between those...
22  *
23  * @author Pierre van Rooden
24  * @author Michiel Meeuwissen
25  * @version $Id: LengthDataType.java,v 1.4 2005/11/23 12:11:25 michiel Exp $
26  * @since MMBase-1.8
27  */

28 public interface LengthDataType extends DataType {
29
30
31     /**
32      * In this method should be implemented how to calculate such a length for a certain value of
33      * this datatype. There does not exist a generic interface for this, so the implementation
34      * will cast to the expected type (String, byte[]..)
35      */

36     public long getLength(Object JavaDoc value);
37
38     /**
39      * Returns the minimum length of binary values for this datatype.
40      * @return the minimum length as an <code>int</code>, or 0 if there is no minimum length.
41      */

42     public long getMinLength();
43     /**
44      * Returns the 'minLength' restriction, containing the value, errormessages, and fixed status of this attribute.
45      * @return the restriction as a {@link DataType.Restriction}
46      */

47     public DataType.Restriction getMinLengthRestriction();
48
49     /**
50      * Sets the minimum length of binary values for this datatype.
51      * @param value the minimum length as an <code>long</code>, or 0 if there is no minimum length.
52      * @throws Class Identifier: java.lang.UnsupportedOperationException if this datatype is finished
53      */

54     public void setMinLength(long value);
55
56     /**
57      * Returns the maximum length of binary values for this datatype.
58      * @return the maximum length as an <code>long</code>, or a very very big value
59      * (<code>Long.MAX_VALUE</code>) if there is no maximum length.
60      */

61     public long getMaxLength();
62
63     /**
64      * Returns the 'maxLength' restriction, containing the value, errormessages, and fixed status of this attribute.
65      * @return the restriction as a {@link DataType.Restriction}
66      */

67     public DataType.Restriction getMaxLengthRestriction();
68
69     /**
70      * Sets the maximum length of binary values for this datatype.
71      * @param value see {@link #getMaxLength}
72      * @throws Class Identifier: java.lang.UnsupportedOperationException if this datatype is finished
73      */

74     public void setMaxLength(long value);
75
76 }
77
Popular Tags