01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.template.environment;
18:
19: import java.io.Serializable;
20:
21: import org.apache.excalibur.source.SourceValidity;
22:
23: /**
24: * @version SVN $Id: JXSourceValidity.java 449189 2006-09-23 06:52:29Z crossley $
25: */
26: public final class JXSourceValidity implements SourceValidity,
27: Serializable {
28: private final SourceValidity sourceValidity;
29: private final SourceValidity templateValidity;
30:
31: public JXSourceValidity(SourceValidity sourceValidity,
32: SourceValidity templateValidity) {
33: this .sourceValidity = sourceValidity;
34: this .templateValidity = templateValidity;
35: }
36:
37: public int isValid() {
38: switch (sourceValidity.isValid()) {
39: case SourceValidity.INVALID:
40: return SourceValidity.INVALID;
41: case SourceValidity.UNKNOWN: {
42: if (templateValidity.isValid() == SourceValidity.INVALID) {
43: return SourceValidity.INVALID;
44: } else {
45: return SourceValidity.UNKNOWN;
46: }
47: }
48: case SourceValidity.VALID:
49: return templateValidity.isValid();
50: }
51: return SourceValidity.UNKNOWN;
52: }
53:
54: public int isValid(SourceValidity otherValidity) {
55: if (otherValidity instanceof JXSourceValidity) {
56: JXSourceValidity otherJXValidity = (JXSourceValidity) otherValidity;
57: switch (sourceValidity
58: .isValid(otherJXValidity.sourceValidity)) {
59: case SourceValidity.INVALID:
60: return SourceValidity.INVALID;
61: case SourceValidity.UNKNOWN: {
62: if (templateValidity
63: .isValid(otherJXValidity.templateValidity) == SourceValidity.INVALID) {
64: return SourceValidity.INVALID;
65: } else {
66: return SourceValidity.UNKNOWN;
67: }
68: }
69: case SourceValidity.VALID:
70: return templateValidity
71: .isValid(otherJXValidity.templateValidity);
72: }
73: }
74: return 0;
75: }
76:
77: }
|