View Javadoc
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.util.List;
20  
21  import static com.healthmarketscience.jackcess.impl.query.QueryFormat.*;
22  
23  
24  /**
25   * Base interface for classes which encapsulate information about an Access
26   * query.  The {@link #toSQLString()} method can be used to convert this
27   * object into the actual SQL string which this query data represents.
28   * 
29   * @author James Ahlborn
30   */
31  public interface Query 
32  {
33  
34    public enum Type 
35    {
36      SELECT(SELECT_QUERY_OBJECT_FLAG, 1),
37      MAKE_TABLE(MAKE_TABLE_QUERY_OBJECT_FLAG, 2),
38      APPEND(APPEND_QUERY_OBJECT_FLAG, 3),
39      UPDATE(UPDATE_QUERY_OBJECT_FLAG, 4),
40      DELETE(DELETE_QUERY_OBJECT_FLAG, 5),
41      CROSS_TAB(CROSS_TAB_QUERY_OBJECT_FLAG, 6),
42      DATA_DEFINITION(DATA_DEF_QUERY_OBJECT_FLAG, 7),
43      PASSTHROUGH(PASSTHROUGH_QUERY_OBJECT_FLAG, 8),
44      UNION(UNION_QUERY_OBJECT_FLAG, 9),
45      UNKNOWN(-1, -1);
46  
47      private final int _objectFlag; 
48      private final short _value;
49  
50      private Type(int objectFlag, int value) {
51        _objectFlag = objectFlag;
52        _value = (short)value;
53      }
54  
55      public int getObjectFlag() {
56        return _objectFlag;
57      }
58  
59      public short getValue() {
60        return _value;
61      }
62    }
63  
64    /**
65     * Returns the name of the query.
66     */
67    public String getName();
68  
69    /**
70     * Returns the type of the query.
71     */
72    public Type getType();
73  
74    /**
75     * Whether or not this query has been marked as hidden.
76     * @usage _general_method_
77     */
78    public boolean isHidden();
79  
80    /**
81     * Returns the unique object id of the query.
82     */
83    public int getObjectId();
84  
85    public int getObjectFlag();
86  
87    /**
88     * Returns the rows from the system query table from which the query
89     * information was derived.
90     */
91    // public List<Row> getRows();
92  
93    public List<String> getParameters();
94  
95    public String getOwnerAccessType();
96  
97    /**
98     * Returns the actual SQL string which this query data represents.
99     */
100   public String toSQLString();
101 }