KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > common > value > Value


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.common.value;
10
11
12 import java.io.Serializable JavaDoc;
13 import java.util.List JavaDoc;
14
15 /**
16  * A read only interface used to retrieve data. It represents both for
17  * mono value and multi values. It must implement equals and hashCode.
18  *
19  * The semantics :
20  *
21  * | Storage | mono | multi |
22  * | xxx | xxx | [xxx] |
23  * | null | null | [null] |
24  * --------------------------------
25  * | [] | null | [] |
26  * | [null,..] | null | [null,..] |
27  * | ["1",..] | "1" | ["1",..] |
28  *
29  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
30  * @version $Revision: 1.2 $
31  */

32 public interface Value extends Serializable JavaDoc
33 {
34
35    // ***********************
36
// * Mono valued methods *
37
// ***********************
38

39    /**
40     * Return true if the value is null.
41     */

42    boolean isNull();
43
44    /**
45     * Return the value as a string.
46     */

47    String JavaDoc asString();
48
49    /**
50     * Return the value as an int.
51     *
52     * @throws NullConversionException if one of the values is null
53     * @throws FormatConversionException if one of the values cannot be converted
54     */

55    int asInt() throws NullConversionException, FormatConversionException;
56
57    /**
58     * Return the value as a boolean.
59     *
60     * @throws NullConversionException if one of the values is null
61     * @throws FormatConversionException if one of the values cannot be converted
62     */

63    boolean asBoolean() throws NullConversionException, FormatConversionException;
64
65    /**
66     * Return the value.
67     *
68     */

69    Object JavaDoc asObject();
70
71    // ************************
72
// * Multi valued methods *
73
// ************************
74

75    /**
76     * Return true if it contains more than one value.
77     */

78    boolean isMultiValued();
79
80    /**
81     * Return the values as an array of string.
82     */

83    String JavaDoc[] asStringArray();
84
85    /**
86     * Return the values as an array of int.
87     *
88     * @throws NullConversionException if one of the values is null
89     * @throws FormatConversionException if one of the values cannot be converted
90     */

91    int[] asIntArray() throws NullConversionException, FormatConversionException;
92
93    /**
94     * Return the values as an array of boolean.
95     *
96     * @throws NullConversionException if one of the values is null
97     * @throws FormatConversionException if one of the values cannot be converted
98     */

99    boolean[] asBooleanArray() throws NullConversionException, FormatConversionException;
100
101    /**
102     * Return the values as an array of converted object.
103     */

104    Object JavaDoc[] asObjectArray();
105
106    /**
107     * Return the values as an immutable collection of converted object or null.
108     */

109    List JavaDoc asObjectList();
110 }
111
Popular Tags