KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > queryframework > InMemoryQueryIndirectionPolicy


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.queryframework;
23
24
25 /**
26  * <p><b>Purpose</b>:
27  * Used to provide the user with a means of contoling the behaviour of in memory queries
28  * that access un-instantiated indirection in the query..
29  *
30  * <p><b>Description</b>:
31  * This class contains a state variable that is used to determine what a query should do
32  * when accesing un-instantiated indirection. Use use this policy access the policy of a query
33  * set the policy behaviour using the methods below. All read queries have the policy set to throw exception by default
34  *
35  * @author Gordon Yorke
36  * @since TopLink/Java 3.6.3
37  */

38 public class InMemoryQueryIndirectionPolicy implements java.io.Serializable JavaDoc {
39     public static final int SHOULD_THROW_INDIRECTION_EXCEPTION = 0;
40     public static final int SHOULD_TRIGGER_INDIRECTION = 1;
41     public static final int SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED = 2;
42     public static final int SHOULD_IGNORE_EXCEPTION_RETURN_NOT_CONFORMED = 3;
43     protected int policy;
44
45     public InMemoryQueryIndirectionPolicy() {
46         this.policy = SHOULD_THROW_INDIRECTION_EXCEPTION;
47     }
48
49     public InMemoryQueryIndirectionPolicy(int policyValue) {
50         this.policy = policyValue;
51     }
52
53     public boolean shouldTriggerIndirection() {
54         return this.policy == SHOULD_TRIGGER_INDIRECTION;
55     }
56
57     public boolean shouldThrowIndirectionException() {
58         return this.policy == SHOULD_THROW_INDIRECTION_EXCEPTION;
59     }
60
61     public boolean shouldIgnoreIndirectionExceptionReturnConformed() {
62         return this.policy == SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED;
63     }
64
65     public boolean shouldIgnoreIndirectionExceptionReturnNotConformed() {
66         return this.policy == SHOULD_IGNORE_EXCEPTION_RETURN_NOT_CONFORMED;
67     }
68
69     public void ignoreIndirectionExceptionReturnNotConformed() {
70         this.policy = SHOULD_IGNORE_EXCEPTION_RETURN_NOT_CONFORMED;
71     }
72
73     public void ignoreIndirectionExceptionReturnConformed() {
74         this.policy = SHOULD_IGNORE_EXCEPTION_RETURN_CONFORMED;
75     }
76
77     public void triggerIndirection() {
78         this.policy = SHOULD_TRIGGER_INDIRECTION;
79     }
80
81     public void throwIndirectionException() {
82         this.policy = SHOULD_THROW_INDIRECTION_EXCEPTION;
83     }
84
85     //feature 2297
86
public int getPolicy() {
87         return this.policy;
88     }
89
90     public void setPolicy(int policy) {
91         this.policy = policy;
92     }
93 }
94
Popular Tags