You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@metamodel.apache.org by ka...@apache.org on 2013/07/19 11:33:14 UTC
[31/61] [partial] Hard rename of all 'org/eobjects' folders to
'org/apache'.
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/builder/WhereBuilderImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/builder/WhereBuilderImpl.java b/core/src/main/java/org/eobjects/metamodel/query/builder/WhereBuilderImpl.java
deleted file mode 100644
index 7e1db14..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/builder/WhereBuilderImpl.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.query.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eobjects.metamodel.query.FilterItem;
-import org.eobjects.metamodel.query.OperatorType;
-import org.eobjects.metamodel.query.Query;
-import org.eobjects.metamodel.query.QueryParameter;
-import org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.schema.Column;
-
-final class WhereBuilderImpl extends AbstractQueryFilterBuilder<SatisfiedWhereBuilder<GroupedQueryBuilder>> implements
- WhereBuilder<GroupedQueryBuilder>, SatisfiedWhereBuilder<GroupedQueryBuilder> {
-
- private final Query _query;
- private final List<FilterItem> _orFilters;
- private FilterItem _parentOrFilter;
-
- public WhereBuilderImpl(Column column, Query query, GroupedQueryBuilder queryBuilder) {
- super(new SelectItem(column), queryBuilder);
- _query = query;
- _orFilters = new ArrayList<FilterItem>();
- }
-
- public WhereBuilderImpl(Column column, Query query, FilterItem parentOrFilter, List<FilterItem> orFilters,
- GroupedQueryBuilder queryBuilder) {
- super(new SelectItem(column), queryBuilder);
- _query = query;
- _parentOrFilter = parentOrFilter;
- _orFilters = orFilters;
- }
-
- @Override
- protected SatisfiedWhereBuilder<GroupedQueryBuilder> applyFilter(FilterItem filter) {
- if (_parentOrFilter == null) {
- _query.where(filter);
- } else {
- if (_parentOrFilter.getChildItemCount() == 1) {
- _query.getWhereClause().removeItem(_orFilters.get(0));
- _query.getWhereClause().addItem(_parentOrFilter);
- }
- }
- _orFilters.add(filter);
- return this;
- }
-
- @Override
- public WhereBuilder<GroupedQueryBuilder> or(String columnName) {
- Column column = findColumn(columnName);
- return or(column);
- }
-
- @Override
- public WhereBuilder<GroupedQueryBuilder> or(Column column) {
- if (_parentOrFilter == null) {
- _parentOrFilter = new FilterItem(_orFilters);
- }
- return new WhereBuilderImpl(column, _query, _parentOrFilter, _orFilters, getQueryBuilder());
- }
-
- @Override
- public WhereBuilder<GroupedQueryBuilder> and(String columnName) {
- Column column = findColumn(columnName);
- return and(column);
- }
-
- @Override
- public WhereBuilder<GroupedQueryBuilder> and(Column column) {
- return getQueryBuilder().where(column);
- }
-
- @Override
- public SatisfiedWhereBuilder<GroupedQueryBuilder> eq(QueryParameter queryParameter) {
- return isEquals(queryParameter);
- }
-
- @Override
- public SatisfiedWhereBuilder<GroupedQueryBuilder> isEquals(QueryParameter queryParameter) {
- if (queryParameter == null) {
- throw new IllegalArgumentException("query parameter cannot be null");
- }
- return _filterBuilder.applyFilter(OperatorType.EQUALS_TO, queryParameter);
- }
-
- @Override
- public SatisfiedWhereBuilder<GroupedQueryBuilder> differentFrom(QueryParameter queryParameter) {
- return ne(queryParameter);
- }
-
- @Override
- public SatisfiedWhereBuilder<GroupedQueryBuilder> ne(QueryParameter queryParameter) {
- if (queryParameter == null) {
- throw new IllegalArgumentException("query parameter cannot be null");
- }
- return _filterBuilder.applyFilter(OperatorType.DIFFERENT_FROM, queryParameter);
- }
-
- @Override
- public SatisfiedWhereBuilder<GroupedQueryBuilder> greaterThan(QueryParameter queryParameter) {
- return gt(queryParameter);
- }
-
- @Override
- public SatisfiedWhereBuilder<GroupedQueryBuilder> gt(QueryParameter queryParameter) {
- if (queryParameter == null) {
- throw new IllegalArgumentException("query parameter cannot be null");
- }
- return _filterBuilder.applyFilter(OperatorType.GREATER_THAN, queryParameter);
- }
-
- @Override
- public SatisfiedWhereBuilder<GroupedQueryBuilder> lessThan(QueryParameter queryParameter) {
- return lt(queryParameter);
- }
-
- @Override
- public SatisfiedWhereBuilder<GroupedQueryBuilder> lt(QueryParameter queryParameter) {
- if (queryParameter == null) {
- throw new IllegalArgumentException("query parameter cannot be null");
- }
- return _filterBuilder.applyFilter(OperatorType.LESS_THAN, queryParameter);
- }
-
- @Override
- public SatisfiedWhereBuilder<GroupedQueryBuilder> like(QueryParameter queryParameter) {
- if (queryParameter == null) {
- throw new IllegalArgumentException("query parameter cannot be null");
- }
- return _filterBuilder.applyFilter(OperatorType.LIKE, queryParameter);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/builder/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/builder/package-info.java b/core/src/main/java/org/eobjects/metamodel/query/builder/package-info.java
deleted file mode 100644
index 6226c85..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/builder/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * API for query building
- */
-package org.eobjects.metamodel.query.builder;
-
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/package-info.java b/core/src/main/java/org/eobjects/metamodel/query/package-info.java
deleted file mode 100644
index 48d9b8e..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * API for querying
- */
-package org.eobjects.metamodel.query;
-
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/parser/FromItemParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/parser/FromItemParser.java b/core/src/main/java/org/eobjects/metamodel/query/parser/FromItemParser.java
deleted file mode 100644
index 78fff2e..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/parser/FromItemParser.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.query.parser;
-
-import org.eobjects.metamodel.DataContext;
-import org.eobjects.metamodel.query.FromItem;
-import org.eobjects.metamodel.query.JoinType;
-import org.eobjects.metamodel.query.Query;
-import org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.schema.Table;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-final class FromItemParser implements QueryPartProcessor {
-
- private static final Logger logger = LoggerFactory.getLogger(FromItemParser.class);
-
- private final Query _query;
- private final DataContext _dataContext;
-
- public FromItemParser(DataContext dataContext, Query query) {
- _dataContext = dataContext;
- _query = query;
- }
-
- @Override
- public void parse(String delim, String itemToken) {
- final FromItem fromItem;
-
- final int parenthesisStart = itemToken.indexOf('(');
- if (parenthesisStart != -1) {
- if (parenthesisStart != 0) {
- throw new QueryParserException("Not capable of parsing FROM token: " + itemToken
- + ". Expected parenthesis to start at first character.");
- }
- final int parenthesisEnd = itemToken.indexOf(')', parenthesisStart);
- if (parenthesisEnd == -1) {
- throw new QueryParserException("Not capable of parsing FROM token: " + itemToken
- + ". Expected end parenthesis.");
- }
-
- final String subQueryString = itemToken.substring(parenthesisStart + 1, parenthesisEnd);
- logger.debug("Parsing sub-query: {}", subQueryString);
-
- final Query subQuery = new QueryParser(_dataContext, subQueryString).parse();
- fromItem = new FromItem(subQuery);
-
- final String alias = itemToken.substring(parenthesisEnd + 1).trim();
- if (!alias.isEmpty()) {
- fromItem.setAlias(alias);
- }
- } else if (itemToken.toUpperCase().indexOf(" JOIN ") != -1) {
- fromItem = parseJoinItem(itemToken);
- } else {
- fromItem = parseTableItem(itemToken);
- }
-
- _query.from(fromItem);
- }
-
- private FromItem parseTableItem(String itemToken) {
- final String[] tokens = itemToken.split(" ");
- final String alias;
- if (tokens.length == 2) {
- alias = tokens[1];
- } else if (tokens.length == 1) {
- alias = null;
- } else {
- throw new QueryParserException("Not capable of parsing FROM token: " + itemToken);
- }
-
- final Table table = _dataContext.getTableByQualifiedLabel(tokens[0]);
- if (table == null) {
- throw new QueryParserException("Not capable of parsing FROM token: " + itemToken);
- }
-
- final FromItem result = new FromItem(table);
- result.setAlias(alias);
- result.setQuery(_query);
- return result;
- }
-
- // this method will be documented based on this example itemToken: FOO f
- // INNER JOIN BAR b ON f.id = b.id
- private FromItem parseJoinItem(final String itemToken) {
- final int indexOfJoin = itemToken.toUpperCase().indexOf(" JOIN ");
-
- // firstPart = "FOO f INNER"
- final String firstPart = itemToken.substring(0, indexOfJoin).trim();
-
- // secondPart = "BAR b ON f.id = b.id"
- final String secondPart = itemToken.substring(indexOfJoin + " JOIN ".length()).trim();
-
- final int indexOfJoinType = firstPart.lastIndexOf(" ");
-
- // joinTypeString = "INNER"
- final String joinTypeString = firstPart.substring(indexOfJoinType).trim().toUpperCase();
- final JoinType joinType = JoinType.valueOf(joinTypeString);
-
- // firstTableToken = "FOO f"
- final String firstTableToken = firstPart.substring(0, indexOfJoinType).trim();
-
- final int indexOfOn = secondPart.toUpperCase().indexOf(" ON ");
-
- // secondTableToken = "BAR b"
- final String secondTableToken = secondPart.substring(0, indexOfOn).trim();
-
- final FromItem leftSide = parseTableItem(firstTableToken);
- final FromItem rightSide = parseTableItem(secondTableToken);
-
- // onClausess = ["f.id = b.id"]
- final String[] onClauses = secondPart.substring(indexOfOn + " ON ".length()).split(" AND ");
- final SelectItem[] leftOn = new SelectItem[onClauses.length];
- final SelectItem[] rightOn = new SelectItem[onClauses.length];
- for (int i = 0; i < onClauses.length; i++) {
- final String onClause = onClauses[i];
- final int indexOfEquals = onClause.indexOf("=");
- // leftPart = "f.id"
- final String leftPart = onClause.substring(0, indexOfEquals).trim();
- // rightPart = "b.id"
- final String rightPart = onClause.substring(indexOfEquals + 1).trim();
-
- leftOn[i] = findSelectItem(leftPart, leftSide, rightSide);
- rightOn[i] = findSelectItem(rightPart, leftSide, rightSide);
- }
-
- final FromItem result = new FromItem(joinType, leftSide, rightSide, leftOn, rightOn);
- result.setQuery(_query);
- return result;
- }
-
- private SelectItem findSelectItem(String token, FromItem leftSide, FromItem rightSide) {
- // first look in the original query
- SelectItemParser selectItemParser = new SelectItemParser(_query, false);
- SelectItem result = selectItemParser.findSelectItem(token);
-
- if (result == null) {
- // fail over and try with the from items available in the join that
- // is being built.
- final Query temporaryQuery = new Query().from(leftSide, rightSide);
- selectItemParser = new SelectItemParser(temporaryQuery, false);
- result = selectItemParser.findSelectItem(token);
-
- if (result == null) {
- throw new QueryParserException("Not capable of parsing ON token: " + token);
- }
-
- // set the query on the involved query parts (since they have been
- // temporarily moved to the searched query).
- leftSide.setQuery(_query);
- rightSide.setQuery(_query);
- result.setQuery(_query);
- }
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/parser/GroupByItemParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/parser/GroupByItemParser.java b/core/src/main/java/org/eobjects/metamodel/query/parser/GroupByItemParser.java
deleted file mode 100644
index fc7e776..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/parser/GroupByItemParser.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.query.parser;
-
-import org.eobjects.metamodel.query.Query;
-
-final class GroupByItemParser implements QueryPartProcessor {
-
- private final Query _query;
-
- public GroupByItemParser(Query query) {
- _query = query;
- }
-
- @Override
- public void parse(String delim, String itemToken) {
- _query.groupBy(itemToken);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/parser/HavingItemParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/parser/HavingItemParser.java b/core/src/main/java/org/eobjects/metamodel/query/parser/HavingItemParser.java
deleted file mode 100644
index 5f4a559..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/parser/HavingItemParser.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.query.parser;
-
-import org.eobjects.metamodel.query.Query;
-
-final class HavingItemParser implements QueryPartProcessor {
-
- private final Query _query;
-
- public HavingItemParser(Query query) {
- _query = query;
- }
-
- @Override
- public void parse(String delim, String itemToken) {
- _query.having(itemToken);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/parser/OrderByItemParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/parser/OrderByItemParser.java b/core/src/main/java/org/eobjects/metamodel/query/parser/OrderByItemParser.java
deleted file mode 100644
index 8c3ebf0..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/parser/OrderByItemParser.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.query.parser;
-
-import org.eobjects.metamodel.query.Query;
-
-final class OrderByItemParser implements QueryPartProcessor {
-
- private final Query _query;
-
- public OrderByItemParser(Query query) {
- _query = query;
- }
-
- @Override
- public void parse(String delim, String itemToken) {
- _query.orderBy(itemToken);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryParser.java b/core/src/main/java/org/eobjects/metamodel/query/parser/QueryParser.java
deleted file mode 100644
index a5f0e03..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryParser.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.query.parser;
-
-import org.eobjects.metamodel.DataContext;
-import org.eobjects.metamodel.query.Query;
-
-/**
- * A parser class of for full SQL-like queries.
- */
-public class QueryParser {
-
- private final DataContext _dataContext;
- private final String _queryString;
- private final String _queryStringUpperCase;
-
- public QueryParser(DataContext dataContext, String queryString) {
- if (dataContext == null) {
- throw new IllegalArgumentException("DataContext cannot be null");
- }
- if (queryString == null) {
- throw new IllegalArgumentException("Query string cannot be null");
- }
- _dataContext = dataContext;
- _queryString = prepareQuery(queryString);
- _queryStringUpperCase = _queryString.toUpperCase();
- }
-
- /**
- * Performs any preparations (not changing any semantics) to the query
- * string
- *
- * @param queryString
- * @return
- */
- private String prepareQuery(String queryString) {
- queryString = queryString.replaceAll("[\n\r\t]", " ");
- queryString = queryString.replaceAll(" ", " ");
- queryString = queryString.trim();
- return queryString;
- }
-
- public Query parse() throws QueryParserException {
- final Query query = new Query();
-
- // collect focal point query clauses
- int[] selectIndices = indexesOf("SELECT ", null);
- int[] fromIndices = indexesOf(" FROM ", selectIndices);
- int[] whereIndices = indexesOf(" WHERE ", fromIndices);
- int[] groupByIndices = indexesOf(" GROUP BY ", whereIndices);
- int[] havingIndices = indexesOf(" HAVING ", groupByIndices);
- int[] orderByIndices = indexesOf(" ORDER BY", havingIndices);
- int[] limitIndices = indexesOf(" LIMIT ", orderByIndices);
- int[] offsetIndices = indexesOf(" OFFSET ", limitIndices);
-
- // a few validations, minimum requirements
- if (selectIndices == null) {
- throw new QueryParserException("SELECT not found in query: " + _queryString);
- }
- if (fromIndices == null) {
- throw new QueryParserException("FROM not found in query: " + _queryString);
- }
-
- // parse FROM
- {
- final String fromClause = getSubstring(
- getLastEndIndex(fromIndices),
- getNextStartIndex(whereIndices, groupByIndices, havingIndices, orderByIndices, limitIndices,
- offsetIndices));
- parseFromClause(query, fromClause);
- }
-
- {
- String selectClause = getSubstring(getLastEndIndex(selectIndices), fromIndices[0]);
- if (selectClause.startsWith("DISTINCT ")) {
- query.selectDistinct();
- selectClause = selectClause.substring("DISTINCT ".length());
- }
- parseSelectClause(query, selectClause);
- }
-
- if (whereIndices != null) {
- final String whereClause = getSubstring(getLastEndIndex(whereIndices),
- getNextStartIndex(groupByIndices, havingIndices, orderByIndices, limitIndices, offsetIndices));
- if (whereClause != null) {
- parseWhereClause(query, whereClause);
- }
- }
-
- if (groupByIndices != null) {
- final String groupByClause = getSubstring(getLastEndIndex(groupByIndices, whereIndices),
- getNextStartIndex(havingIndices, orderByIndices, limitIndices, offsetIndices));
- if (groupByClause != null) {
- parseGroupByClause(query, groupByClause);
- }
- }
-
- if (havingIndices != null) {
- final String havingClause = getSubstring(
- getLastEndIndex(havingIndices, groupByIndices, whereIndices, fromIndices, selectIndices),
- getNextStartIndex(orderByIndices, limitIndices, offsetIndices));
- if (havingClause != null) {
- parseHavingClause(query, havingClause);
- }
- }
-
- if (orderByIndices != null) {
- final String orderByClause = getSubstring(
- getLastEndIndex(orderByIndices, havingIndices, groupByIndices, whereIndices, fromIndices,
- selectIndices), getNextStartIndex(limitIndices, offsetIndices));
- if (orderByClause != null) {
- parseOrderByClause(query, orderByClause);
- }
- }
-
- if (limitIndices != null) {
- final String limitClause = getSubstring(
- getLastEndIndex(limitIndices, orderByIndices, havingIndices, groupByIndices, whereIndices,
- fromIndices, selectIndices), getNextStartIndex(offsetIndices));
- if (limitClause != null) {
- parseLimitClause(query, limitClause);
- }
- }
-
- if (offsetIndices != null) {
- final String offsetClause = getSubstring(
- getLastEndIndex(offsetIndices, limitIndices, orderByIndices, havingIndices, groupByIndices,
- whereIndices, fromIndices, selectIndices), getNextStartIndex());
- if (offsetClause != null) {
- parseOffsetClause(query, offsetClause);
- }
- }
-
- return query;
- }
-
- private void parseFromClause(Query query, String fromClause) {
- QueryPartParser clauseParser = new QueryPartParser(new FromItemParser(_dataContext, query), fromClause, ",");
- clauseParser.parse();
- }
-
- private void parseSelectClause(Query query, String selectClause) {
- QueryPartParser clauseParser = new QueryPartParser(new SelectItemParser(query, false), selectClause, ",");
- clauseParser.parse();
- }
-
- private void parseWhereClause(Query query, String whereClause) {
- // only parse "AND" delimitors, since "OR" will be taken care of as
- // compound filter items at 2nd level parsing
- QueryPartParser clauseParser = new QueryPartParser(new WhereItemParser(query), whereClause, " AND ");
- clauseParser.parse();
- }
-
- private void parseGroupByClause(Query query, String groupByClause) {
- QueryPartParser clauseParser = new QueryPartParser(new GroupByItemParser(query), groupByClause, ",");
- clauseParser.parse();
- }
-
- private void parseHavingClause(Query query, String havingClause) {
- // only parse "AND" delimitors, since "OR" will be taken care of as
- // compound filter items at 2nd level parsing
- QueryPartParser clauseParser = new QueryPartParser(new HavingItemParser(query), havingClause, " AND ");
- clauseParser.parse();
- }
-
- private void parseOrderByClause(Query query, String orderByClause) {
- QueryPartParser clauseParser = new QueryPartParser(new OrderByItemParser(query), orderByClause, ",");
- clauseParser.parse();
- }
-
- private void parseLimitClause(Query query, String limitClause) {
- limitClause = limitClause.trim();
- if (!limitClause.isEmpty()) {
- try {
- int limit = Integer.parseInt(limitClause);
- query.setMaxRows(limit);
- } catch (NumberFormatException e) {
- throw new QueryParserException("Could not parse LIMIT value: " + limitClause);
- }
- }
- }
-
- private void parseOffsetClause(Query query, String offsetClause) {
- offsetClause = offsetClause.trim();
- if (!offsetClause.isEmpty()) {
- try {
- final int offset = Integer.parseInt(offsetClause);
- // ofset is 0-based, but first-row is 1-based
- final int firstRow = offset + 1;
- query.setFirstRow(firstRow);
- } catch (NumberFormatException e) {
- throw new QueryParserException("Could not parse OFFSET value: " + offsetClause);
- }
- }
- }
-
- private String getSubstring(Integer from, int to) {
- if (from == null) {
- return null;
- }
- if (from.intValue() == to) {
- return null;
- }
- return _queryString.substring(from, to);
- }
-
- private int getNextStartIndex(int[]... indicesArray) {
- for (int[] indices : indicesArray) {
- if (indices != null) {
- return indices[0];
- }
- }
- return _queryString.length();
- }
-
- private Integer getLastEndIndex(int[]... indicesArray) {
- for (int[] indices : indicesArray) {
- if (indices != null) {
- return indices[1];
- }
- }
- return null;
- }
-
- /**
- * Finds the start and end indexes of a string in the query. The string
- * parameter of this method is expected to be in upper case, while the query
- * itself is tolerant of case differences.
- *
- * @param string
- * @param previousIndices
- * @return
- */
- protected int[] indexesOf(String string, int[] previousIndices) {
- final int startIndex;
- if (previousIndices == null) {
- startIndex = _queryStringUpperCase.indexOf(string);
- } else {
- startIndex = _queryStringUpperCase.indexOf(string, previousIndices[1]);
- }
- if (startIndex == -1) {
- return null;
- }
- int endIndex = startIndex + string.length();
- return new int[] { startIndex, endIndex };
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryParserException.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryParserException.java b/core/src/main/java/org/eobjects/metamodel/query/parser/QueryParserException.java
deleted file mode 100644
index 54bd94d..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryParserException.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.query.parser;
-
-import org.eobjects.metamodel.MetaModelException;
-
-/**
- * Subtype of {@link MetaModelException} which indicate a problem in parsing a
- * query passed to the {@link QueryParser}.
- */
-public class QueryParserException extends MetaModelException {
-
- private static final long serialVersionUID = 1L;
-
- public QueryParserException() {
- super();
- }
-
- public QueryParserException(Exception cause) {
- super(cause);
- }
-
- public QueryParserException(String message, Exception cause) {
- super(message, cause);
- }
-
- public QueryParserException(String message) {
- super(message);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryPartCollectionProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryPartCollectionProcessor.java b/core/src/main/java/org/eobjects/metamodel/query/parser/QueryPartCollectionProcessor.java
deleted file mode 100644
index ac45a49..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryPartCollectionProcessor.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.query.parser;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Simple implementation of {@link QueryPartProcessor} which simply adds all
- * elements to a collection. Use {@link #getTokens()} to retrieve the 'processed'
- * tokens and {@link #getDelims()} for the corresponding delimitors.
- */
-public class QueryPartCollectionProcessor implements QueryPartProcessor {
-
- private final List<String> _delims;
- private final List<String> _tokens;
-
- public QueryPartCollectionProcessor() {
- _tokens = new ArrayList<String>();
- _delims = new ArrayList<String>();
- }
-
- @Override
- public void parse(String delim, String token) {
- _delims.add(delim);
- _tokens.add(token);
- }
-
- public List<String> getDelims() {
- return _delims;
- }
-
- public List<String> getTokens() {
- return _tokens;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryPartParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryPartParser.java b/core/src/main/java/org/eobjects/metamodel/query/parser/QueryPartParser.java
deleted file mode 100644
index 15050ea..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryPartParser.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.query.parser;
-
-/**
- * Parser of query parts. This parser is aware of parenthesis symbols '(' and
- * ')' and only yields tokens that have balanced parentheses. Delimitors are
- * configurable.
- */
-public final class QueryPartParser {
-
- private final QueryPartProcessor _processor;
- private final String _clause;
- private final String[] _ItemDelims;
-
- public QueryPartParser(QueryPartProcessor processor, String clause, String... itemDelims) {
- if (clause == null) {
- throw new IllegalArgumentException("Clause cannot be null");
- }
- if (itemDelims == null || itemDelims.length == 0) {
- throw new IllegalArgumentException("Item delimitors cannot be null or empty");
- }
- _processor = processor;
- _clause = clause;
- _ItemDelims = itemDelims;
- }
-
- public void parse() {
- if (_clause.isEmpty()) {
- return;
- }
-
- int parenthesisCount = 0;
- int offset = 0;
- boolean singleOuterParenthesis = _clause.charAt(0) == '(' && _clause.charAt(_clause.length() - 1) == ')';
-
- String previousDelim = null;
- DelimOccurrence nextDelimOccurrence = getNextDelim(0);
- if (nextDelimOccurrence != null) {
- for (int i = 0; i < _clause.length(); i++) {
- char c = _clause.charAt(i);
- if (c == '(') {
- parenthesisCount++;
- } else if (c == ')') {
- parenthesisCount--;
- if (singleOuterParenthesis && parenthesisCount == 0 && i != _clause.length() - 1) {
- singleOuterParenthesis = false;
- }
- }
- if (i == nextDelimOccurrence.index) {
- if (parenthesisCount == 0) {
- // token bounds has been identified
- String itemToken = _clause.substring(offset, i);
- parseItem(previousDelim, itemToken);
- offset = i + nextDelimOccurrence.delim.length();
- previousDelim = nextDelimOccurrence.delim;
- }
- nextDelimOccurrence = getNextDelim(nextDelimOccurrence.index + 1);
- if (nextDelimOccurrence == null) {
- break;
- }
- }
- }
- }
-
- if (singleOuterParenthesis) {
- String newClause = _clause.substring(1, _clause.length() - 1);
- // re-run based on new clause
- QueryPartParser newParser = new QueryPartParser(_processor, newClause, _ItemDelims);
- newParser.parse();
- return;
- }
-
- // last token will occur outside loop
- if (offset != _clause.length()) {
- final String token = _clause.substring(offset);
- parseItem(previousDelim, token);
- }
- }
-
- private static class DelimOccurrence {
- public int index;
- public String delim;
- }
-
- private DelimOccurrence getNextDelim(int offset) {
- DelimOccurrence result = null;
- for (int i = 0; i < _ItemDelims.length; i++) {
- String delim = _ItemDelims[i];
- int index = _clause.indexOf(delim, offset);
- if (index != -1) {
- if (result == null || index == Math.min(result.index, index)) {
- result = new DelimOccurrence();
- result.index = index;
- result.delim = delim;
- }
- }
- }
- return result;
- }
-
- private void parseItem(String delim, String token) {
- if (token != null) {
- token = token.trim();
- if (!token.isEmpty()) {
- _processor.parse(delim, token);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryPartProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryPartProcessor.java b/core/src/main/java/org/eobjects/metamodel/query/parser/QueryPartProcessor.java
deleted file mode 100644
index 27a5d88..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/parser/QueryPartProcessor.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.query.parser;
-
-/**
- * Callback of the {@link QueryPartParser}, which recieves notifications
- * whenever a token is identified/parsed. A {@link QueryPartProcessor} is used
- * to perform the actual processing of identified tokens.
- */
-public interface QueryPartProcessor {
-
- /**
- * Method invoked whenever the {@link QueryPartParser} identifies a token.
- *
- * @param delim
- * the (previous) delimitor identified before the token. This
- * will always be null in case of the first token.
- * @param token
- * the token identified.
- */
- public void parse(String delim, String token);
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/parser/SelectItemParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/parser/SelectItemParser.java b/core/src/main/java/org/eobjects/metamodel/query/parser/SelectItemParser.java
deleted file mode 100644
index 2810a4a..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/parser/SelectItemParser.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.query.parser;
-
-import org.eobjects.metamodel.MetaModelException;
-import org.eobjects.metamodel.query.FromItem;
-import org.eobjects.metamodel.query.FunctionType;
-import org.eobjects.metamodel.query.Query;
-import org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.schema.Column;
-
-public final class SelectItemParser implements QueryPartProcessor {
-
- public static class MultipleSelectItemsParsedException extends IllegalArgumentException {
-
- private static final long serialVersionUID = 1L;
-
- private final FromItem _fromItem;
-
- public MultipleSelectItemsParsedException(FromItem fromItem) {
- _fromItem = fromItem;
- }
-
- public FromItem getFromItem() {
- return _fromItem;
- }
- }
-
- private final Query _query;
- private final boolean _allowExpressionBasedSelectItems;
-
- public SelectItemParser(Query query, boolean allowExpressionBasedSelectItems) {
- _query = query;
- _allowExpressionBasedSelectItems = allowExpressionBasedSelectItems;
- }
-
- @Override
- public void parse(String delim, String itemToken) throws MetaModelException {
- if ("*".equals(itemToken)) {
- _query.selectAll();
- return;
- }
-
- String alias = null;
- final int indexOfAlias = itemToken.toUpperCase().lastIndexOf(" AS ");
- if (indexOfAlias != -1) {
- alias = itemToken.substring(indexOfAlias + " AS ".length());
- itemToken = itemToken.substring(0, indexOfAlias);
- }
-
- try {
- final SelectItem selectItem = findSelectItem(itemToken);
- if (selectItem == null) {
- throw new QueryParserException("Not capable of parsing SELECT token: " + itemToken);
- }
-
- if (alias != null) {
- selectItem.setAlias(alias);
- }
-
- _query.select(selectItem);
- } catch (MultipleSelectItemsParsedException e) {
- FromItem fromItem = e.getFromItem();
- if (fromItem != null) {
- _query.selectAll(fromItem);
- } else {
- throw e;
- }
- }
- }
-
- /**
- * Finds/creates a SelectItem based on the given expression. Unlike the
- * {@link #parse(String, String)} method, this method will not actually add
- * the selectitem to the query.
- *
- * @param expression
- * @return
- *
- * @throws MultipleSelectItemsParsedException
- * if an expression yielding multiple select-items (such as "*")
- * was passed in the expression
- */
- public SelectItem findSelectItem(String expression) throws MultipleSelectItemsParsedException {
- if ("*".equals(expression)) {
- throw new MultipleSelectItemsParsedException(null);
- }
-
- if ("COUNT(*)".equalsIgnoreCase(expression)) {
- return SelectItem.getCountAllItem();
- }
-
- final FunctionType function;
- final int startParenthesis = expression.indexOf('(');
- if (startParenthesis > 0 && expression.endsWith(")")) {
- String functionName = expression.substring(0, startParenthesis);
- function = FunctionType.get(functionName);
- if (function != null) {
- expression = expression.substring(startParenthesis + 1, expression.length() - 1).trim();
- if (function == FunctionType.COUNT && "*".equals(expression)) {
- return SelectItem.getCountAllItem();
- }
- }
- } else {
- function = null;
- }
-
- int lastIndexOfDot = expression.lastIndexOf(".");
-
- String columnName = null;
- FromItem fromItem = null;
-
- if (lastIndexOfDot != -1) {
- String prefix = expression.substring(0, lastIndexOfDot);
- columnName = expression.substring(lastIndexOfDot + 1);
- fromItem = _query.getFromClause().getItemByReference(prefix);
- }
-
- if (fromItem == null) {
- if (_query.getFromClause().getItemCount() == 1) {
- fromItem = _query.getFromClause().getItem(0);
- columnName = expression;
- } else {
- fromItem = null;
- columnName = null;
- }
- }
-
- if (fromItem != null) {
- if ("*".equals(columnName)) {
- throw new MultipleSelectItemsParsedException(fromItem);
- } else if (fromItem.getTable() != null) {
- Column column = fromItem.getTable().getColumnByName(columnName);
- if (column != null) {
- SelectItem selectItem = new SelectItem(function, column, fromItem);
- return selectItem;
- }
- } else if (fromItem.getSubQuery() != null) {
- final Query subQuery = fromItem.getSubQuery();
- final SelectItem subQuerySelectItem = new SelectItemParser(subQuery, _allowExpressionBasedSelectItems).findSelectItem(columnName);
- if (subQuerySelectItem == null) {
- return null;
- }
- return new SelectItem(subQuerySelectItem, fromItem);
- }
- }
-
- if (_allowExpressionBasedSelectItems) {
- return new SelectItem(function, expression, null);
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/query/parser/WhereItemParser.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/query/parser/WhereItemParser.java b/core/src/main/java/org/eobjects/metamodel/query/parser/WhereItemParser.java
deleted file mode 100644
index 764fbdc..0000000
--- a/core/src/main/java/org/eobjects/metamodel/query/parser/WhereItemParser.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.query.parser;
-
-import org.eobjects.metamodel.query.Query;
-
-final class WhereItemParser implements QueryPartProcessor {
-
- private final Query _query;
-
- public WhereItemParser(Query query) {
- _query = query;
- }
-
- @Override
- public void parse(String delim, String itemToken) {
- _query.where(itemToken);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/schema/AbstractColumn.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/schema/AbstractColumn.java b/core/src/main/java/org/eobjects/metamodel/schema/AbstractColumn.java
deleted file mode 100644
index 85cc2e4..0000000
--- a/core/src/main/java/org/eobjects/metamodel/schema/AbstractColumn.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.schema;
-
-/**
- * Abstract {@link Column} implementation. Implements most common and trivial
- * methods.
- *
- * @author Kasper Sørensen
- */
-public abstract class AbstractColumn implements Column {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public final String getQuotedName() {
- String quote = getQuote();
- if (quote == null) {
- return getName();
- }
- return quote + getName() + quote;
- }
-
- @Override
- public final String getQualifiedLabel() {
- StringBuilder sb = new StringBuilder();
- Table table = getTable();
- if (table != null) {
- sb.append(table.getQualifiedLabel());
- sb.append('.');
- }
- sb.append(getName());
- return sb.toString();
- }
-
- @Override
- public final int compareTo(Column that) {
- int diff = getQualifiedLabel().compareTo(that.getQualifiedLabel());
- if (diff == 0) {
- diff = toString().compareTo(that.toString());
- }
- return diff;
- }
-
- @Override
- public final String toString() {
- return "Column[name=" + getName() + ",columnNumber=" + getColumnNumber() + ",type=" + getType() + ",nullable="
- + isNullable() + ",nativeType=" + getNativeType() + ",columnSize=" + getColumnSize() + "]";
- }
-
- @Override
- public int hashCode() {
- return getName().hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj == this) {
- return true;
- }
- if (obj instanceof Column) {
- Column other = (Column) obj;
- if (!getName().equals(other.getName())) {
- return false;
- }
- if (getType() != other.getType()) {
- return false;
- }
-
- final Table table1 = getTable();
- final Table table2 = other.getTable();
- if (table1 == null) {
- if (table2 != null) {
- return false;
- }
- } else {
- if (!table1.equals(table2)) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/schema/AbstractRelationship.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/schema/AbstractRelationship.java b/core/src/main/java/org/eobjects/metamodel/schema/AbstractRelationship.java
deleted file mode 100644
index c1d5646..0000000
--- a/core/src/main/java/org/eobjects/metamodel/schema/AbstractRelationship.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.schema;
-
-import java.util.List;
-
-import org.eobjects.metamodel.util.BaseObject;
-
-public abstract class AbstractRelationship extends BaseObject implements
- Relationship {
-
- private static final long serialVersionUID = 1L;
-
- protected static Table checkSameTable(Column[] columns) {
- if (columns == null || columns.length == 0) {
- throw new IllegalArgumentException(
- "At least one key-column must exist on both "
- + "primary and foreign side for "
- + "a relation to exist.");
- }
- Table table = null;
- for (int i = 0; i < columns.length; i++) {
- Column column = columns[i];
- if (i == 0) {
- table = column.getTable();
- } else {
- if (table != column.getTable()) {
- throw new IllegalArgumentException(
- "Key-columns did not have same table");
- }
- }
- }
- return table;
- }
-
- @Override
- public Table getForeignTable() {
- return getForeignColumns()[0].getTable();
- }
-
- @Override
- public Table getPrimaryTable() {
- return getPrimaryColumns()[0].getTable();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("Relationship[");
- sb.append("primaryTable=" + getPrimaryTable().getName());
- Column[] columns = getPrimaryColumns();
- sb.append(",primaryColumns=[");
- for (int i = 0; i < columns.length; i++) {
- if (i != 0) {
- sb.append(", ");
- }
- sb.append(columns[i].getName());
- }
- sb.append("]");
- sb.append(",foreignTable=" + getForeignTable().getName());
- columns = getForeignColumns();
- sb.append(",foreignColumns=[");
- for (int i = 0; i < columns.length; i++) {
- if (i != 0) {
- sb.append(", ");
- }
- sb.append(columns[i].getName());
- }
- sb.append("]");
- sb.append("]");
- return sb.toString();
- }
-
- public int compareTo(Relationship that) {
- return toString().compareTo(that.toString());
- }
-
- @Override
- protected final void decorateIdentity(List<Object> identifiers) {
- identifiers.add(getPrimaryColumns());
- identifiers.add(getForeignColumns());
- }
-
- @Override
- protected final boolean classEquals(BaseObject obj) {
- return obj instanceof Relationship;
- }
-
- @Override
- public boolean containsColumnPair(Column pkColumn, Column fkColumn) {
- if (pkColumn != null && fkColumn != null) {
- Column[] primaryColumns = getPrimaryColumns();
- Column[] foreignColumns = getForeignColumns();
- for (int i = 0; i < primaryColumns.length; i++) {
- if (pkColumn.equals(primaryColumns[i])
- && fkColumn.equals(foreignColumns[i])) {
- return true;
- }
- }
- }
- return false;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/schema/AbstractSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/schema/AbstractSchema.java b/core/src/main/java/org/eobjects/metamodel/schema/AbstractSchema.java
deleted file mode 100644
index 79ccb09..0000000
--- a/core/src/main/java/org/eobjects/metamodel/schema/AbstractSchema.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.schema;
-
-import java.util.ArrayList;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eobjects.metamodel.util.Action;
-import org.eobjects.metamodel.util.CollectionUtils;
-import org.eobjects.metamodel.util.EqualsBuilder;
-import org.eobjects.metamodel.util.HasNameMapper;
-import org.eobjects.metamodel.util.Predicate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract implementation of the {@link Schema} interface. Implements most
- * common and trivial methods.
- *
- * @author Kasper Sørensen
- */
-public abstract class AbstractSchema implements Schema {
-
- private static final long serialVersionUID = 1L;
-
- private static final Logger logger = LoggerFactory.getLogger(AbstractSchema.class);
-
- @Override
- public final String getQuotedName() {
- String quote = getQuote();
- if (quote == null) {
- return getName();
- }
- return quote + getName() + quote;
- }
-
- @Override
- public Relationship[] getRelationships() {
- final Set<Relationship> result = new LinkedHashSet<Relationship>();
- CollectionUtils.forEach(getTables(), new Action<Table>() {
- @Override
- public void run(Table table) {
- Relationship[] relations = table.getRelationships();
- for (int i = 0; i < relations.length; i++) {
- Relationship relation = relations[i];
- result.add(relation);
- }
- }
- });
- return result.toArray(new Relationship[result.size()]);
- }
-
- @Override
- public Table getTable(int index) throws IndexOutOfBoundsException {
- Table[] tables = getTables();
- return tables[index];
- }
-
- @Override
- public final String getQualifiedLabel() {
- return getName();
- }
-
- @Override
- public final int getTableCount(TableType type) {
- return getTables(type).length;
- }
-
- @Override
- public final int getRelationshipCount() {
- return getRelationships().length;
- }
-
- @Override
- public final int getTableCount() {
- return getTables().length;
- }
-
- @Override
- public final Table[] getTables(final TableType type) {
- return CollectionUtils.filter(getTables(), new Predicate<Table>() {
- @Override
- public Boolean eval(Table table) {
- return table.getType() == type;
- }
- }).toArray(new Table[0]);
- }
-
- @Override
- public final Table getTableByName(String tableName) {
- if (tableName == null) {
- return null;
- }
-
- final List<Table> foundTables = new ArrayList<Table>(1);
- // Search for table matches, case insensitive.
- for (Table table : getTables()) {
- if (tableName.equalsIgnoreCase(table.getName())) {
- foundTables.add(table);
- }
- }
-
- final int numTables = foundTables.size();
- if (logger.isDebugEnabled()) {
- logger.debug("Found {} tables(s) matching '{}': {}", new Object[] { numTables, tableName, foundTables });
- }
-
- if (numTables == 0) {
- return null;
- } else if (numTables == 1) {
- return foundTables.get(0);
- }
-
- // If more matches are found, search case sensitive
- for (Table table : foundTables) {
- if (tableName.equals(table.getName())) {
- return table;
- }
- }
-
- // if none matches case sensitive, pick the first one.
- return foundTables.get(0);
- }
-
- @Override
- public final String[] getTableNames() {
- Table[] tables = getTables();
- return CollectionUtils.map(tables, new HasNameMapper()).toArray(new String[tables.length]);
- }
-
- @Override
- public final String toString() {
- return "Schema[name=" + getName() + "]";
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj == this) {
- return true;
- }
- if (obj instanceof Schema) {
- Schema other = (Schema) obj;
- EqualsBuilder eb = new EqualsBuilder();
- eb.append(getName(), other.getName());
- eb.append(getQuote(), other.getQuote());
- if (eb.isEquals()) {
- try {
- int tableCount1 = getTableCount();
- int tableCount2 = other.getTableCount();
- eb.append(tableCount1, tableCount2);
- } catch (Exception e) {
- // might occur when schemas are disconnected. Omit this check then.
- }
- }
- return eb.isEquals();
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- String name = getName();
- if (name == null) {
- return -1;
- }
- return name.hashCode();
- }
-
- @Override
- public final int compareTo(Schema that) {
- int diff = getQualifiedLabel().compareTo(that.getQualifiedLabel());
- if (diff == 0) {
- diff = toString().compareTo(that.toString());
- }
- return diff;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/schema/AbstractTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/schema/AbstractTable.java b/core/src/main/java/org/eobjects/metamodel/schema/AbstractTable.java
deleted file mode 100644
index 3728751..0000000
--- a/core/src/main/java/org/eobjects/metamodel/schema/AbstractTable.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.schema;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eobjects.metamodel.MetaModelHelper;
-import org.eobjects.metamodel.util.Action;
-import org.eobjects.metamodel.util.CollectionUtils;
-import org.eobjects.metamodel.util.HasNameMapper;
-import org.eobjects.metamodel.util.Predicate;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract {@link Table} implementation. Includes most common/trivial methods.
- *
- * @author Kasper Sørensen
- */
-public abstract class AbstractTable implements Table {
-
- private static final long serialVersionUID = 1L;
-
- private static final Logger logger = LoggerFactory.getLogger(AbstractTable.class);
-
- @Override
- public final int getColumnCount() {
- return getColumns().length;
- }
-
- @Override
- public Column getColumn(int index) throws IndexOutOfBoundsException {
- Column[] columns = getColumns();
- return columns[index];
- }
-
- @Override
- public final Column getColumnByName(final String columnName) {
- if (columnName == null) {
- return null;
- }
-
- final List<Column> foundColumns = new ArrayList<Column>(1);
-
- // Search for column matches, case insensitive.
- for (Column column : getColumns()) {
- final String candidateName = column.getName();
- if (columnName.equalsIgnoreCase(candidateName)) {
- foundColumns.add(column);
- }
- }
-
- final int numColumns = foundColumns.size();
-
- if (logger.isDebugEnabled()) {
- logger.debug("Found {} column(s) matching '{}': {}", new Object[] { numColumns, columnName, foundColumns });
- }
-
- if (numColumns == 0) {
- return null;
- } else if (numColumns == 1) {
- // if there's only one, return it.
- return foundColumns.get(0);
- }
-
- // If more matches are found, search case sensitive
- for (Column column : foundColumns) {
- if (columnName.equals(column.getName())) {
- return column;
- }
- }
-
- // if none matches case sensitive, pick the first one.
- return foundColumns.get(0);
- }
-
- @Override
- public final int getRelationshipCount() {
- return getRelationships().length;
- }
-
- @Override
- public final Column[] getNumberColumns() {
- return CollectionUtils.filter(getColumns(), new Predicate<Column>() {
- @Override
- public Boolean eval(Column col) {
- ColumnType type = col.getType();
- return type != null && type.isNumber();
- }
- }).toArray(new Column[0]);
- }
-
- @Override
- public final Column[] getLiteralColumns() {
- return CollectionUtils.filter(getColumns(), new Predicate<Column>() {
- @Override
- public Boolean eval(Column col) {
- ColumnType type = col.getType();
- return type != null && type.isLiteral();
- }
- }).toArray(new Column[0]);
- }
-
- @Override
- public final Column[] getTimeBasedColumns() {
- return CollectionUtils.filter(getColumns(), new Predicate<Column>() {
- @Override
- public Boolean eval(Column col) {
- ColumnType type = col.getType();
- return type != null && type.isTimeBased();
- }
- }).toArray(new Column[0]);
- }
-
- @Override
- public final Column[] getBooleanColumns() {
- return CollectionUtils.filter(getColumns(), new Predicate<Column>() {
- @Override
- public Boolean eval(Column col) {
- ColumnType type = col.getType();
- return type != null && type.isBoolean();
- }
- }).toArray(new Column[0]);
- }
-
- @Override
- public final Column[] getIndexedColumns() {
- return CollectionUtils.filter(getColumns(), new Predicate<Column>() {
- @Override
- public Boolean eval(Column col) {
- return col.isIndexed();
- }
- }).toArray(new Column[0]);
- }
-
- @Override
- public final Relationship[] getForeignKeyRelationships() {
- return CollectionUtils.filter(getRelationships(), new Predicate<Relationship>() {
- @Override
- public Boolean eval(Relationship arg) {
- return AbstractTable.this.equals(arg.getForeignTable());
- }
- }).toArray(new Relationship[0]);
- }
-
- @Override
- public final Relationship[] getPrimaryKeyRelationships() {
- return CollectionUtils.filter(getRelationships(), new Predicate<Relationship>() {
- @Override
- public Boolean eval(Relationship arg) {
- return AbstractTable.this.equals(arg.getPrimaryTable());
- }
- }).toArray(new Relationship[0]);
- }
-
- @Override
- public final Column[] getForeignKeys() {
- final Set<Column> columns = new HashSet<Column>();
- final Relationship[] relationships = getForeignKeyRelationships();
- CollectionUtils.forEach(relationships, new Action<Relationship>() {
- @Override
- public void run(Relationship arg) {
- Column[] foreignColumns = arg.getForeignColumns();
- for (Column column : foreignColumns) {
- columns.add(column);
- }
- }
- });
- return columns.toArray(new Column[columns.size()]);
- }
-
- @Override
- public final Column[] getPrimaryKeys() {
- final List<Column> primaryKeyColumns = new ArrayList<Column>();
- final Column[] columnsInTable = getColumns();
- for (Column column : columnsInTable) {
- if (column.isPrimaryKey()) {
- primaryKeyColumns.add(column);
- }
- }
- return primaryKeyColumns.toArray(new Column[primaryKeyColumns.size()]);
- }
-
- @Override
- public final String[] getColumnNames() {
- Column[] columns = getColumns();
- return CollectionUtils.map(columns, new HasNameMapper()).toArray(new String[columns.length]);
- }
-
- @Override
- public final Column[] getColumnsOfType(ColumnType columnType) {
- Column[] columns = getColumns();
- return MetaModelHelper.getColumnsByType(columns, columnType);
- }
-
- @Override
- public final Column[] getColumnsOfSuperType(final SuperColumnType superColumnType) {
- Column[] columns = getColumns();
- return MetaModelHelper.getColumnsBySuperType(columns, superColumnType);
- }
-
- @Override
- public final Relationship[] getRelationships(final Table otherTable) {
- Relationship[] relationships = getRelationships();
-
- return CollectionUtils.filter(relationships, new Predicate<Relationship>() {
- @Override
- public Boolean eval(Relationship relation) {
- if (relation.getForeignTable() == otherTable && relation.getPrimaryTable() == AbstractTable.this) {
- return true;
- } else if (relation.getForeignTable() == AbstractTable.this && relation.getPrimaryTable() == otherTable) {
- return true;
- }
- return false;
- }
- }).toArray(new Relationship[0]);
- }
-
- @Override
- public final String getQuotedName() {
- String quote = getQuote();
- if (quote == null) {
- return getName();
- }
- return quote + getName() + quote;
- }
-
- @Override
- public final String getQualifiedLabel() {
- StringBuilder sb = new StringBuilder();
- Schema schema = getSchema();
- if (schema != null && schema.getName() != null) {
- sb.append(schema.getQualifiedLabel());
- sb.append('.');
- }
- sb.append(getName());
- return sb.toString();
- }
-
- @Override
- public final String toString() {
- return "Table[name=" + getName() + ",type=" + getType() + ",remarks=" + getRemarks() + "]";
- }
-
- @Override
- public int hashCode() {
- return getName().hashCode();
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj == this) {
- return true;
- }
- if (obj instanceof Table) {
- final Table other = (Table) obj;
- if (!getQualifiedLabel().equals(other.getQualifiedLabel())) {
- return false;
- }
- if (getType() != other.getType()) {
- return false;
- }
- final Schema sch1 = getSchema();
- final Schema sch2 = other.getSchema();
- if (sch1 != null) {
- if (!sch1.equals(sch2)) {
- return false;
- }
- } else {
- if (sch2 != null) {
- return false;
- }
- }
-
- try {
- final String[] columnNames1 = getColumnNames();
- final String[] columnNames2 = other.getColumnNames();
-
- if (columnNames1 != null && columnNames1.length != 0) {
- if (columnNames2 != null && columnNames2.length != 0) {
- if (!Arrays.equals(columnNames1, columnNames2)) {
- return false;
- }
- }
- }
- } catch (Exception e) {
- // going "down stream" may throw exceptions, e.g. due to
- // de-serialization issues. We will be tolerant to such
- // exceptions
- logger.debug("Caught (and ignoring) exception while comparing column names of tables", e);
- }
-
- return true;
- }
- return false;
- }
-
- @Override
- public final int compareTo(Table that) {
- int diff = getQualifiedLabel().compareTo(that.getQualifiedLabel());
- if (diff == 0) {
- diff = toString().compareTo(that.toString());
- }
- return diff;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/schema/Column.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/schema/Column.java b/core/src/main/java/org/eobjects/metamodel/schema/Column.java
deleted file mode 100644
index 1208368..0000000
--- a/core/src/main/java/org/eobjects/metamodel/schema/Column.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.eobjects.metamodel.schema;
-
-import java.io.Serializable;
-
-/**
- * Represents a column and it's metadata description. Columns reside within a
- * Table and can be used as keys for relationships between tables.
- *
- * @see Table
- *
- * @author Kasper Sørensen
- */
-public interface Column extends Comparable<Column>, Serializable, NamedStructure {
-
- /**
- * Gets the name of this Column
- *
- * @return the name of this Column
- */
- @Override
- public String getName();
-
- /**
- * Returns the column number or index. Note: This column number is 0-based
- * whereas the JDBC is 1-based.
- *
- * @return the number of this column.
- */
- public int getColumnNumber();
-
- /**
- * Gets the type of the column
- *
- * @return this column's type.
- */
- public ColumnType getType();
-
- /**
- * Gets the table for which this column belong
- *
- * @return this column's table.
- */
- public Table getTable();
-
- /**
- * Determines whether or not this column accepts null values.
- *
- * @return true if this column accepts null values, false if not and null if
- * not known.
- */
- public Boolean isNullable();
-
- /**
- * Gets any remarks/comments to this column.
- *
- * @return any remarks/comments to this column.
- */
- public String getRemarks();
-
- /**
- * Gets the data type size of this column.
- *
- * @return the data type size of this column or null if the size is not
- * determined or known.
- */
- public Integer getColumnSize();
-
- /**
- * Gets the native type of this column. A native type is the name of the
- * data type as defined in the datastore.
- *
- * @return the name of the native type.
- */
- public String getNativeType();
-
- /**
- * Determines if this column is indexed.
- *
- * @return true if this column is indexed or false if not (or not known)
- */
- public boolean isIndexed();
-
- /**
- * Determines if this column is (one of) the primary key(s) of its table.
- *
- * @return true if this column is a primary key, or false if not (or if this
- * is not determinable).
- */
- public boolean isPrimaryKey();
-}
\ No newline at end of file