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/22 10:10:49 UTC
[36/64] [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/data/DataSetHeader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/DataSetHeader.java b/core/src/main/java/org/eobjects/metamodel/data/DataSetHeader.java
deleted file mode 100644
index 186c7b9..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/DataSetHeader.java
+++ /dev/null
@@ -1,41 +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.data;
-
-import java.io.Serializable;
-
-import org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.schema.Column;
-
-/**
- * Represents the header of a {@link DataSet}, which define the
- * columns/SelectItems of it.
- */
-public interface DataSetHeader extends Serializable {
-
- public SelectItem[] getSelectItems();
-
- public int size();
-
- public int indexOf(SelectItem item);
-
- public int indexOf(Column column);
-
- public SelectItem getSelectItem(int i);
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/DataSetIterator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/DataSetIterator.java b/core/src/main/java/org/eobjects/metamodel/data/DataSetIterator.java
deleted file mode 100644
index 82481c5..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/DataSetIterator.java
+++ /dev/null
@@ -1,69 +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.data;
-
-import java.util.Iterator;
-
-/**
- * Iterator implementation that iterates through a DataSet.
- *
- * @author Kasper Sørensen
- */
-public final class DataSetIterator implements Iterator<Row> {
-
- private final DataSet _dataSet;
- private volatile short _iterationState;
- private volatile Row _row;
-
- public DataSetIterator(DataSet dataSet) {
- _dataSet = dataSet;
- // 0 = uninitialized, 1=row not read yet, 2=row read, 3=finished
- _iterationState = 0;
- }
-
- @Override
- public boolean hasNext() {
- if (_iterationState == 0 || _iterationState == 2) {
- if (_dataSet.next()) {
- _iterationState = 1;
- _row = _dataSet.getRow();
- } else {
- _iterationState = 3;
- _row = null;
- _dataSet.close();
- }
- }
- return _iterationState == 1;
- }
-
- @Override
- public Row next() {
- if (_iterationState == 1) {
- _iterationState = 2;
- }
- return _row;
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException(
- "DataSet is read-only, remove() is not supported.");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/DataSetTableModel.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/DataSetTableModel.java b/core/src/main/java/org/eobjects/metamodel/data/DataSetTableModel.java
deleted file mode 100644
index 53fb2be..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/DataSetTableModel.java
+++ /dev/null
@@ -1,112 +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.data;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.swing.table.AbstractTableModel;
-import javax.swing.table.TableModel;
-
-import org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.util.EqualsBuilder;
-
-/**
- * {@link TableModel} implementation which wraps a {@link DataSet} and presents its data.
- *
- * @author Kasper Sørensen
- *
- * @since 3.0
- */
-public class DataSetTableModel extends AbstractTableModel {
-
- private static final long serialVersionUID = 267644807447629777L;
- private boolean _materialized;
- private final List<Row> _materializedRows = new ArrayList<Row>();
- private final DataSet _dataSet;
- private final SelectItem[] _selectItems;
-
- public DataSetTableModel(DataSet dataSet) {
- _dataSet = dataSet;
- _selectItems = dataSet.getSelectItems();
- _materialized = false;
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(_selectItems) + _materializedRows.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj == this) {
- return true;
- }
- if (getClass() == obj.getClass()) {
- DataSetTableModel that = (DataSetTableModel) obj;
- EqualsBuilder eb = new EqualsBuilder();
- eb.append(_materializedRows, that._materializedRows);
- eb.append(_selectItems, that._selectItems);
- return eb.isEquals();
- }
- return false;
- }
-
- public int getColumnCount() {
- return _selectItems.length;
- }
-
- public int getRowCount() {
- materialize();
- return _materializedRows.size();
- }
-
- private void materialize() {
- if (!_materialized) {
- try {
- while (_dataSet.next()) {
- _materializedRows.add(_dataSet.getRow());
- }
- } finally {
- _dataSet.close();
- }
- _materialized = true;
- }
- }
-
- public Object getValueAt(int rowIndex, int columnIndex) {
- materialize();
- return _materializedRows.get(rowIndex).getValue(columnIndex);
- }
-
- @Override
- public String getColumnName(int column) {
- return _selectItems[column].getSuperQueryAlias(false);
- }
-
- @Override
- public void setValueAt(Object value, int rowIndex, int columnIndex) {
- throw new UnsupportedOperationException(
- "DataSetTableModels are immutable, so setValueAt() method is unsupported.");
- }
-}
\ 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/data/DefaultRow.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/DefaultRow.java b/core/src/main/java/org/eobjects/metamodel/data/DefaultRow.java
deleted file mode 100644
index 3fee3b8..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/DefaultRow.java
+++ /dev/null
@@ -1,205 +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.data;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eobjects.metamodel.query.SelectItem;
-
-/**
- * Default Row implementation. Holds values in memory.
- *
- * @author Kasper Sørensen
- */
-public final class DefaultRow extends AbstractRow implements Row {
-
- private static final long serialVersionUID = 1L;
-
- private final DataSetHeader _header;
- private final Object[] _values;
- private final Style[] _styles;
-
- /**
- * This field was replaced by the DataSetHeader field above.
- *
- * @deprecated no longer used, except for in deserialized objects
- */
- @Deprecated
- private List<SelectItem> _items;
-
- /**
- * Constructs a row.
- *
- * @param header
- * @param values
- * @param styles
- */
- public DefaultRow(DataSetHeader header, Object[] values, Style[] styles) {
- if (header == null) {
- throw new IllegalArgumentException("DataSet header cannot be null");
- }
- if (values == null) {
- throw new IllegalArgumentException("Values cannot be null");
- }
- if (header.size() != values.length) {
- throw new IllegalArgumentException("Header size and values length must be equal. " + header.size()
- + " select items present in header and encountered these values: " + Arrays.toString(values));
- }
- if (styles != null) {
- if (values.length != styles.length) {
- throw new IllegalArgumentException("Values length and styles length must be equal. " + values.length
- + " values present and encountered these styles: " + Arrays.toString(styles));
- }
- boolean entirelyNoStyle = true;
- for (int i = 0; i < styles.length; i++) {
- if (styles[i] == null) {
- throw new IllegalArgumentException("Elements in the style array cannot be null");
- }
- if (entirelyNoStyle && !Style.NO_STYLE.equals(styles[i])) {
- entirelyNoStyle = false;
- }
- }
-
- if (entirelyNoStyle) {
- // no need to reference any styles
- styles = null;
- }
- }
- _header = header;
- _values = values;
- _styles = styles;
- }
-
- /**
- * Constructs a row.
- *
- * @param header
- * @param values
- */
- public DefaultRow(DataSetHeader header, Object[] values) {
- this(header, values, null);
- }
-
- /**
- * Constructs a row from an array of SelectItems and an array of
- * corresponding values
- *
- * @param items
- * the array of SelectItems
- * @param values
- * the array of values
- *
- * @deprecated use {@link #DefaultRow(DataSetHeader, Object[])} or
- * {@link #DefaultRow(DataSetHeader, Object[], Style[])}
- * instead.
- */
- @Deprecated
- public DefaultRow(SelectItem[] items, Object[] values) {
- this(Arrays.asList(items), values, null);
- }
-
- /**
- * Constructs a row from an array of SelectItems and an array of
- * corresponding values
- *
- * @param items
- * the array of SelectItems
- * @param values
- * the array of values
- * @param styles
- * an optional array of styles
- * @deprecated use {@link #DefaultRow(DataSetHeader, Object[])} or
- * {@link #DefaultRow(DataSetHeader, Object[], Style[])}
- * instead.
- */
- @Deprecated
- public DefaultRow(SelectItem[] items, Object[] values, Style[] styles) {
- this(Arrays.asList(items), values, styles);
- }
-
- /**
- * Constructs a row from a list of SelectItems and an array of corresponding
- * values
- *
- * @param items
- * the list of SelectItems
- * @param values
- * the array of values
- * @deprecated use {@link #DefaultRow(DataSetHeader, Object[])} or
- * {@link #DefaultRow(DataSetHeader, Object[], Style[])}
- * instead.
- */
- @Deprecated
- public DefaultRow(List<SelectItem> items, Object[] values) {
- this(items, values, null);
- }
-
- /**
- * Constructs a row from a list of SelectItems and an array of corresponding
- * values
- *
- * @param items
- * the list of SelectItems
- * @param values
- * the array of values
- * @param styles
- * an optional array of styles
- * @deprecated use {@link #DefaultRow(DataSetHeader, Object[])} or
- * {@link #DefaultRow(DataSetHeader, Object[], Style[])}
- * instead.
- */
- @Deprecated
- public DefaultRow(List<SelectItem> items, Object[] values, Style[] styles) {
- this(new SimpleDataSetHeader(items), values, styles);
- }
-
- @Override
- public Object getValue(int index) throws ArrayIndexOutOfBoundsException {
- return _values[index];
- }
-
- @Override
- public Object[] getValues() {
- return _values;
- }
-
- @Override
- public Style getStyle(int index) throws IndexOutOfBoundsException {
- if (_styles == null) {
- return Style.NO_STYLE;
- }
- return _styles[index];
- }
-
- @Override
- public Style[] getStyles() {
- return _styles;
- }
-
- @Override
- protected DataSetHeader getHeader() {
- if (_header == null && _items != null) {
- // this only happens for deserialized objects which where serialized
- // prior to the introduction of DataSetHeader.
- return new SimpleDataSetHeader(_items);
- }
- return _header;
- }
-}
\ 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/data/EmptyDataSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/EmptyDataSet.java b/core/src/main/java/org/eobjects/metamodel/data/EmptyDataSet.java
deleted file mode 100644
index 12d3caf..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/EmptyDataSet.java
+++ /dev/null
@@ -1,59 +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.data;
-
-import java.util.List;
-
-import org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.schema.Column;
-
-/**
- * An empty data set.
- *
- * @author Kasper Sørensen
- */
-public final class EmptyDataSet extends AbstractDataSet {
-
- public EmptyDataSet(DataSetHeader header) {
- super(header);
- }
-
- public EmptyDataSet(SelectItem[] selectItems) {
- super(new SimpleDataSetHeader(selectItems));
- }
-
- public EmptyDataSet(Column[] columns) {
- super(new SimpleDataSetHeader(columns));
- }
-
- public EmptyDataSet(List<SelectItem> selectItems) {
- this(new SimpleDataSetHeader(selectItems));
- }
-
- @Override
- public boolean next() {
- return false;
- }
-
- @Override
- public Row getRow() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/FilteredDataSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/FilteredDataSet.java b/core/src/main/java/org/eobjects/metamodel/data/FilteredDataSet.java
deleted file mode 100644
index ca406ed..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/FilteredDataSet.java
+++ /dev/null
@@ -1,68 +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.data;
-
-
-/**
- * Wraps another DataSet and transparently applies a set of filters to it.
- *
- * @author Kasper Sørensen
- */
-public final class FilteredDataSet extends AbstractDataSet {
-
- private final DataSet _dataSet;
- private final IRowFilter[] _filters;
- private Row _row;
-
- public FilteredDataSet(DataSet dataSet, IRowFilter... filters) {
- super(dataSet);
- _dataSet = dataSet;
- _filters = filters;
- }
-
- @Override
- public void close() {
- super.close();
- _dataSet.close();
- }
-
- @Override
- public boolean next() {
- boolean next = false;
- while (_dataSet.next()) {
- Row row = _dataSet.getRow();
- for (IRowFilter filter : _filters) {
- next = filter.accept(row);
- if (!next) {
- break;
- }
- }
- if (next) {
- _row = row;
- break;
- }
- }
- return next;
- }
-
- @Override
- public Row getRow() {
- return _row;
- }
-}
\ 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/data/FirstRowDataSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/FirstRowDataSet.java b/core/src/main/java/org/eobjects/metamodel/data/FirstRowDataSet.java
deleted file mode 100644
index 6662eb5..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/FirstRowDataSet.java
+++ /dev/null
@@ -1,73 +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.data;
-
-/**
- * Wraps another DataSet and enforces a first row offset.
- */
-public final class FirstRowDataSet extends AbstractDataSet {
-
- private final DataSet _dataSet;
- private volatile int _rowsLeftToSkip;
-
- /**
- * Constructs a {@link FirstRowDataSet}.
- *
- * @param dataSet
- * the dataset to wrap
- * @param firstRow
- * the first row number (1-based).
- */
- public FirstRowDataSet(DataSet dataSet, int firstRow) {
- super(dataSet);
- _dataSet = dataSet;
- if (firstRow < 1) {
- throw new IllegalArgumentException("First row cannot be negative or zero");
- }
- _rowsLeftToSkip = firstRow - 1;
- }
-
- @Override
- public void close() {
- _dataSet.close();
- }
-
- @Override
- public Row getRow() {
- return _dataSet.getRow();
- }
-
- @Override
- public boolean next() {
- boolean next = true;
- if (_rowsLeftToSkip > 0) {
- while (_rowsLeftToSkip > 0) {
- next = _dataSet.next();
- if (next) {
- _rowsLeftToSkip--;
- } else {
- // no more rows at all - exit loop
- _rowsLeftToSkip = 0;
- return false;
- }
- }
- }
- return _dataSet.next();
- }
-}
\ 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/data/IRowFilter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/IRowFilter.java b/core/src/main/java/org/eobjects/metamodel/data/IRowFilter.java
deleted file mode 100644
index ac46eea..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/IRowFilter.java
+++ /dev/null
@@ -1,37 +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.data;
-
-/**
- * A filter that is executed client-side because filter criteria are either more
- * dynamic than the Query-functionality offer or because it cannot be expressed
- * using datastore-neutral queries.
- *
- * @see FilteredDataSet
- */
-public interface IRowFilter {
-
- /**
- * Filters a row
- *
- * @param row
- * @return true if the row is valid according to the filter
- */
- public boolean accept(Row row);
-}
\ 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/data/InMemoryDataSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/InMemoryDataSet.java b/core/src/main/java/org/eobjects/metamodel/data/InMemoryDataSet.java
deleted file mode 100644
index 7e21412..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/InMemoryDataSet.java
+++ /dev/null
@@ -1,95 +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.data;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eobjects.metamodel.query.SelectItem;
-
-/**
- * DataSet implementation based on in-memory data.
- *
- * @author Kasper Sørensen
- */
-public final class InMemoryDataSet extends AbstractDataSet {
-
- private final List<Row> _rows;
- private int _rowNumber = -1;
-
- public InMemoryDataSet(Row... rows) {
- this(Arrays.asList(rows));
- }
-
- public InMemoryDataSet(List<Row> rows) {
- this(getHeader(rows), rows);
- }
-
- public InMemoryDataSet(DataSetHeader header, Row... rows) {
- super(header);
- _rows = Arrays.asList(rows);
- }
-
- public InMemoryDataSet(DataSetHeader header, List<Row> rows) {
- super(header);
- _rows = rows;
- }
-
- private static DataSetHeader getHeader(List<Row> rows) {
- if (rows.isEmpty()) {
- throw new IllegalArgumentException("Cannot hold an empty list of rows, use " + EmptyDataSet.class
- + " for this");
- }
-
- final SelectItem[] selectItems = rows.get(0).getSelectItems();
-
- if (rows.size() > 3) {
- // not that many records - caching will not have body to scale
- return new SimpleDataSetHeader(selectItems);
- }
- return new CachingDataSetHeader(selectItems);
- }
-
- @Override
- public boolean next() {
- _rowNumber++;
- if (_rowNumber < _rows.size()) {
- return true;
- }
- return false;
- }
-
- @Override
- public Row getRow() {
- if (_rowNumber < 0 || _rowNumber >= _rows.size()) {
- return null;
- }
- Row row = _rows.get(_rowNumber);
- assert row.size() == getHeader().size();
- return row;
- }
-
- public List<Row> getRows() {
- return _rows;
- }
-
- public int size() {
- return _rows.size();
- }
-}
\ 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/data/MaxRowsDataSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/MaxRowsDataSet.java b/core/src/main/java/org/eobjects/metamodel/data/MaxRowsDataSet.java
deleted file mode 100644
index adecaed..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/MaxRowsDataSet.java
+++ /dev/null
@@ -1,56 +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.data;
-
-/**
- * Wraps another DataSet and enforces a maximum number of rows constraint
- */
-public final class MaxRowsDataSet extends AbstractDataSet {
-
- private final DataSet _dataSet;
- private volatile int _rowsLeft;
-
- public MaxRowsDataSet(DataSet dataSet, int maxRows) {
- super(dataSet);
- _dataSet = dataSet;
- _rowsLeft = maxRows;
- }
-
- @Override
- public void close() {
- _dataSet.close();
- }
-
- @Override
- public Row getRow() {
- return _dataSet.getRow();
- }
-
- @Override
- public boolean next() {
- if (_rowsLeft > 0) {
- boolean next = _dataSet.next();
- if (next) {
- _rowsLeft--;
- }
- return next;
- }
- 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/data/Row.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/Row.java b/core/src/main/java/org/eobjects/metamodel/data/Row.java
deleted file mode 100644
index 47e95c0..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/Row.java
+++ /dev/null
@@ -1,135 +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.data;
-
-import java.io.Serializable;
-
-import org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.schema.Column;
-
-/**
- * Represents a row of data in a DataSet. Each row is a mapping between
- * SelectItems and values for each SelectItem.
- *
- * @see DataSet
- * @see SelectItem
- */
-public interface Row extends Serializable {
-
- /**
- * Gets the value of the provided SelectItem.
- *
- * @param item
- * @return the value that corresponds to the provided SelectItem. Can be
- * null if either the value <i>is</i> null or if no value exists
- * that matches the SelectItem.
- */
- public Object getValue(SelectItem item);
-
- /**
- * Shorthand method for getting the value of a SelectItem based on the
- * provided column. Invoking this method is equivalent to invoking
- * getValue(new SelectItem(column)).
- *
- * @param column
- * @return the value of the specified column
- */
- public Object getValue(Column column);
-
- /**
- * Gets the value of the row at a given index
- *
- * @param index
- * @return the value at the specified index
- * @throws IndexOutOfBoundsException
- * if the provided index is out of range
- */
- public Object getValue(int index) throws IndexOutOfBoundsException;
-
- public Style getStyle(SelectItem item);
-
- public Style getStyle(Column column);
-
- public Style getStyle(int index) throws IndexOutOfBoundsException;
-
- public Style[] getStyles();
-
- /**
- * Gets the index of a SelectItem in the row.
- *
- * @param item
- * the item to get the index of
- * @return the index of a SelectItem in the row. If the SelectItem is not
- * found -1 will be returned.
- */
- public int indexOf(SelectItem item);
-
- /**
- * Gets the index of a Column in the row.
- *
- * @param column
- * the column to get the index of
- * @return the index of a column in the row. If the Column is not found, -1
- * will be returned.
- */
- public int indexOf(Column column);
-
- /**
- * Gets the select items that represent the columns of the {@link DataSet}
- * that this row pertains to.
- *
- * @return
- */
- public SelectItem[] getSelectItems();
-
- /**
- * Gets the values of the row, represented as an object array
- *
- * @return an array of objects, containing the values of this row.
- */
- public Object[] getValues();
-
- /**
- * Creates a row similar to this one but only with a subset of the values.
- *
- * @param selectItems
- * the select items (~ columns) to sub-select the row with
- * @return a new Row object containing only the select items requested
- * @deprecated use {@link #getSubSelection(DataSetHeader)} instead.
- */
- @Deprecated
- public Row getSubSelection(SelectItem[] selectItems);
-
- /**
- * Creates a row similar to this one but only with a subset of the values.
- *
- * @param header
- * the new header to sub-select the row with
- * @return a new Row object containing only the select items in the newly
- * requested header
- */
- public Row getSubSelection(DataSetHeader header);
-
- /**
- * Gets the amount of values/columns/select items represented in this row.
- *
- * @return
- */
- public int size();
-}
\ 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/data/RowBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/RowBuilder.java b/core/src/main/java/org/eobjects/metamodel/data/RowBuilder.java
deleted file mode 100644
index b7bce06..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/RowBuilder.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.data;
-
-import org.eobjects.metamodel.insert.RowInsertionBuilder;
-import org.eobjects.metamodel.schema.Column;
-import org.eobjects.metamodel.schema.Table;
-import org.eobjects.metamodel.update.RowUpdationBuilder;
-
-/**
- * Abstract interface for objects that build rows, either for eg. insert or
- * update purposes.
- *
- * @see RowInsertionBuilder
- * @see RowUpdationBuilder
- *
- * @param <RB>
- * the RowBuilder subtype, used for cascading return values
- */
-public interface RowBuilder<RB extends RowBuilder<?>> {
-
- /**
- * Gets the table that this row builder pertains to.
- *
- * @return the table that this row builder pertains to.
- */
- public Table getTable();
-
- /**
- * Sets the value of a column, by column index
- *
- * @param columnIndex
- * @param value
- * @return
- */
- public RB value(int columnIndex, Object value);
-
- /**
- * Sets the value of a column, by column index
- *
- * @param columnIndex
- * @param value
- * @param style
- * @return
- */
- public RB value(int columnIndex, Object value, Style style);
-
- /**
- * Sets the value of a column
- *
- * @param column
- * @param value
- * @return
- */
- public RB value(Column column, Object value);
-
- /**
- * Sets the value of a column
- *
- * @param column
- * @param value
- * @param style
- * @return
- */
- public RB value(Column column, Object value, Style style);
-
- /**
- * Sets the value of a column, by column name
- *
- * @param columnName
- * @param value
- * @return
- */
- public RB value(String columnName, Object value);
-
- /**
- * Sets the value and the style of this value of a column, by column name
- *
- * @param columnName
- * @param value
- * @param style
- * @return
- */
- public RB value(String columnName, Object value, Style style);
-
- /**
- * Gets the built record represented as a {@link Row} object.
- *
- * @return a {@link Row} object as it will appear if committed and queried.
- */
- public Row toRow();
-
- /**
- * Determines if a column's value has been explicitly specified or not. This
- * can be used to tell explicit NULL values apart from just unspecified
- * values in a statement.
- *
- * @param column
- * the column to check
- * @return true if the column's value has been set, or false if not
- */
- public boolean isSet(Column column);
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/RowPublisher.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/RowPublisher.java b/core/src/main/java/org/eobjects/metamodel/data/RowPublisher.java
deleted file mode 100644
index fe7678b..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/RowPublisher.java
+++ /dev/null
@@ -1,70 +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.data;
-
-/**
- * An object on which a push-style data reader can publish records to a
- * {@link RowPublisherDataSet}. The {@link RowPublisher} acts as a buffer
- * between the publishing and consuming part of a dataset scenario. It will
- * manage a queue of rows and will block calls if the queue is not being
- * read/emptied as fast as it is being filled.
- *
- * @author Kasper Sørensen
- */
-public interface RowPublisher {
-
- /**
- * Publishes a row
- *
- * @param row
- * the {@link Row} to publish.
- * @return a boolean indicating whether or not the consumer is still
- * interested in more rows.
- */
- public boolean publish(Row row);
-
- /**
- * Publishes a row, represented by an array of values.
- *
- * @param values
- * the objects to convert to a row.
- * @return a boolean indicating whether or not the consumer is still
- * interested in more rows.
- */
- public boolean publish(Object[] values);
-
- /**
- * Publishes a row, represented by an array of values and an array of
- * styles.
- *
- * @param values
- * the objects to convert to a row.
- * @param styles
- * the styles that correspond to the values.
- * @return a boolean indicating whether or not the consumer is still
- * interested in more rows.
- */
- public boolean publish(Object[] values, Style[] styles);
-
- /**
- * Invoked to indicate to the consumer that no more rows will be published.
- */
- public void finished();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/RowPublisherDataSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/RowPublisherDataSet.java b/core/src/main/java/org/eobjects/metamodel/data/RowPublisherDataSet.java
deleted file mode 100644
index addbeae..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/RowPublisherDataSet.java
+++ /dev/null
@@ -1,111 +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.data;
-
-import org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.util.Action;
-import org.eobjects.metamodel.util.SharedExecutorService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract {@link DataSet} implementation for use in scenarios where a
- * pull-oriented style of reading data is not supported. This implementation
- * instead allows a publshing action to publish rows to the dataset in a
- * blocking manner, and thereby to adapt without having to load all rows into
- * memory.
- *
- * @author Kasper Sørensen
- */
-public final class RowPublisherDataSet extends AbstractDataSet {
-
- private static final Logger logger = LoggerFactory
- .getLogger(RowPublisherDataSet.class);
-
- private final int _maxRows;
- private final Action<RowPublisher> _publishAction;
- private RowPublisherImpl _rowPublisher;
- private boolean _closed;
-
- public RowPublisherDataSet(SelectItem[] selectItems, int maxRows,
- Action<RowPublisher> publishAction) {
- super(selectItems);
- _maxRows = maxRows;
- _publishAction = publishAction;
- _closed = false;
- }
-
- public int getMaxRows() {
- return _maxRows;
- }
-
- @Override
- public void close() {
- super.close();
- _closed = true;
- _rowPublisher.finished();
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- if (!_closed) {
- logger.warn(
- "finalize() invoked, but DataSet is not closed. Invoking close() on {}",
- this);
- close();
- }
- }
-
- @Override
- public boolean next() {
- if (_rowPublisher == null) {
- // first time, create the publisher
- _rowPublisher = new RowPublisherImpl(this);
- logger.info("Starting separate thread for publishing action: {}",
- _publishAction);
- Runnable runnable = new Runnable() {
- public void run() {
- boolean successful = false;
- try {
- _publishAction.run(_rowPublisher);
- logger.debug("Publshing action finished!");
- successful = true;
- } catch (Exception e) {
- _rowPublisher.failed(e);
- }
- if (successful) {
- _rowPublisher.finished();
- }
- };
- };
- SharedExecutorService.get().submit(runnable);
- }
- return _rowPublisher.next();
- }
-
- @Override
- public Row getRow() {
- if (_rowPublisher == null) {
- return null;
- }
- return _rowPublisher.getRow();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/RowPublisherImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/RowPublisherImpl.java b/core/src/main/java/org/eobjects/metamodel/data/RowPublisherImpl.java
deleted file mode 100644
index 6fe2a0d..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/RowPublisherImpl.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.data;
-
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.eobjects.metamodel.MetaModelException;
-
-/**
- * Row publisher implementation used by {@link RowPublisherDataSet}.
- *
- * @author Kasper Sørensen
- */
-class RowPublisherImpl implements RowPublisher {
-
- public static final int BUFFER_SIZE = 20;
-
- private final RowPublisherDataSet _dataSet;
- private final BlockingQueue<Row> _queue;
- private final AtomicBoolean _finished;
- private final AtomicInteger _rowCount;
- private volatile Row _currentRow;
- private volatile Exception _error;
-
- public RowPublisherImpl(RowPublisherDataSet dataSet) {
- _dataSet = dataSet;
- _queue = new ArrayBlockingQueue<Row>(BUFFER_SIZE);
- _finished = new AtomicBoolean(false);
- _rowCount = new AtomicInteger();
- }
-
- @Override
- public boolean publish(Row row) {
- if (_finished.get()) {
- return false;
- }
- while (!offer(row)) {
- if (_finished.get()) {
- return false;
- }
- // wait one more cycle
- }
- int rowCount = _rowCount.incrementAndGet();
- if (_dataSet.getMaxRows() > 0 && rowCount >= _dataSet.getMaxRows()) {
- finished();
- return false;
- }
- return true;
- }
-
- private boolean offer(Row row) {
- try {
- return _queue.offer(row, 1000, TimeUnit.MICROSECONDS);
- } catch (InterruptedException e) {
- // do nothing
- return false;
- }
- }
-
- @Override
- public boolean publish(Object[] values) {
- Row row = new DefaultRow(_dataSet.getHeader(), values);
- return publish(row);
- }
-
- @Override
- public boolean publish(Object[] values, Style[] styles) {
- Row row = new DefaultRow(_dataSet.getHeader(), values, styles);
- return publish(row);
- }
-
- @Override
- public void finished() {
- _finished.set(true);
- }
-
- public boolean next() {
- if (_queue.isEmpty() && _finished.get()) {
- return false;
- }
- try {
- _currentRow = _queue.poll(1000, TimeUnit.MILLISECONDS);
- } catch (InterruptedException e) {
- // do nothing
- }
- if (_currentRow != null) {
- return true;
- }
- if (_error != null) {
- if (_error instanceof RuntimeException) {
- throw (RuntimeException) _error;
- }
- throw new MetaModelException(_error);
- }
- // "busy" (1 second) wait
- return next();
- }
-
- public Row getRow() {
- return _currentRow;
- }
-
- public void failed(Exception error) {
- _error = error;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/SimpleDataSetHeader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/SimpleDataSetHeader.java b/core/src/main/java/org/eobjects/metamodel/data/SimpleDataSetHeader.java
deleted file mode 100644
index 1e7e461..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/SimpleDataSetHeader.java
+++ /dev/null
@@ -1,132 +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.data;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eobjects.metamodel.MetaModelHelper;
-import org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.schema.Column;
-
-/**
- * Simple implementation of {@link DataSetHeader} which does no magic to improve
- * performance.
- *
- * Note that except for datasets with very few records, the
- * {@link CachingDataSetHeader} is preferred.
- */
-public class SimpleDataSetHeader implements DataSetHeader {
-
- private static final long serialVersionUID = 1L;
-
- private final List<SelectItem> _items;
-
- public SimpleDataSetHeader(List<SelectItem> items) {
- _items = items;
- }
-
- public SimpleDataSetHeader(SelectItem[] selectItems) {
- this(Arrays.asList(selectItems));
- }
-
- public SimpleDataSetHeader(Column[] columns) {
- this(MetaModelHelper.createSelectItems(columns));
- }
-
- @Override
- public final SelectItem[] getSelectItems() {
- return _items.toArray(new SelectItem[_items.size()]);
- }
-
- @Override
- public final int size() {
- return _items.size();
- }
-
- @Override
- public SelectItem getSelectItem(int index) {
- return _items.get(index);
- }
-
- @Override
- public int indexOf(Column column) {
- if (column == null) {
- return -1;
- }
- return indexOf(new SelectItem(column));
- }
-
- @Override
- public int indexOf(SelectItem item) {
- if (item == null) {
- return -1;
- }
- int i = 0;
- for (SelectItem selectItem : _items) {
- if (item == selectItem) {
- return i;
- }
- i++;
- }
-
- i = 0;
- for (SelectItem selectItem : _items) {
- if (item.equalsIgnoreAlias(selectItem, true)) {
- return i;
- }
- i++;
- }
-
- i = 0;
- for (SelectItem selectItem : _items) {
- if (item.equalsIgnoreAlias(selectItem)) {
- return i;
- }
- i++;
- }
-
- return -1;
- }
-
- @Override
- public final int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((_items == null) ? 0 : _items.hashCode());
- return result;
- }
-
- @Override
- public final boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- SimpleDataSetHeader other = (SimpleDataSetHeader) obj;
- if (_items == null) {
- if (other._items != null)
- return false;
- } else if (!_items.equals(other._items))
- return false;
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/Style.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/Style.java b/core/src/main/java/org/eobjects/metamodel/data/Style.java
deleted file mode 100644
index d1c04a5..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/Style.java
+++ /dev/null
@@ -1,156 +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.data;
-
-import java.io.Serializable;
-
-/**
- * A {@link Style} represents the visual presentation ('styling') attributes of
- * a value in a {@link Row}. Styling can be used to highlight special values and
- * format the cells of eg. a spreadsheet.
- *
- * Most datastores don't support styling, but some do. Those who do not support
- * it will just omit it.
- *
- * Creation of {@link Style} objects is handled by the {@link StyleBuilder}
- * class.
- *
- * @author Kasper Sørensen
- */
-public interface Style extends Serializable {
-
- /**
- * A style object used for values without styling, "unstyled" values or
- * "neutrally styled" values.
- */
- public static final Style NO_STYLE = new StyleImpl();
-
- /**
- * Represents the text alignment of a value.
- *
- * @author Kasper Sørensen
- */
- public static enum TextAlignment {
- LEFT, RIGHT, CENTER, JUSTIFY
- }
-
- /**
- * Represents a color used for value highlighting.
- *
- * Creation of {@link Color} objects is handled by the static
- * {@link StyleBuilder}.createColor(...) methods.
- *
- * @author Kasper Sørensen
- */
- public static interface Color extends Serializable {
-
- public short getRed();
-
- public short getGreen();
-
- public short getBlue();
- }
-
- /**
- * Represents a unit of sizing elements (eg. fonts) in a {@link Style}.
- *
- * @author Kasper Sørensen
- */
- public static enum SizeUnit {
- /**
- * Point unit
- */
- PT,
-
- /**
- * Pixel unit
- */
- PX,
-
- /**
- * Percent unit
- */
- PERCENT
- }
-
- /**
- * Determines whether or not the value is written in bold text.
- *
- * @return true if text is bold
- */
- public boolean isBold();
-
- /**
- * Determines whether or not the value is written in italic text.
- *
- * @return true if text is italic
- */
- public boolean isItalic();
-
- /**
- * Determines whether or not the value is written with an underline
- *
- * @return true if text is underlined
- */
- public boolean isUnderline();
-
- /**
- * Gets the font size, or null if font size is unspecified.
- *
- * @see SizeUnit
- *
- * @return an Integer, or null
- */
- public Integer getFontSize();
-
- /**
- * Gets the unit of the font size.
- *
- * @return an enum representing the font size unit used.
- */
- public SizeUnit getFontSizeUnit();
-
- /**
- * Gets the text alignment, or null if text alignment is unspecified.
- *
- * @return a TextAlignment value, or null
- */
- public TextAlignment getAlignment();
-
- /**
- * Gets the foreground (text) color, or null if the color is unspecified.
- *
- * @return a Color object representing the foreground color
- */
- public Color getForegroundColor();
-
- /**
- * Gets the background color, or null if the color is unspecified.
- *
- * @return a Color object representing the background color
- */
- public Color getBackgroundColor();
-
- /**
- * Creates a Cascading Style Sheets (CSS) representation of this style.
- *
- * @return a CSS string
- */
- public String toCSS();
-}
\ 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/data/StyleBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/StyleBuilder.java b/core/src/main/java/org/eobjects/metamodel/data/StyleBuilder.java
deleted file mode 100644
index 65400f7..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/StyleBuilder.java
+++ /dev/null
@@ -1,355 +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.data;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.eobjects.metamodel.data.Style.Color;
-import org.eobjects.metamodel.data.Style.SizeUnit;
-import org.eobjects.metamodel.data.Style.TextAlignment;
-import org.eobjects.metamodel.util.EqualsBuilder;
-
-/**
- * Builder class for {@link Style} and related objects, like {@link Color}.
- *
- * @author Kasper Sørensen
- */
-public final class StyleBuilder {
-
- private static final Map<String, Color> _colorCache = new WeakHashMap<String, Color>();
-
- private boolean _bold;
- private boolean _italic;
- private boolean _underline;
- private Integer _fontSize;
- private TextAlignment _alignment;
- private Color _backgroundColor;
- private Color _foregroundColor;
- private SizeUnit _fontSizeUnit;
-
- private final Color _defaultForegroundColor;
- private final Color _defaultBackgroundColor;
-
- /**
- * Constructs a new {@link StyleBuilder} with the default foreground and
- * background colors.
- */
- public StyleBuilder() {
- this(createColor((short) 0, (short) 0, (short) 0), createColor(
- (short) 255, (short) 255, (short) 255));
- }
-
- /**
- * Constructs a new {@link StyleBuilder} with a specified default foreground
- * and background colors. These colors will be disregarded, if posted to the
- * foreground and background methods.
- *
- * @param defaultForegroundColor
- * @param defaultBackgroundColor
- */
- public StyleBuilder(Color defaultForegroundColor,
- Color defaultBackgroundColor) {
- _defaultForegroundColor = defaultForegroundColor;
- _defaultBackgroundColor = defaultBackgroundColor;
- }
-
- /**
- * Resets the state of the built style, which will conceptually match it
- * with {@link Style#NO_STYLE}.
- */
- public void reset() {
- _bold = false;
- _italic = false;
- _underline = false;
- _fontSize = null;
- _alignment = null;
- _backgroundColor = null;
- _foregroundColor = null;
- _fontSizeUnit = null;
- }
-
- /**
- * Creates a {@link Style} object based on the build characteristics.
- *
- * @return a {@link Style} object based on the build characteristics.
- */
- public Style create() {
- StyleImpl style = new StyleImpl(_bold, _italic, _underline, _fontSize,
- _fontSizeUnit, _alignment, _backgroundColor, _foregroundColor);
- if (Style.NO_STYLE.equals(style)) {
- return Style.NO_STYLE;
- }
- return style;
- }
-
- /**
- * Sets the font weight to bold
- *
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder bold() {
- _bold = true;
- return this;
- }
-
- /**
- * Sets the font style to italic
- *
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder italic() {
- _italic = true;
- return this;
- }
-
- /**
- * Sets the text decoration to underlined
- *
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder underline() {
- _underline = true;
- return this;
- }
-
- /**
- * Creates a Color based on a 6-letter RGB hex color code string, eg.
- * "000000" for black and "FFFFFF" for white.
- *
- * @param rgbColorCode
- * a 6-letter RGB hex color code string
- * @return a color representing this color code
- */
- public static Color createColor(String rgbColorCode) {
- assert rgbColorCode.length() == 6;
- String redParth = rgbColorCode.substring(0, 2);
- String greenParth = rgbColorCode.substring(2, 4);
- String blueParth = rgbColorCode.substring(4, 6);
- return createColor(Integer.parseInt(redParth, 16),
- Integer.parseInt(greenParth, 16),
- Integer.parseInt(blueParth, 16));
- }
-
- /**
- * Creates a color based on 3 RGB components, represented as ints
- *
- * @param r
- * @param g
- * @param b
- * @return a color representing the RGB code
- */
- public static Color createColor(int r, int g, int b) {
- return createColor(toRgbComponent(r), toRgbComponent(g),
- toRgbComponent(b));
- }
-
- /**
- * Creates a color based on 3 RGB components, represented as shorts
- *
- * @param r
- * @param g
- * @param b
- * @return a color representing the RGB code
- */
- public static Color createColor(short r, short g, short b) {
- String cacheId = r + "," + g + "," + b;
- Color color = _colorCache.get(cacheId);
- if (color == null) {
- color = new ColorImpl(r, g, b);
- _colorCache.put(cacheId, color);
- }
- return color;
- }
-
- private static short toRgbComponent(int r) {
- if (r < 0) {
- // if eg. a byte was passed as a RGB component
- r = (256 + r);
- }
- if (r > 255) {
- throw new IllegalArgumentException(
- "RGB component cannot be higher than 255");
- }
- return (short) r;
- }
-
- /**
- * Sets the foreground (text) color of the style
- *
- * @param rgbColorCode
- * a 6-letter hex RGB color code, such as FF0000 (red).
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder foreground(String rgbColorCode) {
- return foreground(createColor(rgbColorCode));
- }
-
- /**
- * Sets the foreground (text) color of the style
- *
- * @param rgb
- * a triplet array of shorts
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder foreground(short[] rgb) {
- assert rgb.length == 3;
- return foreground(createColor(rgb[0], rgb[1], rgb[2]));
- }
-
- /**
- * Sets the foreground (text) color of the style
- *
- * @param r
- * red amount (0-255)
- * @param g
- * green amount (0-255)
- * @param b
- * blue amount (0-255)
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder foreground(int r, int g, int b) {
- return foreground(createColor(r, g, b));
- }
-
- /**
- * Sets the foreground (text) color of the style
- *
- * @param color
- * the color to use
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder foreground(Color color) {
- if (EqualsBuilder.equals(_defaultForegroundColor, color)) {
- _foregroundColor = null;
- } else {
- _foregroundColor = color;
- }
- return this;
- }
-
- /**
- * Sets the background (fill) color of the style
- *
- * @param rgbColorCode
- * a 6-letter hex RGB color code, such as FF0000 (red).
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder background(String rgbColorCode) {
- return background(createColor(rgbColorCode));
- }
-
- /**
- * Sets the background (fill) color of the style
- *
- * @param rgb
- * a triplet array of shorts
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder background(short[] rgb) {
- assert rgb.length == 3;
- return background(createColor(rgb[0], rgb[1], rgb[2]));
- }
-
- /**
- * Sets the background (fill) color of the style
- *
- * @param r
- * red amount (0-255)
- * @param g
- * green amount (0-255)
- * @param b
- * blue amount (0-255)
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder background(int r, int g, int b) {
- return background(createColor(r, g, b));
- }
-
- /**
- * Sets the background (fill) color of the style
- *
- * @param color
- * the color to use
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder background(Color color) {
- if (EqualsBuilder.equals(_defaultBackgroundColor, color)) {
- _backgroundColor = null;
- } else {
- _backgroundColor = color;
- }
- return this;
- }
-
- /**
- * Sets the font size of the style
- *
- * @param fontSize
- * the font size
- * @param sizeUnit
- * the font size unit
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder fontSize(int fontSize, SizeUnit sizeUnit) {
- _fontSize = fontSize;
- _fontSizeUnit = sizeUnit;
- return this;
- }
-
- /**
- * Sets the text alignment to center
- *
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder centerAligned() {
- _alignment = TextAlignment.CENTER;
- return this;
- }
-
- /**
- * Sets the text alignment to left
- *
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder leftAligned() {
- _alignment = TextAlignment.LEFT;
- return this;
- }
-
- /**
- * Sets the text alignment to right
- *
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder rightAligned() {
- _alignment = TextAlignment.RIGHT;
- return this;
- }
-
- /**
- * Sets the text alignment to justify
- *
- * @return the {@link StyleBuilder} self (for cascading method calls)
- */
- public StyleBuilder justifyAligned() {
- _alignment = TextAlignment.JUSTIFY;
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/StyleImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/StyleImpl.java b/core/src/main/java/org/eobjects/metamodel/data/StyleImpl.java
deleted file mode 100644
index 9c48cf7..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/StyleImpl.java
+++ /dev/null
@@ -1,177 +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.data;
-
-import java.util.List;
-
-import org.eobjects.metamodel.util.BaseObject;
-
-/**
- * Default immutable implementation of {@link Style}.
- *
- * @author Kasper Sørensen
- */
-final class StyleImpl extends BaseObject implements Style {
-
- private static final long serialVersionUID = 1L;
-
- private final boolean _underline;
- private final boolean _italic;
- private final boolean _bold;
- private final Integer _fontSize;
- private final TextAlignment _alignment;
- private final Color _backgroundColor;
- private final Color _foregroundColor;
- private final SizeUnit _fontSizeUnit;
-
- public StyleImpl() {
- this(false, false, false, null, null, null, null, null);
- }
-
- public StyleImpl(boolean bold, boolean italic, boolean underline,
- Integer fontSize, SizeUnit fontSizeUnit, TextAlignment alignment,
- Color backgroundColor, Color foregroundColor) {
- _bold = bold;
- _italic = italic;
- _underline = underline;
- _fontSize = fontSize;
- _fontSizeUnit = fontSizeUnit;
- _alignment = alignment;
- _backgroundColor = backgroundColor;
- _foregroundColor = foregroundColor;
- }
-
- @Override
- public boolean isBold() {
- return _bold;
- }
-
- @Override
- public boolean isItalic() {
- return _italic;
- }
-
- @Override
- public boolean isUnderline() {
- return _underline;
- }
-
- @Override
- public Integer getFontSize() {
- return _fontSize;
- }
-
- @Override
- public SizeUnit getFontSizeUnit() {
- return _fontSizeUnit;
- }
-
- @Override
- public TextAlignment getAlignment() {
- return _alignment;
- }
-
- @Override
- public Color getForegroundColor() {
- return _foregroundColor;
- }
-
- @Override
- public Color getBackgroundColor() {
- return _backgroundColor;
- }
-
- @Override
- public String toCSS() {
- StringBuilder sb = new StringBuilder();
- if (_bold) {
- sb.append("font-weight: bold;");
- }
- if (_italic) {
- sb.append("font-style: italic;");
- }
- if (_underline) {
- sb.append("text-decoration: underline;");
- }
- if (_alignment != null) {
- sb.append("text-align: " + toCSS(_alignment) + ";");
- }
- if (_fontSize != null) {
- sb.append("font-size: " + _fontSize);
- switch (_fontSizeUnit) {
- case PT:
- sb.append("pt");
- break;
- case PX:
- sb.append("px");
- break;
- case PERCENT:
- sb.append("%");
- break;
- default:
- // don't write a size unit
- }
- sb.append(';');
- }
- if (_foregroundColor != null) {
- sb.append("color: " + toCSS(_foregroundColor) + ";");
- }
- if (_backgroundColor != null) {
- sb.append("background-color: " + toCSS(_backgroundColor) + ";");
- }
- return sb.toString();
- }
-
- private String toCSS(Color c) {
- return "rgb(" + c.getRed() + "," + c.getGreen() + "," + c.getBlue()
- + ")";
- }
-
- @Override
- public String toString() {
- return toCSS();
- }
-
- private String toCSS(TextAlignment alignment) {
- switch (alignment) {
- case LEFT:
- return "left";
- case RIGHT:
- return "right";
- case CENTER:
- return "center";
- case JUSTIFY:
- return "justify";
- default:
- throw new IllegalStateException("Unknown alignment: " + alignment);
- }
- }
-
- @Override
- protected void decorateIdentity(List<Object> identifiers) {
- identifiers.add(_underline);
- identifiers.add(_italic);
- identifiers.add(_bold);
- identifiers.add(_fontSize);
- identifiers.add(_fontSizeUnit);
- identifiers.add(_alignment);
- identifiers.add(_backgroundColor);
- identifiers.add(_foregroundColor);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/SubSelectionDataSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/SubSelectionDataSet.java b/core/src/main/java/org/eobjects/metamodel/data/SubSelectionDataSet.java
deleted file mode 100644
index aee4ca6..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/SubSelectionDataSet.java
+++ /dev/null
@@ -1,57 +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.data;
-
-import org.eobjects.metamodel.query.SelectItem;
-
-/**
- * {@link DataSet} wrapper for doing subselection.
- *
- * @author Kasper Sørensen
- */
-public final class SubSelectionDataSet extends AbstractDataSet {
-
- private final DataSet _dataSet;
-
- public SubSelectionDataSet(SelectItem[] selectItemsArray, DataSet dataSet) {
- super(selectItemsArray);
- _dataSet = dataSet;
- }
-
- public DataSet getWrappedDataSet() {
- return _dataSet;
- }
-
- @Override
- public boolean next() {
- return _dataSet.next();
- }
-
- @Override
- public Row getRow() {
- final DataSetHeader header = getHeader();
- return _dataSet.getRow().getSubSelection(header);
- }
-
- @Override
- public void close() {
- super.close();
- _dataSet.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/WhereClauseBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/WhereClauseBuilder.java b/core/src/main/java/org/eobjects/metamodel/data/WhereClauseBuilder.java
deleted file mode 100644
index 431d640..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/WhereClauseBuilder.java
+++ /dev/null
@@ -1,69 +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.data;
-
-import org.eobjects.metamodel.query.FilterItem;
-import org.eobjects.metamodel.query.builder.FilterBuilder;
-import org.eobjects.metamodel.schema.Column;
-
-/**
- * An interface for builder components that formulate a WHERE clause, either for
- * querying, updating, deleting or other purposes.
- *
- * @param <T>
- * the return type of the {@link WhereClauseBuilder}s builder methods
- */
-public interface WhereClauseBuilder<T> {
-
- /**
- * Defines a where item to set as a criteria
- *
- * @param column
- * a column to apply a criteria for
- * @return a builder object for further building the where item
- */
- public FilterBuilder<T> where(Column column);
-
- /**
- * Defines a where item to set as a criteria
- *
- * @param columnName
- * the name of the colum to which the criteria will be applied
- * @return a builder object for further building the where item
- */
- public FilterBuilder<T> where(String columnName);
-
- /**
- * Applies where items to set criteria
- *
- * @param filterItems
- * the where items to set
- * @return the builder object itself, for further building of the update
- */
- public T where(FilterItem... filterItems);
-
- /**
- * Applies where items to set criteria
- *
- * @param filterItems
- * the where items to set
- * @return the builder object, for further building of the update
- */
- public T where(Iterable<FilterItem> filterItems);
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/package-info.java b/core/src/main/java/org/eobjects/metamodel/data/package-info.java
deleted file mode 100644
index 9791fe8..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/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 data sets
- */
-package org.eobjects.metamodel.data;
-
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/delete/AbstractRowDeletionBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/delete/AbstractRowDeletionBuilder.java b/core/src/main/java/org/eobjects/metamodel/delete/AbstractRowDeletionBuilder.java
deleted file mode 100644
index 6efc703..0000000
--- a/core/src/main/java/org/eobjects/metamodel/delete/AbstractRowDeletionBuilder.java
+++ /dev/null
@@ -1,135 +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.delete;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eobjects.metamodel.data.Row;
-import org.eobjects.metamodel.query.FilterClause;
-import org.eobjects.metamodel.query.FilterItem;
-import org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.query.builder.AbstractFilterBuilder;
-import org.eobjects.metamodel.query.builder.FilterBuilder;
-import org.eobjects.metamodel.schema.Column;
-import org.eobjects.metamodel.schema.Table;
-
-/**
- * Abstract {@link RowDeletionBuilder} implementation
- */
-public abstract class AbstractRowDeletionBuilder implements RowDeletionBuilder {
-
- private final Table _table;
- private final List<FilterItem> _whereItems;
-
- public AbstractRowDeletionBuilder(Table table) {
- if (table == null) {
- throw new IllegalArgumentException("Table cannot be null");
- }
- _table = table;
- _whereItems = new ArrayList<FilterItem>();
- }
-
- protected List<FilterItem> getWhereItems() {
- return _whereItems;
- }
-
- @Override
- public FilterBuilder<RowDeletionBuilder> where(Column column) {
- SelectItem selectItem = new SelectItem(column);
- return new AbstractFilterBuilder<RowDeletionBuilder>(selectItem) {
- @Override
- protected RowDeletionBuilder applyFilter(FilterItem filter) {
- return where(filter);
- }
- };
- }
-
- @Override
- public FilterBuilder<RowDeletionBuilder> where(String columnName) {
- Column column = _table.getColumnByName(columnName);
- if (column == null) {
- throw new IllegalArgumentException("No such column: " + columnName);
- }
- return where(column);
- }
-
- @Override
- public RowDeletionBuilder where(FilterItem... filterItems) {
- for (FilterItem filterItem : filterItems) {
- _whereItems.add(filterItem);
- }
- return this;
- }
-
- @Override
- public RowDeletionBuilder where(Iterable<FilterItem> filterItems) {
- for (FilterItem filterItem : filterItems) {
- _whereItems.add(filterItem);
- }
- return this;
- }
-
- @Override
- public Table getTable() {
- return _table;
- }
-
- /**
- * Determines if a row should be deleted or not (can be used by subclasses
- * as a convenient determinator).
- *
- * @param row
- * @return true if the row should be deleted.
- */
- protected boolean deleteRow(Row row) {
- final List<FilterItem> whereItems = getWhereItems();
- for (FilterItem filterItem : whereItems) {
- if (!filterItem.evaluate(row)) {
- // since filter items are ANDed, if any item does not evaluate
- // to true, the row is not deleted
- return false;
- }
- }
- return true;
- }
-
- /**
- * Convenience method to tell subclasses if the delete operation represents
- * a full table truncate operation. Usually such operations can be optimized
- * by simply removing the table (and maybe restoring similar headers in a
- * new table).
- *
- * @return
- */
- protected boolean isTruncateTableOperation() {
- final List<FilterItem> whereItems = getWhereItems();
- return whereItems.isEmpty();
- }
-
- @Override
- public String toString() {
- return toSql();
- }
-
- @Override
- public String toSql() {
- return "DELETE FROM " + _table.getQualifiedLabel() + new FilterClause(null, " WHERE ").addItems(_whereItems);
- }
-}