01: /*
02: * Copyright (c) 2004 JETA Software, Inc. All rights reserved.
03: *
04: * Redistribution and use in source and binary forms, with or without modification,
05: * are permitted provided that the following conditions are met:
06: *
07: * o Redistributions of source code must retain the above copyright notice,
08: * this list of conditions and the following disclaimer.
09: *
10: * o Redistributions in binary form must reproduce the above copyright notice,
11: * this list of conditions and the following disclaimer in the documentation
12: * and/or other materials provided with the distribution.
13: *
14: * o Neither the name of JETA Software nor the names of its contributors may
15: * be used to endorse or promote products derived from this software without
16: * specific prior written permission.
17: *
18: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21: * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22: * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23: * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25: * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26: * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28: */
29:
30: package com.jeta.forms.store.memento;
31:
32: /**
33: * This class is used to pass information to a GridComponent when it is storing
34: * its state. We use this class to provide a level of control over how the state
35: * is stored. For example, we can do a shallow or deep copy of the state. A
36: * shallow copy happens when only the link references to forms are stored. A
37: * deep copy occurs with the full form information is stored for a linked form.
38: *
39: * @author Jeff Tassin
40: */
41: public class StateRequest {
42: public static final StateRequest DEEP_COPY = new StateRequest(true);
43: public static final StateRequest SHALLOW_COPY = new StateRequest(
44: false);
45:
46: public static final String COMPONENT_ID = "state.request";
47:
48: /**
49: * Flag that indicates if we should perform a deep copy on linked forms.
50: */
51: private boolean m_deep_copy = false;
52:
53: /**
54: * Creates a <code>StateRequest</code> instance with the shallow copy flag
55: */
56: public StateRequest() {
57:
58: }
59:
60: /**
61: * Creates a <code>StateRequest</code> instance with the specified copy
62: * flag
63: *
64: * @param deep_copy
65: * set to true if the request is for a deep copy of the form
66: * state.
67: */
68: public StateRequest(boolean deep_copy) {
69: m_deep_copy = deep_copy;
70: }
71:
72: /**
73: * Returns the flag that indicates if we should perform a deep copy on
74: * linked forms.
75: *
76: * @return the flag that indicates if we should perform a deep copy on
77: * linked forms.
78: */
79: public boolean isDeepCopy() {
80: return m_deep_copy;
81: }
82:
83: /**
84: * Returns the flag that indicates if we should perform a shallow copy on
85: * linked forms.
86: *
87: * @return the flag that indicates if we should perform a shallow copy on
88: * linked forms.
89: */
90: public boolean isShallowCopy() {
91: return !isDeepCopy();
92: }
93: }
|