KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > jcr > source > JCRNodeSourceValidity


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

16 package org.apache.cocoon.jcr.source;
17
18 import javax.jcr.Value;
19
20 import org.apache.excalibur.source.SourceValidity;
21
22 /**
23  * Validity of a {@link JCRNodeSource}. It's a wrapper around a JCR
24  * <code>Value</code>.
25  *
26  * @version $Id: JCRNodeSourceValidity.java 240329 2005-08-26 20:04:15Z vgritsenko $
27  */

28 public class JCRNodeSourceValidity implements SourceValidity {
29
30     private Value value;
31
32     public JCRNodeSourceValidity(Value value) {
33         this.value = value;
34     }
35
36     public int isValid() {
37         // Don't know, need another validity to compare with
38
return 0;
39     }
40
41     public int isValid(SourceValidity other) {
42         if (other instanceof JCRNodeSourceValidity) {
43             // compare the two values
44
return ((JCRNodeSourceValidity) other).value.equals(this.value) ? 1 : -1;
45         } else {
46             // invalid
47
return -1;
48         }
49     }
50 }
51
Popular Tags