git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@398 f203690c-595d-4dc9-a70b-905162fa7fd2tags/rel_1_1_19
@@ -618,7 +618,7 @@ public class Database | |||
} | |||
/** | |||
* Finds all the relationships in the database between the given tables. | |||
* Finds all the queries in the database. | |||
*/ | |||
public List<Query> getQueries() | |||
throws IOException |
@@ -33,6 +33,9 @@ import static com.healthmarketscience.jackcess.query.QueryFormat.*; | |||
/** | |||
* Concrete Query subclass which represents an append query, e.g.: | |||
* {@code INSERT INTO <table> VALUES (<values>)} | |||
* | |||
* @author James Ahlborn | |||
*/ | |||
public class AppendQuery extends BaseSelectQuery |
@@ -27,14 +27,14 @@ King of Prussia, PA 19406 | |||
package com.healthmarketscience.jackcess.query; | |||
import java.util.ArrayList; | |||
import java.util.Iterator; | |||
import java.util.List; | |||
import static com.healthmarketscience.jackcess.query.QueryFormat.*; | |||
/** | |||
* Base class for queries which represent some form of SELECT statement. | |||
* | |||
* @author James Ahlborn | |||
*/ | |||
public abstract class BaseSelectQuery extends Query |
@@ -33,6 +33,9 @@ import static com.healthmarketscience.jackcess.query.QueryFormat.*; | |||
/** | |||
* Concrete Query subclass which represents a crosstab/pivot query, e.g.: | |||
* {@code TRANSFORM <expr> SELECT <query> PIVOT <expr>} | |||
* | |||
* @author James Ahlborn | |||
*/ | |||
public class CrossTabQuery extends BaseSelectQuery |
@@ -31,7 +31,7 @@ import java.util.List; | |||
/** | |||
* SQL query which represents a DDL query. | |||
* Concrete Query subclass which represents a DDL query. | |||
* | |||
* @author James Ahlborn | |||
*/ |
@@ -31,6 +31,9 @@ import java.util.List; | |||
/** | |||
* Concrete Query subclass which represents a delete query, e.g.: | |||
* {@code DELETE * FROM <table> WHERE <expression>} | |||
* | |||
* @author James Ahlborn | |||
*/ | |||
public class DeleteQuery extends BaseSelectQuery |
@@ -29,10 +29,11 @@ package com.healthmarketscience.jackcess.query; | |||
import java.util.List; | |||
import static com.healthmarketscience.jackcess.query.QueryFormat.*; | |||
/** | |||
* Concrete Query subclass which represents an table creation query, e.g.: | |||
* {@code SELECT <query> INTO <newTable>} | |||
* | |||
* @author James Ahlborn | |||
*/ | |||
public class MakeTableQuery extends BaseSelectQuery |
@@ -31,7 +31,8 @@ import java.util.List; | |||
/** | |||
* SQL query which represents a query which will be executed via ODBC. | |||
* Concrete Query subclass which represents a query which will be executed via | |||
* ODBC. | |||
* | |||
* @author James Ahlborn | |||
*/ |
@@ -44,6 +44,10 @@ import static com.healthmarketscience.jackcess.query.QueryFormat.*; | |||
/** | |||
* Base class for classes which encapsulate information about an Access query. | |||
* The {@link #toSQLString()} method can be used to convert this object into | |||
* the actual SQL string which this query data represents. | |||
* | |||
* @author James Ahlborn | |||
*/ | |||
public abstract class Query | |||
@@ -103,14 +107,23 @@ public abstract class Query | |||
} | |||
} | |||
/** | |||
* Returns the name of the query. | |||
*/ | |||
public String getName() { | |||
return _name; | |||
} | |||
/** | |||
* Returns the type of the query. | |||
*/ | |||
public Type getType() { | |||
return _type; | |||
} | |||
/** | |||
* Returns the unique object id of the query. | |||
*/ | |||
public int getObjectId() { | |||
return _objectId; | |||
} | |||
@@ -119,6 +132,10 @@ public abstract class Query | |||
return getType().getObjectFlag(); | |||
} | |||
/** | |||
* Returns the rows from the system query table from which the query | |||
* information was derived. | |||
*/ | |||
public List<Row> getRows() { | |||
return _rows; | |||
} | |||
@@ -353,6 +370,9 @@ public abstract class Query | |||
return true; | |||
} | |||
/** | |||
* Returns the actual SQL string which this query data represents. | |||
*/ | |||
public String toSQLString() | |||
{ | |||
StringBuilder builder = new StringBuilder(); | |||
@@ -379,6 +399,17 @@ public abstract class Query | |||
return ToStringBuilder.reflectionToString(this); | |||
} | |||
/** | |||
* Creates a concrete Query instance from the given query data. | |||
* | |||
* @param objectFlag the flag indicating the type of the query | |||
* @param name the name of the query | |||
* @param rows the rows from the system query table containing the data | |||
* describing this query | |||
* @param objectId the unique object id of this query | |||
* | |||
* @return a Query instance for the given query data | |||
*/ | |||
public static Query create(int objectFlag, String name, List<Row> rows, | |||
int objectId) | |||
{ | |||
@@ -525,7 +556,7 @@ public abstract class Query | |||
return builder; | |||
} | |||
private static class UnknownQuery extends Query | |||
private static final class UnknownQuery extends Query | |||
{ | |||
private final int _objectFlag; | |||
@@ -547,7 +578,11 @@ public abstract class Query | |||
} | |||
} | |||
public static class Row | |||
/** | |||
* Struct containing the information from a single row of the system query | |||
* table. | |||
*/ | |||
public static final class Row | |||
{ | |||
public final Byte attribute; | |||
public final String expression; | |||
@@ -674,7 +709,7 @@ public abstract class Query | |||
} | |||
} | |||
private static class Join | |||
private static final class Join | |||
{ | |||
public final List<String> tables = new ArrayList<String>(); | |||
public boolean isJoin; |
@@ -35,6 +35,8 @@ import com.healthmarketscience.jackcess.DataType; | |||
import org.apache.commons.lang.SystemUtils; | |||
/** | |||
* Constants used by the query data parsing. | |||
* | |||
* @author James Ahlborn | |||
*/ | |||
public class QueryFormat |
@@ -31,6 +31,9 @@ import java.util.List; | |||
/** | |||
* Concrete Query subclass which represents a select query, e.g.: | |||
* {@code SELECT <columns> FROM <tables> WHERE <expression>} | |||
* | |||
* @author James Ahlborn | |||
*/ | |||
public class SelectQuery extends BaseSelectQuery |
@@ -33,7 +33,8 @@ import static com.healthmarketscience.jackcess.query.QueryFormat.*; | |||
/** | |||
* SQL query which represents a UNION query. | |||
* Concrete Query subclass which represents a UNION query, e.g.: | |||
* {@code SELECT <query1> UNION SELECT <query2>} | |||
* | |||
* @author James Ahlborn | |||
*/ |
@@ -33,6 +33,9 @@ import static com.healthmarketscience.jackcess.query.QueryFormat.*; | |||
/** | |||
* Concrete Query subclass which represents a row update query, e.g.: | |||
* {@code UPDATE <table> SET <newValues>} | |||
* | |||
* @author James Ahlborn | |||
*/ | |||
public class UpdateQuery extends Query |