01: /*
02: * Copyright 2004-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.springframework.webflow.engine;
17:
18: import java.io.ObjectStreamException;
19: import java.io.Serializable;
20:
21: import org.springframework.webflow.execution.RequestContext;
22:
23: /**
24: * Transition criteria that always returns true.
25: *
26: * @author Keith Donald
27: */
28: public class WildcardTransitionCriteria implements TransitionCriteria,
29: Serializable {
30:
31: /*
32: * Implementation note: not located in webflow.execution.support package to
33: * avoid a cyclic dependency between webflow.execution and webflow.execution.support.
34: */
35:
36: /**
37: * Event id value ("*") that will cause the transition to match on any
38: * event.
39: */
40: public static final String WILDCARD_EVENT_ID = "*";
41:
42: /**
43: * Shared instance of a TransitionCriteria that always returns true.
44: */
45: public static final WildcardTransitionCriteria INSTANCE = new WildcardTransitionCriteria();
46:
47: /**
48: * Private constructor because this is a singleton.
49: */
50: private WildcardTransitionCriteria() {
51: }
52:
53: public boolean test(RequestContext context) {
54: return true;
55: }
56:
57: // resolve the singleton instance
58: private Object readResolve() throws ObjectStreamException {
59: return INSTANCE;
60: }
61:
62: public String toString() {
63: return WILDCARD_EVENT_ID;
64: }
65: }
|