01: /*
02:
03: This software is OSI Certified Open Source Software.
04: OSI Certified is a certification mark of the Open Source Initiative.
05:
06: The license (Mozilla version 1.0) can be read at the MMBase site.
07: See http://www.MMBase.org/license
08:
09: */
10: package org.mmbase.datatypes;
11:
12: /**
13: * A LengthDataType is a datatype that defines a length for its values ({@link #getLength(Object)}) ,
14: * and restrictions on that (minimal an maximal length). Sometimes you may think 'size' in stead of
15: * length, but we think that there is is not much difference between those...
16: *
17: * @author Pierre van Rooden
18: * @author Michiel Meeuwissen
19: * @version $Id: LengthDataType.java,v 1.7 2007/04/07 17:11:56 nklasens Exp $
20: * @since MMBase-1.8
21: */
22: public interface LengthDataType<E> extends DataType<E> {
23:
24: /**
25: * In this method should be implemented how to calculate such a length for a certain value of
26: * this datatype. There does not exist a generic interface for this, so the implementation
27: * will cast to the expected type (String, byte[]..)
28: */
29: public long getLength(Object value);
30:
31: /**
32: * Returns the minimum length of binary values for this datatype.
33: * @return the minimum length as an <code>int</code>, or 0 if there is no minimum length.
34: */
35: public long getMinLength();
36:
37: /**
38: * Returns the 'minLength' restriction, containing the value, errormessages, and fixed status of this attribute.
39: * @return the restriction as a {@link DataType.Restriction}
40: */
41: public DataType.Restriction<Long> getMinLengthRestriction();
42:
43: /**
44: * Sets the minimum length of binary values for this datatype.
45: * @param value the minimum length as an <code>long</code>, or 0 if there is no minimum length.
46: * @throws Class Identifier: java.lang.UnsupportedOperationException if this datatype is finished
47: */
48: public void setMinLength(long value);
49:
50: /**
51: * Returns the maximum length of binary values for this datatype.
52: * @return the maximum length as an <code>long</code>, or a very very big value
53: * (<code>Long.MAX_VALUE</code>) if there is no maximum length.
54: */
55: public long getMaxLength();
56:
57: /**
58: * Returns the 'maxLength' restriction, containing the value, errormessages, and fixed status of this attribute.
59: * @return the restriction as a {@link DataType.Restriction}
60: */
61: public DataType.Restriction<Long> getMaxLengthRestriction();
62:
63: /**
64: * Sets the maximum length of binary values for this datatype.
65: * @param value see {@link #getMaxLength}
66: * @throws Class Identifier: java.lang.UnsupportedOperationException if this datatype is finished
67: */
68: public void setMaxLength(long value);
69:
70: }
|