KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > jcr > Value


1 /*
2  * $Id: Value.java,v 1.3 2004/08/07 16:45:05 benjmestrallet Exp $
3  *
4  * Copyright 2002-2004 Day Management AG, Switzerland.
5  *
6  * Licensed under the Day RI License, Version 2.0 (the "License"),
7  * as a reference implementation of the following specification:
8  *
9  * Content Repository API for Java Technology, revision 0.12
10  * <http://www.jcp.org/en/jsr/detail?id=170>
11  *
12  * You may not use this file except in compliance with the License.
13  * You may obtain a copy of the License files at
14  *
15  * http://www.day.com/content/en/licenses/day-ri-license-2.0
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */

24 package javax.jcr;
25
26 import java.io.InputStream JavaDoc;
27 import java.util.Calendar JavaDoc;
28
29 /**
30  * A generic holder for the value of a <code>Property</code>
31  * can be used whithout knowing the exact type (string, double, stream etc.)
32  *
33  * @author Peeter Piegaze
34  * @author Stefan Guggisberg
35  */

36 public interface Value {
37
38   /**
39    * Returns the <code>type</code> of this <code>Value</code>.
40    * One of:
41    * <ul>
42    * <li><code>PropertyType.STRING</code></li>
43    * <li><code>PropertyType.DATE</code></li>
44    * <li><code>PropertyType.BINARY</code></li>
45    * <li><code>PropertyType.DOUBLE</code></li>
46    * <li><code>PropertyType.LONG</code></li>
47    * <li><code>PropertyType.BOOLEAN</code></li>
48    * <li><code>PropertyType.SOFTLINK</code></li>
49    * <li><code>PropertyType.REFERENCE</code></li>
50    * </ul>
51    * See <code>{@link PropertyType}</code>.
52    * <p/>
53    * The type returned is that which was set at property creation.
54    */

55   public int getType();
56
57   /**
58    * Returns the <code>String</code> representation of this value.
59    * Unlike <code>{@link Property#getString()}</code> this method throws a
60    * <code>ValueFormatException</code> if conversion is not possible.
61    *
62    * @return a <code>String</code> representation of this value
63    * @throws ValueFormatException If, due to its type or format, this value
64    * cannot be converted to <code>String</code> (since everything can be
65    * converted to string, this should never happen) or the value is null
66    * (i.e., empty).
67    * @throws IllegalStateException if <code>getStream()</code> has been
68    * called previously at least once.
69    * @throws RepositoryException If another error occurs.
70    */

71   public String JavaDoc getString() throws ValueFormatException, IllegalStateException JavaDoc, RepositoryException;
72
73   /**
74    * Returns the <code>double</code> representation of this value.
75    * Unlike
76    * <code>{@link Property#getDouble()}</code> this method throws a
77    * <code>ValueFormatException</code> if conversion is not possible.
78    *
79    * @return a <code>double</code> representation of this value
80    * @throws ValueFormatException If, due to its type or format, this value
81    * cannot be converted to <code>double</code> or the value is null
82    * (i.e., empty).
83    * @throws IllegalStateException if <code>getStream()</code> has been
84    * called previously at least once.
85    * @throws RepositoryException If another error occurs.
86    */

87   public double getDouble() throws ValueFormatException, IllegalStateException JavaDoc, RepositoryException;
88
89   /**
90    * Returns the <code>InputStream</code> representation of this value.
91    * Unlike
92    * <code>{@link Property#getStream()}</code> this method throws a
93    * <code>ValueFormatException</code> if conversion is not possible.
94    * Please note that calling <code>getStream()</code> repeatedly will always
95    * return the <i>same</i> <code>InputStream</code> object.
96    *
97    * @return a <code>InputStream</code> representation of this value
98    * @throws ValueFormatException If, due to its type or format, this value
99    * cannot be converted to <code>InputStream</code> (since everything can be
100    * converted to string, this should never happen) or the value is null
101    * (i.e., empty).
102    * @throws IllegalStateException if any getter methods other than
103    * <code>getStream()</code> and <code>getState()</code> have been
104    * called previously at least once.
105    * @throws RepositoryException If another error occurs.
106    */

107   public InputStream JavaDoc getStream() throws ValueFormatException, IllegalStateException JavaDoc, RepositoryException;
108
109   /**
110    * Returns the <code>Calendar</code> representation of this value.
111    * Unlike
112    * <code>{@link Property#getDate()}</code> this method throws a
113    * <code>ValueFormatException</code> if conversion is not possible.
114    *
115    * @return a <code>Calendar</code> representation of this value
116    * @throws ValueFormatException If, due to its type or format, this value
117    * cannot be converted to <code>Calendar</code> or the value is null
118    * (i.e., empty).
119    * @throws IllegalStateException if <code>getStream()</code> has been
120    * called previously at least once.
121    * @throws RepositoryException If another error occurs.
122    */

123   public Calendar JavaDoc getDate() throws ValueFormatException, IllegalStateException JavaDoc, RepositoryException;
124
125   /**
126    * Returns the <code>long</code> representation of this value.
127    * Unlike
128    * <code>{@link Property#getLong()}</code> this method throws a
129    * <code>ValueFormatException</code> if conversion is not possible.
130    *
131    * @return a <code>long</code> representation of this value
132    * @throws ValueFormatException If, due to its type or format, this value
133    * cannot be converted to <code>long</code> or the value is null
134    * (i.e., empty).
135    * @throws IllegalStateException if <code>getStream()</code> has been
136    * called previously at least once.
137    * @throws RepositoryException If another error occurs.
138    */

139   public long getLong() throws ValueFormatException, IllegalStateException JavaDoc, RepositoryException;
140
141   /**
142    * Returns the <code>boolean</code> representation of this value.
143    * Unlike
144    * <code>{@link Property#getBoolean()}</code> this method throws a
145    * <code>ValueFormatException</code> if conversion is not possible.
146    * Same as level 1.
147    *
148    * @return a <code>boolean</code> representation of this value
149    * @throws ValueFormatException If, due to its type or format, this value
150    * cannot be converted to <code>boolean</code> or the value is null
151    * (i.e., empty).
152    * @throws IllegalStateException if <code>getStream()</code> has been
153    * called previously at least once.
154    * @throws RepositoryException If another error occurs.
155    */

156   public boolean getBoolean() throws ValueFormatException, IllegalStateException JavaDoc, RepositoryException;
157 }
Popular Tags