KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > excalibur > source > SourceValidity


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.excalibur.source;
18
19 import java.io.Serializable JavaDoc;
20
21 /**
22  * A <code>SourceValidity</code> object contains all information to check if a Source
23  * object is still valid.
24  * <p>
25  * There are two possibilities:
26  * <ul>
27  * <li>The validity object has all information to check by itself if it is valid
28  * (e.g. given an expires date).</li>
29  * <li>The validity object possibility needs another (newer) validity object to compare
30  * against (e.g. to test a last modification date).</li>
31  * </ul>
32  * To avoid testing what the actual implementation of the validity object supports,
33  * the invocation order is to first call {@link #isValid()} and only if this result
34  * is <code>0</code> (i.e. "don't know"), then to call {@link #isValid(SourceValidity)}.
35  * <p>
36  * Remember to call {@link #isValid(SourceValidity)} when {@link #isValid()} returned
37  * <code>0</code> !
38  *
39  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
40  * @version CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:26 $
41  */

42 public interface SourceValidity
43     extends Serializable JavaDoc
44 {
45     final int VALID = +1;
46     final int INVALID = -1;
47     /** @deprecated because it has been misspelled, use UNKNOWN of course */
48     final int UNKNWON = 0;
49     final int UNKNOWN = 0;
50     
51     /**
52      * Check if the component is still valid. The possible results are :
53      * <ul>
54      * <li><code>-1</code>: invalid. The component isn't valid anymore.</li>
55      * <li><code>0</code>: don't know. This validity should be checked against a new
56      * validity object using {@link #isValid(SourceValidity)}.</li>
57      * <li><code>1</code>: valid. The component is still valid.</li>
58      * </ul>
59      */

60     int isValid();
61
62     /**
63      * Check if the component is still valid. This is only true if the incoming Validity
64      * is of the same type and has the "same" values.
65      * <p>
66      * The invocation order is that the isValid
67      * method of the old Validity object is called with the new one as a
68      * parameter.
69      * @return -1 is returned, if the validity object is not valid anymore
70      * +1 is returned, if the validity object is still valid
71      * 0 is returned, if the validity check could not be performed.
72      * In this case, the new validity object is not usable. Examples
73      * for this are: when the validity objects have different types,
74      * or when one validity object for any reason is not able to
75      * get the required information.
76      */

77     int isValid( SourceValidity newValidity );
78 }
79
Popular Tags