01: /*
02:
03: Derby - Class org.apache.derby.impl.sql.compile.DefaultVTIModDeferPolicy
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (the "License"); you may not use this file except in compliance with
10: the License. You may obtain a copy of the License at
11:
12: http://www.apache.org/licenses/LICENSE-2.0
13:
14: Unless required by applicable law or agreed to in writing, software
15: distributed under the License is distributed on an "AS IS" BASIS,
16: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: See the License for the specific language governing permissions and
18: limitations under the License.
19:
20: */
21:
22: package org.apache.derby.impl.sql.compile;
23:
24: import org.apache.derby.vti.DeferModification;
25:
26: /**
27: * This class implements the default policy for defering modifications to virtual
28: * tables.
29: */
30: class DefaultVTIModDeferPolicy implements DeferModification {
31: private final String targetVTIClassName;
32: private final boolean VTIResultSetIsSensitive;
33:
34: DefaultVTIModDeferPolicy(String targetVTIClassName,
35: boolean VTIResultSetIsSensitive) {
36: this .targetVTIClassName = targetVTIClassName;
37: this .VTIResultSetIsSensitive = VTIResultSetIsSensitive;
38: }
39:
40: /**
41: * @see org.apache.derby.vti.DeferModification#alwaysDefer
42: */
43: public boolean alwaysDefer(int statementType) {
44: return false;
45: }
46:
47: /**
48: * @see org.apache.derby.vti.DeferModification#columnRequiresDefer
49: */
50: public boolean columnRequiresDefer(int statementType,
51: String columnName, boolean inWhereClause) {
52: switch (statementType) {
53: case DeferModification.INSERT_STATEMENT:
54: return false;
55:
56: case DeferModification.UPDATE_STATEMENT:
57: return VTIResultSetIsSensitive && inWhereClause;
58:
59: case DeferModification.DELETE_STATEMENT:
60: return false;
61: }
62: return false; // Should not get here.
63: } // end of columnRequiresDefer
64:
65: /**
66: * @see org.apache.derby.vti.DeferModification#subselectRequiresDefer(int,String,String)
67: */
68: public boolean subselectRequiresDefer(int statementType,
69: String schemaName, String tableName) {
70: return false;
71: } // end of subselectRequiresDefer( statementType, schemaName, tableName)
72:
73: /**
74: * @see org.apache.derby.vti.DeferModification#subselectRequiresDefer(int, String)
75: */
76: public boolean subselectRequiresDefer(int statementType,
77: String VTIClassName) {
78: return targetVTIClassName.equals(VTIClassName);
79: } // end of subselectRequiresDefer( statementType, VTIClassName)
80:
81: public void modificationNotify(int statementType, boolean deferred) {
82: }
83: }
|