From 764aa75ad6c2ba78ccd5e84bd7c5ee8f39e9c9d7 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Wed, 31 Jul 2013 03:40:21 +0000 Subject: [PATCH] add Query.isHidden method and expose original object flags on Query instances git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@766 f203690c-595d-4dc9-a70b-905162fa7fd2 --- .../jackcess/impl/DatabaseImpl.java | 2 +- .../jackcess/impl/query/AppendQueryImpl.java | 5 ++- .../impl/query/BaseSelectQueryImpl.java | 6 +-- .../impl/query/CrossTabQueryImpl.java | 5 ++- .../impl/query/DataDefinitionQueryImpl.java | 5 ++- .../jackcess/impl/query/DeleteQueryImpl.java | 5 ++- .../impl/query/MakeTableQueryImpl.java | 5 ++- .../impl/query/PassthroughQueryImpl.java | 5 ++- .../jackcess/impl/query/QueryImpl.java | 43 ++++++++++--------- .../jackcess/impl/query/SelectQueryImpl.java | 5 ++- .../jackcess/impl/query/UnionQueryImpl.java | 5 ++- .../jackcess/impl/query/UpdateQueryImpl.java | 5 ++- .../jackcess/query/Query.java | 6 +++ .../jackcess/query/QueryTest.java | 3 +- 14 files changed, 61 insertions(+), 44 deletions(-) diff --git a/src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java b/src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java index 87f7ef1..da70cbd 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/DatabaseImpl.java @@ -193,7 +193,7 @@ public class DatabaseImpl implements Database /** this object is another type of "system" object */ static final int ALT_SYSTEM_OBJECT_FLAG = 0x02; /** this object is hidden */ - static final int HIDDEN_OBJECT_FLAG = 0x08; + public static final int HIDDEN_OBJECT_FLAG = 0x08; /** all flags which seem to indicate some type of system object */ static final int SYSTEM_OBJECT_FLAGS = SYSTEM_OBJECT_FLAG | ALT_SYSTEM_OBJECT_FLAG; diff --git a/src/java/com/healthmarketscience/jackcess/impl/query/AppendQueryImpl.java b/src/java/com/healthmarketscience/jackcess/impl/query/AppendQueryImpl.java index 1177d6e..285ff04 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/query/AppendQueryImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/query/AppendQueryImpl.java @@ -42,8 +42,9 @@ import com.healthmarketscience.jackcess.query.AppendQuery; public class AppendQueryImpl extends BaseSelectQueryImpl implements AppendQuery { - public AppendQueryImpl(String name, List rows, int objectId) { - super(name, rows, objectId, Type.APPEND); + public AppendQueryImpl(String name, List rows, int objectId, + int objectFlag) { + super(name, rows, objectId, objectFlag, Type.APPEND); } public String getTargetTable() { diff --git a/src/java/com/healthmarketscience/jackcess/impl/query/BaseSelectQueryImpl.java b/src/java/com/healthmarketscience/jackcess/impl/query/BaseSelectQueryImpl.java index 0fddb59..b4d9a22 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/query/BaseSelectQueryImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/query/BaseSelectQueryImpl.java @@ -42,9 +42,9 @@ public abstract class BaseSelectQueryImpl extends QueryImpl implements BaseSelectQuery { - protected BaseSelectQueryImpl(String name, List rows, int objectId, - Type type) { - super(name, rows, objectId, type); + protected BaseSelectQueryImpl(String name, List rows, int objectId, + int objectFlag, Type type) { + super(name, rows, objectId, objectFlag, type); } protected void toSQLSelectString(StringBuilder builder, diff --git a/src/java/com/healthmarketscience/jackcess/impl/query/CrossTabQueryImpl.java b/src/java/com/healthmarketscience/jackcess/impl/query/CrossTabQueryImpl.java index d4b7e28..a88ef5b 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/query/CrossTabQueryImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/query/CrossTabQueryImpl.java @@ -43,8 +43,9 @@ public class CrossTabQueryImpl extends BaseSelectQueryImpl implements CrossTabQuery { - public CrossTabQueryImpl(String name, List rows, int objectId) { - super(name, rows, objectId, Type.CROSS_TAB); + public CrossTabQueryImpl(String name, List rows, int objectId, + int objectFlag) { + super(name, rows, objectId, objectFlag, Type.CROSS_TAB); } protected Row getTransformRow() { diff --git a/src/java/com/healthmarketscience/jackcess/impl/query/DataDefinitionQueryImpl.java b/src/java/com/healthmarketscience/jackcess/impl/query/DataDefinitionQueryImpl.java index 27ee5ab..491c928 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/query/DataDefinitionQueryImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/query/DataDefinitionQueryImpl.java @@ -40,8 +40,9 @@ public class DataDefinitionQueryImpl extends QueryImpl implements DataDefinitionQuery { - public DataDefinitionQueryImpl(String name, List rows, int objectId) { - super(name, rows, objectId, Type.DATA_DEFINITION); + public DataDefinitionQueryImpl(String name, List rows, int objectId, + int objectFlag) { + super(name, rows, objectId, objectFlag, Type.DATA_DEFINITION); } public String getDDLString() { diff --git a/src/java/com/healthmarketscience/jackcess/impl/query/DeleteQueryImpl.java b/src/java/com/healthmarketscience/jackcess/impl/query/DeleteQueryImpl.java index 8c96b6d..fce02ec 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/query/DeleteQueryImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/query/DeleteQueryImpl.java @@ -40,8 +40,9 @@ import com.healthmarketscience.jackcess.query.DeleteQuery; public class DeleteQueryImpl extends BaseSelectQueryImpl implements DeleteQuery { - public DeleteQueryImpl(String name, List rows, int objectId) { - super(name, rows, objectId, Type.DELETE); + public DeleteQueryImpl(String name, List rows, int objectId, + int objectFlag) { + super(name, rows, objectId, objectFlag, Type.DELETE); } @Override diff --git a/src/java/com/healthmarketscience/jackcess/impl/query/MakeTableQueryImpl.java b/src/java/com/healthmarketscience/jackcess/impl/query/MakeTableQueryImpl.java index 29e402b..00c9417 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/query/MakeTableQueryImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/query/MakeTableQueryImpl.java @@ -41,8 +41,9 @@ public class MakeTableQueryImpl extends BaseSelectQueryImpl implements MakeTableQuery { - public MakeTableQueryImpl(String name, List rows, int objectId) { - super(name, rows, objectId, Type.MAKE_TABLE); + public MakeTableQueryImpl(String name, List rows, int objectId, + int objectFlag) { + super(name, rows, objectId, objectFlag, Type.MAKE_TABLE); } public String getTargetTable() { diff --git a/src/java/com/healthmarketscience/jackcess/impl/query/PassthroughQueryImpl.java b/src/java/com/healthmarketscience/jackcess/impl/query/PassthroughQueryImpl.java index af67e2c..7674e5f 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/query/PassthroughQueryImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/query/PassthroughQueryImpl.java @@ -40,8 +40,9 @@ import com.healthmarketscience.jackcess.query.PassthroughQuery; public class PassthroughQueryImpl extends QueryImpl implements PassthroughQuery { - public PassthroughQueryImpl(String name, List rows, int objectId) { - super(name, rows, objectId, Type.PASSTHROUGH); + public PassthroughQueryImpl(String name, List rows, int objectId, + int objectFlag) { + super(name, rows, objectId, objectFlag, Type.PASSTHROUGH); } public String getConnectionString() { diff --git a/src/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java b/src/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java index 354a276..e8952cd 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/query/QueryImpl.java @@ -36,10 +36,11 @@ import java.util.List; import java.util.Map; import com.healthmarketscience.jackcess.RowId; -import com.healthmarketscience.jackcess.query.Query; +import com.healthmarketscience.jackcess.impl.DatabaseImpl; import com.healthmarketscience.jackcess.impl.RowIdImpl; import com.healthmarketscience.jackcess.impl.RowImpl; import static com.healthmarketscience.jackcess.impl.query.QueryFormat.*; +import com.healthmarketscience.jackcess.query.Query; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -62,12 +63,16 @@ public abstract class QueryImpl implements Query private final List _rows; private final int _objectId; private final Type _type; + private final int _objectFlag; - protected QueryImpl(String name, List rows, int objectId, Type type) { + protected QueryImpl(String name, List rows, int objectId, int objectFlag, + Type type) + { _name = name; _rows = rows; _objectId = objectId; _type = type; + _objectFlag = objectFlag; if(type != Type.UNKNOWN) { short foundType = getShortValue(getQueryType(rows), @@ -92,6 +97,10 @@ public abstract class QueryImpl implements Query return _type; } + public boolean isHidden() { + return((_objectFlag & DatabaseImpl.HIDDEN_OBJECT_FLAG) != 0); + } + /** * Returns the unique object id of the query. */ @@ -100,7 +109,7 @@ public abstract class QueryImpl implements Query } public int getObjectFlag() { - return getType().getObjectFlag(); + return _objectFlag; } /** @@ -389,23 +398,23 @@ public abstract class QueryImpl implements Query try { switch(typeFlag) { case SELECT_QUERY_OBJECT_FLAG: - return new SelectQueryImpl(name, rows, objectId); + return new SelectQueryImpl(name, rows, objectId, objectFlag); case MAKE_TABLE_QUERY_OBJECT_FLAG: - return new MakeTableQueryImpl(name, rows, objectId); + return new MakeTableQueryImpl(name, rows, objectId, objectFlag); case APPEND_QUERY_OBJECT_FLAG: - return new AppendQueryImpl(name, rows, objectId); + return new AppendQueryImpl(name, rows, objectId, objectFlag); case UPDATE_QUERY_OBJECT_FLAG: - return new UpdateQueryImpl(name, rows, objectId); + return new UpdateQueryImpl(name, rows, objectId, objectFlag); case DELETE_QUERY_OBJECT_FLAG: - return new DeleteQueryImpl(name, rows, objectId); + return new DeleteQueryImpl(name, rows, objectId, objectFlag); case CROSS_TAB_QUERY_OBJECT_FLAG: - return new CrossTabQueryImpl(name, rows, objectId); + return new CrossTabQueryImpl(name, rows, objectId, objectFlag); case DATA_DEF_QUERY_OBJECT_FLAG: - return new DataDefinitionQueryImpl(name, rows, objectId); + return new DataDefinitionQueryImpl(name, rows, objectId, objectFlag); case PASSTHROUGH_QUERY_OBJECT_FLAG: - return new PassthroughQueryImpl(name, rows, objectId); + return new PassthroughQueryImpl(name, rows, objectId, objectFlag); case UNION_QUERY_OBJECT_FLAG: - return new UnionQueryImpl(name, rows, objectId); + return new UnionQueryImpl(name, rows, objectId, objectFlag); default: // unknown querytype throw new IllegalStateException( @@ -531,18 +540,10 @@ public abstract class QueryImpl implements Query private static final class UnknownQueryImpl extends QueryImpl { - private final int _objectFlag; - private UnknownQueryImpl(String name, List rows, int objectId, int objectFlag) { - super(name, rows, objectId, Type.UNKNOWN); - _objectFlag = objectFlag; - } - - @Override - public int getObjectFlag() { - return _objectFlag; + super(name, rows, objectId, objectFlag, Type.UNKNOWN); } @Override diff --git a/src/java/com/healthmarketscience/jackcess/impl/query/SelectQueryImpl.java b/src/java/com/healthmarketscience/jackcess/impl/query/SelectQueryImpl.java index dfe326a..d7e817e 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/query/SelectQueryImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/query/SelectQueryImpl.java @@ -40,8 +40,9 @@ import com.healthmarketscience.jackcess.query.SelectQuery; public class SelectQueryImpl extends BaseSelectQueryImpl implements SelectQuery { - public SelectQueryImpl(String name, List rows, int objectId) { - super(name, rows, objectId, Type.SELECT); + public SelectQueryImpl(String name, List rows, int objectId, + int objectFlag) { + super(name, rows, objectId, objectFlag, Type.SELECT); } @Override diff --git a/src/java/com/healthmarketscience/jackcess/impl/query/UnionQueryImpl.java b/src/java/com/healthmarketscience/jackcess/impl/query/UnionQueryImpl.java index d94efc1..d01458d 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/query/UnionQueryImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/query/UnionQueryImpl.java @@ -41,8 +41,9 @@ import com.healthmarketscience.jackcess.query.UnionQuery; */ public class UnionQueryImpl extends QueryImpl implements UnionQuery { - public UnionQueryImpl(String name, List rows, int objectId) { - super(name, rows, objectId, Type.UNION); + public UnionQueryImpl(String name, List rows, int objectId, + int objectFlag) { + super(name, rows, objectId, objectFlag, Type.UNION); } public String getUnionType() { diff --git a/src/java/com/healthmarketscience/jackcess/impl/query/UpdateQueryImpl.java b/src/java/com/healthmarketscience/jackcess/impl/query/UpdateQueryImpl.java index 093f3ec..3e334d8 100644 --- a/src/java/com/healthmarketscience/jackcess/impl/query/UpdateQueryImpl.java +++ b/src/java/com/healthmarketscience/jackcess/impl/query/UpdateQueryImpl.java @@ -42,8 +42,9 @@ import com.healthmarketscience.jackcess.query.UpdateQuery; public class UpdateQueryImpl extends QueryImpl implements UpdateQuery { - public UpdateQueryImpl(String name, List rows, int objectId) { - super(name, rows, objectId, Type.UPDATE); + public UpdateQueryImpl(String name, List rows, int objectId, + int objectFlag) { + super(name, rows, objectId, objectFlag, Type.UPDATE); } public List getTargetTables() diff --git a/src/java/com/healthmarketscience/jackcess/query/Query.java b/src/java/com/healthmarketscience/jackcess/query/Query.java index f6d6cc3..991d53a 100644 --- a/src/java/com/healthmarketscience/jackcess/query/Query.java +++ b/src/java/com/healthmarketscience/jackcess/query/Query.java @@ -74,6 +74,12 @@ public interface Query */ public Type getType(); + /** + * Whether or not this query has been marked as hidden. + * @usage _general_method_ + */ + public boolean isHidden(); + /** * Returns the unique object id of the query. */ diff --git a/test/src/java/com/healthmarketscience/jackcess/query/QueryTest.java b/test/src/java/com/healthmarketscience/jackcess/query/QueryTest.java index 015f2fc..ade3ec1 100644 --- a/test/src/java/com/healthmarketscience/jackcess/query/QueryTest.java +++ b/test/src/java/com/healthmarketscience/jackcess/query/QueryTest.java @@ -188,7 +188,8 @@ public class QueryTest extends TestCase } try { - new QueryImpl("TestQuery", rowList, 13, Query.Type.UNION) { + new QueryImpl("TestQuery", rowList, 13, Query.Type.UNION.getObjectFlag(), + Query.Type.UNION) { @Override protected void toSQLString(StringBuilder builder) { throw new UnsupportedOperationException(); }}; -- 2.39.5