1 /*
2 Copyright (c) 2013 James Ahlborn
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
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
17 package com.healthmarketscience.jackcess.query;
18
19 import java.io.IOException;
20 import java.util.List;
21
22 import com.healthmarketscience.jackcess.NameMap;
23 import com.healthmarketscience.jackcess.PropertyMap;
24 import static com.healthmarketscience.jackcess.impl.query.QueryFormat.*;
25
26
27 /**
28 * Base interface for classes which encapsulate information about an Access
29 * query. The {@link #toSQLString()} method can be used to convert this
30 * object into the actual SQL string which this query data represents.
31 *
32 * @author James Ahlborn
33 */
34 public interface Query
35 {
36
37 public enum Type
38 {
39 SELECT(SELECT_QUERY_OBJECT_FLAG, 1),
40 MAKE_TABLE(MAKE_TABLE_QUERY_OBJECT_FLAG, 2),
41 APPEND(APPEND_QUERY_OBJECT_FLAG, 3),
42 UPDATE(UPDATE_QUERY_OBJECT_FLAG, 4),
43 DELETE(DELETE_QUERY_OBJECT_FLAG, 5),
44 CROSS_TAB(CROSS_TAB_QUERY_OBJECT_FLAG, 6),
45 DATA_DEFINITION(DATA_DEF_QUERY_OBJECT_FLAG, 7),
46 PASSTHROUGH(PASSTHROUGH_QUERY_OBJECT_FLAG, 8),
47 UNION(UNION_QUERY_OBJECT_FLAG, 9),
48 UNKNOWN(-1, -1);
49
50 private final int _objectFlag;
51 private final short _value;
52
53 private Type(int objectFlag, int value) {
54 _objectFlag = objectFlag;
55 _value = (short)value;
56 }
57
58 public int getObjectFlag() {
59 return _objectFlag;
60 }
61
62 public short getValue() {
63 return _value;
64 }
65 }
66
67 /**
68 * Returns the name of the query.
69 */
70 public String getName();
71
72 /**
73 * Returns the type of the query.
74 */
75 public Type getType();
76
77 /**
78 * Whether or not this query has been marked as hidden.
79 * @usage _general_method_
80 */
81 public boolean isHidden();
82
83 /**
84 * Returns the unique object id of the query.
85 */
86 public int getObjectId();
87
88 public int getObjectFlag();
89
90 /**
91 * Returns the rows from the system query table from which the query
92 * information was derived.
93 */
94 // public List<Row> getRows();
95
96 public List<String> getParameters();
97
98 public String getOwnerAccessType();
99
100 /**
101 * Returns the actual SQL string which this query data represents.
102 */
103 public String toSQLString();
104
105 /**
106 * @return the properties for this query
107 * @usage _general_method_
108 */
109 public PropertyMap getProperties() throws IOException;
110
111 /**
112 * @return the name map for this query, which cannot be changed, or {@code
113 * null} if the query has none
114 * @usage _intermediate_method_
115 */
116 public NameMap getNameMap() throws IOException;
117 }