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:20 UTC
[37/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/convert/Converters.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/convert/Converters.java b/core/src/main/java/org/eobjects/metamodel/convert/Converters.java
deleted file mode 100644
index 11dd331..0000000
--- a/core/src/main/java/org/eobjects/metamodel/convert/Converters.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.convert;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.eobjects.metamodel.DataContext;
-import org.eobjects.metamodel.MetaModelHelper;
-import org.eobjects.metamodel.UpdateableDataContext;
-import org.eobjects.metamodel.data.DataSet;
-import org.eobjects.metamodel.data.Row;
-import org.eobjects.metamodel.data.RowBuilder;
-import org.eobjects.metamodel.data.Style;
-import org.eobjects.metamodel.intercept.InterceptableDataContext;
-import org.eobjects.metamodel.intercept.Interceptors;
-import org.eobjects.metamodel.query.Query;
-import org.eobjects.metamodel.schema.Column;
-import org.eobjects.metamodel.schema.SuperColumnType;
-import org.eobjects.metamodel.schema.Table;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class consists of static methods for decorating {@link DataContext}s
- * with {@link TypeConverter}s, which allows for automatic conversion of values
- * on data read and write operations.
- */
-public final class Converters {
-
- private static final Logger logger = LoggerFactory.getLogger(Converters.class);
-
- private Converters() {
- // prevent instantiation
- }
-
- /**
- * Adds a type converter to a specific column in the {@link DataContext}.
- *
- * @param dataContext
- * the DataContext to decorate
- * @param column
- * the column which holds values to convert
- * @param converter
- * the converter to use on the specified column
- * @return a decorated DataContext, which should be used for successive
- * operations on the data.
- */
- public static UpdateableDataContext addTypeConverter(UpdateableDataContext dataContext, Column column,
- TypeConverter<?, ?> converter) {
- return addTypeConverterInternally(dataContext, column, converter);
- }
-
- /**
- * Adds a type converter to a specific column in the {@link DataContext}.
- *
- * @param dataContext
- * the DataContext to decorate
- * @param column
- * the column which holds values to convert
- * @param converter
- * the converter to use on the specified column
- * @return a decorated DataContext, which should be used for successive
- * operations on the data.
- */
- public static DataContext addTypeConverter(DataContext dataContext, Column column, TypeConverter<?, ?> converter) {
- return addTypeConverterInternally(dataContext, column, converter);
- }
-
- /**
- * Adds a collection of type converters to specific columns in the
- * {@link DataContext}
- *
- * @param dataContext
- * the DataContext to decorate
- * @param converters
- * a map containing columns and mapped type converters.
- * @return a decorated DataContext, which should be used for successive
- * operations on the data.
- */
- public static UpdateableDataContext addTypeConverters(UpdateableDataContext dataContext,
- Map<Column, TypeConverter<?, ?>> converters) {
- return addTypeConvertersInternally(dataContext, converters);
- }
-
- /**
- * Adds a collection of type converters to specific columns in the
- * {@link DataContext}
- *
- * @param dataContext
- * the DataContext to decorate
- * @param converters
- * a map containing columns and mapped type converters.
- * @return a decorated DataContext, which should be used for successive
- * operations on the data.
- */
- public static DataContext addTypeConverters(DataContext dataContext, Map<Column, TypeConverter<?, ?>> converters) {
- return addTypeConvertersInternally(dataContext, converters);
- }
-
- /**
- * Auto-detects / guesses the type converters to be applied on set of
- * columns. This method will query the String columns in order to assert
- * which columns are likely candidates for conversion.
- *
- * As such this method is not guaranteed to pick the correct converters,
- * since data can change over time or other conversions can be requested.
- *
- * @param dataContext
- * the DataContext that holds the data.
- * @param columns
- * the columns to inspect to find type conversion candidates.
- * @param sampleSize
- * the max amount of rows to query for doing auto-detection. Use
- * {@link Integer#MAX_VALUE} if no constraint should be put on
- * the number of records to sample.
- * @return a map of {@link Column}s and {@link TypeConverter}s which can be
- * used (eg. with the {@link #addTypeConverters(DataContext, Map)}
- * method) to decorate the DataContext with type converters.
- */
- public static Map<Column, TypeConverter<?, ?>> autoDetectConverters(DataContext dataContext, Column[] columns,
- int sampleSize) {
- columns = MetaModelHelper.getColumnsBySuperType(columns, SuperColumnType.LITERAL_TYPE);
- final Map<Column, TypeConverter<?, ?>> result = new HashMap<Column, TypeConverter<?, ?>>();
- Table[] tables = MetaModelHelper.getTables(columns);
- for (Table table : tables) {
- Column[] tableColumns = MetaModelHelper.getTableColumns(table, columns);
- autoDetectConvertersInternally(dataContext, table, tableColumns, sampleSize, result);
- }
- return result;
- }
-
- /**
- * Auto-detects / guesses the type converters to be applied on a table. This
- * method will query the String columns of a table in order to assert which
- * columns are likely candidates for conversion.
- *
- * As such this method is not guaranteed to pick the correct converters,
- * since data can change over time or other conversions can be requested.
- *
- * @param dataContext
- * the DataContext that holds the data.
- * @param table
- * the table to inspect to find type conversion candidates. This
- * table will hold all columns of the result.
- * @param sampleSize
- * the max amount of rows to query for doing auto-detection. Use
- * {@link Integer#MAX_VALUE} if no constraint should be put on
- * the number of records to sample.
- * @return a map of {@link Column}s and {@link TypeConverter}s which can be
- * used (eg. with the {@link #addTypeConverters(DataContext, Map)}
- * method) to decorate the DataContext with type converters.
- */
- public static Map<Column, TypeConverter<?, ?>> autoDetectConverters(DataContext dataContext, Table table,
- int sampleSize) {
- final Map<Column, TypeConverter<?, ?>> result = new HashMap<Column, TypeConverter<?, ?>>();
- Column[] columns = table.getColumnsOfSuperType(SuperColumnType.LITERAL_TYPE);
- autoDetectConvertersInternally(dataContext, table, columns, sampleSize, result);
- return result;
- }
-
- private static void autoDetectConvertersInternally(DataContext dataContext, Table table, Column[] columns,
- int sampleSize, Map<Column, TypeConverter<?, ?>> result) {
- if (columns == null || columns.length == 0) {
- return;
- }
-
- Map<Column, ColumnTypeDetector> detectors = new HashMap<Column, ColumnTypeDetector>();
- for (Column column : columns) {
- detectors.put(column, new ColumnTypeDetector());
- }
-
- Query query = dataContext.query().from(table).select(columns).toQuery();
- if (sampleSize > 0 && sampleSize != Integer.MAX_VALUE) {
- query.setMaxRows(sampleSize);
- }
- DataSet dataSet = dataContext.executeQuery(query);
- try {
- while (dataSet.next()) {
- Row row = dataSet.getRow();
- for (Column column : columns) {
- String stringValue = (String) row.getValue(column);
- ColumnTypeDetector detector = detectors.get(column);
- detector.registerValue(stringValue);
- }
- }
- } finally {
- dataSet.close();
- }
- for (Column column : columns) {
- ColumnTypeDetector detector = detectors.get(column);
- TypeConverter<?, ?> converter = detector.createConverter();
- if (converter != null) {
- result.put(column, converter);
- }
- }
- }
-
- private static InterceptableDataContext addTypeConvertersInternally(final DataContext dc,
- Map<Column, TypeConverter<?, ?>> converters) {
- if (converters == null) {
- throw new IllegalArgumentException("Converters cannot be null");
- }
-
- InterceptableDataContext interceptable = Interceptors.intercept(dc);
-
- Set<Entry<Column, TypeConverter<?, ?>>> entries = converters.entrySet();
- for (Entry<Column, TypeConverter<?, ?>> entry : entries) {
- Column column = entry.getKey();
- TypeConverter<?, ?> converter = entry.getValue();
- interceptable = addTypeConverterInternally(interceptable, column, converter);
- }
-
- return interceptable;
- }
-
- private static InterceptableDataContext addTypeConverterInternally(final DataContext dc, Column column,
- TypeConverter<?, ?> converter) {
- if (column == null) {
- throw new IllegalArgumentException("Column cannot be null");
- }
-
- InterceptableDataContext interceptable = Interceptors.intercept(dc);
- DataContext delegate = interceptable.getDelegate();
-
- boolean interceptDataSets = true;
-
- if (delegate instanceof HasReadTypeConverters) {
- // some DataContexts implement the HasTypeConverters interface,
- // which is preferred when available
- HasReadTypeConverters hasTypeConverter = (HasReadTypeConverters) delegate;
- hasTypeConverter.addConverter(column, converter);
-
- interceptDataSets = false;
- }
-
- addTypeConverterInterceptors(interceptable, column, converter, interceptDataSets);
- return interceptable;
- }
-
- private static void addTypeConverterInterceptors(InterceptableDataContext interceptable, Column column,
- TypeConverter<?, ?> converter, boolean interceptDataSets) {
- // intercept datasets (reads)
- if (interceptDataSets) {
- ConvertedDataSetInterceptor interceptor = interceptable.getDataSetInterceptors().getInterceptorOfType(
- ConvertedDataSetInterceptor.class);
- if (interceptor == null) {
- interceptor = new ConvertedDataSetInterceptor();
- interceptable.addDataSetInterceptor(interceptor);
- }
- interceptor.addConverter(column, converter);
- }
-
- // intercept inserts (writes)
- {
- ConvertedRowInsertionInterceptor interceptor = interceptable.getRowInsertionInterceptors()
- .getInterceptorOfType(ConvertedRowInsertionInterceptor.class);
- if (interceptor == null) {
- interceptor = new ConvertedRowInsertionInterceptor();
- interceptable.addRowInsertionInterceptor(interceptor);
- }
- interceptor.addConverter(column, converter);
- }
-
- // convert updates
- {
- ConvertedRowUpdationInterceptor interceptor = interceptable.getRowUpdationInterceptors()
- .getInterceptorOfType(ConvertedRowUpdationInterceptor.class);
- if (interceptor == null) {
- interceptor = new ConvertedRowUpdationInterceptor();
- interceptable.addRowUpdationInterceptor(interceptor);
- }
- interceptor.addConverter(column, converter);
- }
-
- // converting deletes (as well as where-items in updates) should not be
- // applied, because the DataSet interceptor is anyways only working on
- // the output. In that sense it adds symetry to NOT support conversion
- // in the where clause of UPDATEs and DELETEs.
- }
-
- /**
- * Converts values in a {@link RowBuilder}.
- *
- * @param rowBuilder
- * @param converters
- * @return
- */
- protected static <RB extends RowBuilder<?>> RB convertRow(RB rowBuilder, Map<Column, TypeConverter<?, ?>> converters) {
- Table table = rowBuilder.getTable();
- Column[] columns = table.getColumns();
- Row row = rowBuilder.toRow();
- for (Column column : columns) {
- @SuppressWarnings("unchecked")
- TypeConverter<?, Object> converter = (TypeConverter<?, Object>) converters.get(column);
- if (converter != null) {
- final int indexInRow = row.indexOf(column);
- final Object value = row.getValue(indexInRow);
- final Object physicalValue = converter.toPhysicalValue(value);
- logger.debug("Converted virtual value {} to {}", value, physicalValue);
- if (value == null && physicalValue == null && !rowBuilder.isSet(column)) {
- logger.debug("Omitting implicit null value for column: {}", column);
- } else {
- final Style style = row.getStyle(indexInRow);
- rowBuilder.value(column, physicalValue, style);
- }
- }
- }
- return rowBuilder;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/convert/HasReadTypeConverters.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/convert/HasReadTypeConverters.java b/core/src/main/java/org/eobjects/metamodel/convert/HasReadTypeConverters.java
deleted file mode 100644
index a5c1f86..0000000
--- a/core/src/main/java/org/eobjects/metamodel/convert/HasReadTypeConverters.java
+++ /dev/null
@@ -1,33 +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.convert;
-
-import org.eobjects.metamodel.data.DataSet;
-import org.eobjects.metamodel.schema.Column;
-
-/**
- * Defines an interface for objects that are aware of {@link TypeConverter}s,
- * and know how to apply them to read operations (Queries or {@link DataSet}s).
- *
- * @author Kasper Sørensen
- */
-public interface HasReadTypeConverters {
-
- public void addConverter(Column column, TypeConverter<?, ?> converter);
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/convert/StringToBooleanConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/convert/StringToBooleanConverter.java b/core/src/main/java/org/eobjects/metamodel/convert/StringToBooleanConverter.java
deleted file mode 100644
index 6f3fdaa..0000000
--- a/core/src/main/java/org/eobjects/metamodel/convert/StringToBooleanConverter.java
+++ /dev/null
@@ -1,54 +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.convert;
-
-import org.eobjects.metamodel.util.BooleanComparator;
-
-/**
- * A {@link TypeConverter} that converts String values (on the physical layer)
- * to interpreted Booleans.
- *
- * @author Kasper Sørensen
- * @author Ankit Kumar
- */
-public class StringToBooleanConverter implements TypeConverter<String, Boolean> {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toPhysicalValue(Boolean virtualValue) {
- if (virtualValue == null) {
- return null;
- }
- return virtualValue.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Boolean toVirtualValue(String physicalValue) {
- if (physicalValue == null || physicalValue.length() == 0) {
- return null;
- }
- return BooleanComparator.parseBoolean(physicalValue);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/convert/StringToDateConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/convert/StringToDateConverter.java b/core/src/main/java/org/eobjects/metamodel/convert/StringToDateConverter.java
deleted file mode 100644
index 862bc64..0000000
--- a/core/src/main/java/org/eobjects/metamodel/convert/StringToDateConverter.java
+++ /dev/null
@@ -1,127 +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.convert;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.eobjects.metamodel.util.Func;
-import org.eobjects.metamodel.util.TimeComparator;
-
-/**
- * A {@link TypeConverter} that converts String values (on the physical layer)
- * to interpreted {@link Date}s.
- *
- * @author Kasper Sørensen
- * @author Ankit Kumar
- */
-public class StringToDateConverter implements TypeConverter<String, Date> {
-
- private final Func<Date, String> _serializeFunc;
- private final Func<String, Date> _deserializeFunc;
-
- /**
- * Constructs a new {@link StringToDateConverter} which will use the
- * {@link TimeComparator#toDate(Object)} method for parsing dates and the
- * {@link DateFormat#MEDIUM} date time format for physical representation.
- */
- public StringToDateConverter() {
- _deserializeFunc = new Func<String, Date>() {
- @Override
- public Date eval(String stringValue) {
- return TimeComparator.toDate(stringValue);
- }
- };
- _serializeFunc = new Func<Date, String>() {
- @Override
- public String eval(Date date) {
- return DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
- DateFormat.MEDIUM).format(date);
- }
- };
- }
-
- /**
- * Constructs a new {@link StringToDateConverter} using a given date
- * pattern.
- *
- * @param datePattern
- * a String date pattern, corresponding to the syntax of a
- * {@link SimpleDateFormat}.
- */
- public StringToDateConverter(String datePattern) {
- this(new SimpleDateFormat(datePattern));
- }
-
- /**
- * Constructs a new {@link StringToDateConverter} using a given
- * {@link DateFormat}.
- *
- * @param dateFormat
- * the {@link DateFormat} to use for parsing and formatting
- * dates.
- */
- public StringToDateConverter(final DateFormat dateFormat) {
- if (dateFormat == null) {
- throw new IllegalArgumentException("DateFormat cannot be null");
- }
- _deserializeFunc = new Func<String, Date>() {
- @Override
- public Date eval(String string) {
- try {
- return dateFormat.parse(string);
- } catch (ParseException e) {
- throw new IllegalArgumentException(
- "Could not parse date string: " + string);
- }
- }
- };
- _serializeFunc = new Func<Date, String>() {
- @Override
- public String eval(Date date) {
- return dateFormat.format(date);
- }
- };
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toPhysicalValue(Date virtualValue) {
- if (virtualValue == null) {
- return null;
- }
- return _serializeFunc.eval(virtualValue);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Date toVirtualValue(String physicalValue) {
- if (physicalValue == null || physicalValue.length() == 0) {
- return null;
- }
- return _deserializeFunc.eval(physicalValue);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/convert/StringToDoubleConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/convert/StringToDoubleConverter.java b/core/src/main/java/org/eobjects/metamodel/convert/StringToDoubleConverter.java
deleted file mode 100644
index d073cfc..0000000
--- a/core/src/main/java/org/eobjects/metamodel/convert/StringToDoubleConverter.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.convert;
-
-/**
- * A {@link TypeConverter} that converts String values (on the physical layer)
- * to interpreted Doubles.
- *
- * @author Kasper Sørensen
- * @author Ankit Kumar
- */
-public class StringToDoubleConverter implements TypeConverter<String, Double> {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toPhysicalValue(Double virtualValue) {
- if (virtualValue == null) {
- return null;
- }
- return virtualValue.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Double toVirtualValue(String physicalValue) {
- if (physicalValue == null || physicalValue.length() == 0) {
- return null;
- }
- return Double.parseDouble(physicalValue);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/convert/StringToIntegerConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/convert/StringToIntegerConverter.java b/core/src/main/java/org/eobjects/metamodel/convert/StringToIntegerConverter.java
deleted file mode 100644
index 19d1bb5..0000000
--- a/core/src/main/java/org/eobjects/metamodel/convert/StringToIntegerConverter.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.convert;
-
-/**
- * A {@link TypeConverter} that converts String values (on the physical layer)
- * to interpreted Integers.
- *
- * @author Kasper Sørensen
- * @author Ankit Kumar
- */
-public class StringToIntegerConverter implements TypeConverter<String, Integer> {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toPhysicalValue(Integer virtualValue) {
- if (virtualValue == null) {
- return null;
- }
- return virtualValue.toString();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Integer toVirtualValue(String physicalValue) {
- if (physicalValue == null || physicalValue.length() == 0) {
- return null;
- }
- return Integer.parseInt(physicalValue);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/convert/TypeConverter.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/convert/TypeConverter.java b/core/src/main/java/org/eobjects/metamodel/convert/TypeConverter.java
deleted file mode 100644
index 5827b2a..0000000
--- a/core/src/main/java/org/eobjects/metamodel/convert/TypeConverter.java
+++ /dev/null
@@ -1,54 +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.convert;
-
-/**
- * Defines an interface for converting values from and to their physical
- * materializations and their virtual representations.
- *
- * @see ConvertedDataContext
- *
- * @author Kasper Sørensen
- * @author Ankit Kumar
- *
- * @param <P>
- * the physical type of value
- * @param <V>
- * the virtual type of value
- */
-public interface TypeConverter<P, V> {
-
- /**
- * Converts a virtual representation of a value into it's physical value.
- *
- * @param virtualValue
- * the virtual representation
- * @return the physical value
- */
- public P toPhysicalValue(V virtualValue);
-
- /**
- * Converts a physical value into it's virtual representation.
- *
- * @param physicalValue
- * the physical value
- * @return the virtual representation
- */
- public V toVirtualValue(P physicalValue);
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/convert/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/convert/package-info.java b/core/src/main/java/org/eobjects/metamodel/convert/package-info.java
deleted file mode 100644
index 88ec009..0000000
--- a/core/src/main/java/org/eobjects/metamodel/convert/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.
- */
-/**
- * DataContext decorator for implicit conversion of value types after querying and before insertion.
- */
-package org.eobjects.metamodel.convert;
-
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/create/AbstractColumnBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/create/AbstractColumnBuilder.java b/core/src/main/java/org/eobjects/metamodel/create/AbstractColumnBuilder.java
deleted file mode 100644
index 2f2e422..0000000
--- a/core/src/main/java/org/eobjects/metamodel/create/AbstractColumnBuilder.java
+++ /dev/null
@@ -1,87 +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.create;
-
-import org.eobjects.metamodel.schema.Column;
-import org.eobjects.metamodel.schema.ColumnType;
-import org.eobjects.metamodel.schema.MutableColumn;
-
-/**
- * Convenience implementation of all {@link ColumnBuilder} methods
- *
- * @param <T>
- * the return type of the builder methods.
- */
-abstract class AbstractColumnBuilder<T extends ColumnBuilder<?>> implements ColumnBuilder<T> {
-
- private final MutableColumn _column;
-
- public AbstractColumnBuilder(MutableColumn column) {
- _column = column;
- }
-
- protected MutableColumn getColumn() {
- return _column;
- }
-
- @SuppressWarnings("unchecked")
- protected T getReturnObject() {
- return (T) this;
- }
-
- @Override
- public final T like(Column column) {
- _column.setColumnSize(column.getColumnSize());
- _column.setNativeType(column.getNativeType());
- _column.setType(column.getType());
- _column.setNullable(column.isNullable());
- return getReturnObject();
- }
-
- @Override
- public final T ofType(ColumnType type) {
- _column.setType(type);
- return getReturnObject();
- }
-
- @Override
- public final T ofNativeType(String nativeType) {
- _column.setNativeType(nativeType);
- return getReturnObject();
- }
-
- @Override
- public final T ofSize(int size) {
- _column.setColumnSize(size);
- return getReturnObject();
- }
-
- @Override
- public final T nullable(boolean nullable) {
- _column.setNullable(nullable);
- return getReturnObject();
- }
-
- @Override
- public final T asPrimaryKey() {
- _column.setPrimaryKey(true);
- return getReturnObject();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/create/AbstractTableCreationBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/create/AbstractTableCreationBuilder.java b/core/src/main/java/org/eobjects/metamodel/create/AbstractTableCreationBuilder.java
deleted file mode 100644
index 2d52275..0000000
--- a/core/src/main/java/org/eobjects/metamodel/create/AbstractTableCreationBuilder.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.create;
-
-import org.eobjects.metamodel.UpdateCallback;
-import org.eobjects.metamodel.schema.Column;
-import org.eobjects.metamodel.schema.ColumnType;
-import org.eobjects.metamodel.schema.MutableColumn;
-import org.eobjects.metamodel.schema.MutableTable;
-import org.eobjects.metamodel.schema.Schema;
-import org.eobjects.metamodel.schema.Table;
-import org.eobjects.metamodel.schema.TableType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Abstract {@link TableCreationBuilder} implementation, provided as convenience
- * for {@link TableCreatable} implementations. Handles all the building
- * operations, but not the commit operation.
- *
- * @author Kasper Sørensen
- */
-public abstract class AbstractTableCreationBuilder<U extends UpdateCallback> implements TableCreationBuilder {
-
- private static final Logger logger = LoggerFactory.getLogger(AbstractTableCreationBuilder.class);
-
- private final U _updateCallback;
- private final MutableTable _table;
- private final Schema _schema;
-
- public AbstractTableCreationBuilder(U updateCallback, Schema schema, String name) {
- if (schema != null && schema.getTableByName(name) != null) {
- throw new IllegalArgumentException("A table with the name '" + name + "' already exists in schema: "
- + schema);
- }
- _updateCallback = updateCallback;
- _schema = schema;
- _table = new MutableTable(name, TableType.TABLE, schema);
- }
-
- protected U getUpdateCallback() {
- return _updateCallback;
- }
-
- protected Schema getSchema() {
- return _schema;
- }
-
- protected MutableTable getTable() {
- return _table;
- }
-
- @Override
- public Table toTable() {
- return _table;
- }
-
- @Override
- public TableCreationBuilder like(Table table) {
- logger.debug("like({})", table);
- Column[] columns = table.getColumns();
- for (Column column : columns) {
- withColumn(column.getName()).like(column);
- }
- return this;
- }
-
- @Override
- public ColumnCreationBuilder withColumn(String name) {
- logger.debug("withColumn({})", name);
- MutableColumn col = (MutableColumn) _table.getColumnByName(name);
- if (col == null) {
- col = new MutableColumn(name).setTable(_table).setColumnNumber(_table.getColumnCount());
- _table.addColumn(col);
- }
- return new ColumnCreationBuilderImpl(this, col);
- }
-
- @Override
- public String toString() {
- return toSql();
- }
-
- @Override
- public String toSql() {
- StringBuilder sb = new StringBuilder();
- sb.append("CREATE TABLE ");
- sb.append(_table.getQualifiedLabel());
- sb.append(" (");
- Column[] columns = _table.getColumns();
- for (int i = 0; i < columns.length; i++) {
- if (i != 0) {
- sb.append(',');
- }
- Column column = columns[i];
- sb.append(column.getName());
- ColumnType type = column.getType();
- if (type != null) {
- sb.append(' ');
- sb.append(type.toString());
- Integer columnSize = column.getColumnSize();
- if (columnSize != null) {
- sb.append('(');
- sb.append(columnSize);
- sb.append(')');
- }
- }
- if (column.isNullable() != null
- && !column.isNullable().booleanValue()) {
- sb.append(" NOT NULL");
- }
- if (column.isPrimaryKey()) {
- sb.append(" PRIMARY KEY");
- }
- }
- sb.append(")");
- return sb.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/create/ColumnBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/create/ColumnBuilder.java b/core/src/main/java/org/eobjects/metamodel/create/ColumnBuilder.java
deleted file mode 100644
index 1f1ea74..0000000
--- a/core/src/main/java/org/eobjects/metamodel/create/ColumnBuilder.java
+++ /dev/null
@@ -1,88 +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.create;
-
-import org.eobjects.metamodel.DataContext;
-import org.eobjects.metamodel.schema.Column;
-import org.eobjects.metamodel.schema.ColumnType;
-
-/**
- * Abstract interface for components that build columns.
- *
- * Defines methods for refining particular properties of the column build.
- *
- * @param <T>
- * the return type of the builder methods
- */
-public interface ColumnBuilder<T extends ColumnBuilder<?>> {
-
- /**
- * Builds several properties of a column, based on another {@link Column}
- * object as a prototype.
- *
- * @param column
- * a prototype for the column being built.
- * @return a builder object for further column creation.
- */
- public T like(Column column);
-
- /**
- * Defines the {@link ColumnType} of the created column.
- *
- * @param type
- * the column type of the created column.
- * @return a builder object for further column creation.
- */
- public T ofType(ColumnType type);
-
- /**
- * Defines the native type of the created column (useful especially for SQL
- * based {@link DataContext}s).
- *
- * @param nativeType
- * the native type of the created column
- * @return a builder object for further column creation.
- */
- public T ofNativeType(String nativeType);
-
- /**
- * Defines the size of the created column.
- *
- * @param size
- * the size of the created column.
- * @return a builder object for further column creation.
- */
- public T ofSize(int size);
-
- /**
- * Defines if the created column should be nullable or not.
- *
- * @param nullable
- * if the created column should be nullable or not.
- * @return a builder object for further column creation.
- */
- public T nullable(boolean nullable);
-
- /**
- * Defines that the created column should be a primary key
- *
- * @return a builder object for further column creation.
- */
- public T asPrimaryKey();
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/create/ColumnCreationBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/create/ColumnCreationBuilder.java b/core/src/main/java/org/eobjects/metamodel/create/ColumnCreationBuilder.java
deleted file mode 100644
index d53abda..0000000
--- a/core/src/main/java/org/eobjects/metamodel/create/ColumnCreationBuilder.java
+++ /dev/null
@@ -1,32 +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.create;
-
-import org.eobjects.metamodel.schema.Column;
-
-/**
- * Builder object for creating {@link Column}s. This class also extendsthe
- * {@link TableCreationBuilder} (allowing to step immediately out of the column
- * building and back to the table building immediately).
- *
- * @author Kasper Sørensen
- */
-public interface ColumnCreationBuilder extends ColumnBuilder<ColumnCreationBuilder>, TableCreationBuilder {
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/create/ColumnCreationBuilderImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/create/ColumnCreationBuilderImpl.java b/core/src/main/java/org/eobjects/metamodel/create/ColumnCreationBuilderImpl.java
deleted file mode 100644
index 9add137..0000000
--- a/core/src/main/java/org/eobjects/metamodel/create/ColumnCreationBuilderImpl.java
+++ /dev/null
@@ -1,63 +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.create;
-
-import org.eobjects.metamodel.MetaModelException;
-import org.eobjects.metamodel.schema.MutableColumn;
-import org.eobjects.metamodel.schema.Table;
-
-/**
- * Implementation of the {@link ColumnCreationBuilder}.
- *
- * @author Kasper Sørensen
- */
-final class ColumnCreationBuilderImpl extends AbstractColumnBuilder<ColumnCreationBuilder> implements ColumnCreationBuilder {
-
- private final TableCreationBuilder _createTableBuilder;
-
- public ColumnCreationBuilderImpl(TableCreationBuilder createTableBuilder, MutableColumn column) {
- super(column);
- _createTableBuilder = createTableBuilder;
- }
-
- @Override
- public String toSql() {
- return _createTableBuilder.toSql();
- }
-
- @Override
- public TableCreationBuilder like(Table table) {
- return _createTableBuilder.like(table);
- }
-
- @Override
- public Table execute() throws MetaModelException {
- return _createTableBuilder.execute();
- }
-
- @Override
- public ColumnCreationBuilder withColumn(String name) {
- return _createTableBuilder.withColumn(name);
- }
-
- @Override
- public Table toTable() {
- return _createTableBuilder.toTable();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/create/CreateTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/create/CreateTable.java b/core/src/main/java/org/eobjects/metamodel/create/CreateTable.java
deleted file mode 100644
index 56e1694..0000000
--- a/core/src/main/java/org/eobjects/metamodel/create/CreateTable.java
+++ /dev/null
@@ -1,67 +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.create;
-
-import org.eobjects.metamodel.DataContext;
-import org.eobjects.metamodel.UpdateCallback;
-import org.eobjects.metamodel.UpdateScript;
-import org.eobjects.metamodel.UpdateableDataContext;
-import org.eobjects.metamodel.schema.MutableColumn;
-import org.eobjects.metamodel.schema.MutableSchema;
-import org.eobjects.metamodel.schema.MutableTable;
-import org.eobjects.metamodel.schema.Schema;
-import org.eobjects.metamodel.schema.TableType;
-
-/**
- * Represents a single CREATE TABLE operation to be applied to a
- * {@link UpdateableDataContext}. Instead of providing a custom implementation
- * of the {@link UpdateScript} interface, one can use this pre-built create
- * table implementation. Some {@link DataContext}s may even optimize
- * specifically based on the knowledge that there will only be a single table
- * created.
- */
-public final class CreateTable implements UpdateScript {
-
- private final MutableTable _table;
-
- public CreateTable(Schema schema, String tableName) {
- _table = new MutableTable(tableName, TableType.TABLE, schema);
- }
-
- public CreateTable(String schemaName, String tableName) {
- _table = new MutableTable(tableName, TableType.TABLE, new MutableSchema(schemaName));
- }
-
- /**
- * Adds a column to the current builder
- *
- * @param name
- * @return
- */
- public ColumnBuilder<CreateTableColumnBuilder> withColumn(String name) {
- MutableColumn column = new MutableColumn(name);
- _table.addColumn(column);
- return new CreateTableColumnBuilder(this, column);
- }
-
- @Override
- public void run(UpdateCallback callback) {
- callback.createTable(_table.getSchema().getName(), _table.getName()).like(_table).execute();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/create/CreateTableColumnBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/create/CreateTableColumnBuilder.java b/core/src/main/java/org/eobjects/metamodel/create/CreateTableColumnBuilder.java
deleted file mode 100644
index e1a6b4a..0000000
--- a/core/src/main/java/org/eobjects/metamodel/create/CreateTableColumnBuilder.java
+++ /dev/null
@@ -1,42 +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.create;
-
-import org.eobjects.metamodel.UpdateCallback;
-import org.eobjects.metamodel.UpdateScript;
-import org.eobjects.metamodel.schema.MutableColumn;
-
-/**
- * Column builder for {@link CreateTable}.
- */
-public final class CreateTableColumnBuilder extends AbstractColumnBuilder<CreateTableColumnBuilder> implements ColumnBuilder<CreateTableColumnBuilder>, UpdateScript {
-
- private final CreateTable _createTable;
-
- public CreateTableColumnBuilder(CreateTable createTable, MutableColumn column) {
- super(column);
- _createTable = createTable;
- }
-
- @Override
- public void run(UpdateCallback callback) {
- _createTable.run(callback);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/create/TableCreatable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/create/TableCreatable.java b/core/src/main/java/org/eobjects/metamodel/create/TableCreatable.java
deleted file mode 100644
index 888c09d..0000000
--- a/core/src/main/java/org/eobjects/metamodel/create/TableCreatable.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.create;
-
-import org.eobjects.metamodel.schema.Schema;
-
-/**
- * Interface for objects that support creating new tables.
- *
- * @author Kasper Sørensen
- */
-public interface TableCreatable {
-
- /**
- * Determines whether table creation is supported
- *
- * @return true if table creation is supported
- */
- public boolean isCreateTableSupported();
-
- /**
- * Initiates the building of a table creation operation.
- *
- * @param schema
- * the schema to create the table in
- * @param name
- * the name of the new table
- * @return a builder object on which the details of the table can be
- * specified and committed.
- * @throws IllegalArgumentException
- * if the table argument is null or invalid.
- * @throws IllegalStateException
- * if the connection to the DataContext is read-only or another
- * access restriction is preventing the operation.
- */
- public TableCreationBuilder createTable(Schema schema, String name) throws IllegalArgumentException,
- IllegalStateException;
-
- /**
- * Initiates the building of a table creation operation.
- *
- * @param schemaName
- * the name of the schema to create the table in
- * @param tableName
- * the name of the new table
- * @return a builder object on which the details of the table can be
- * specified and committed.
- * @throws IllegalArgumentException
- * if the table argument is null or invalid.
- * @throws IllegalStateException
- * if the connection to the DataContext is read-only or another
- * access restriction is preventing the operation.
- */
- public TableCreationBuilder createTable(String schemaName, String tableName) throws IllegalArgumentException,
- IllegalStateException;
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/create/TableCreationBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/create/TableCreationBuilder.java b/core/src/main/java/org/eobjects/metamodel/create/TableCreationBuilder.java
deleted file mode 100644
index 042049a..0000000
--- a/core/src/main/java/org/eobjects/metamodel/create/TableCreationBuilder.java
+++ /dev/null
@@ -1,77 +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.create;
-
-import org.eobjects.metamodel.DataContext;
-import org.eobjects.metamodel.MetaModelException;
-import org.eobjects.metamodel.schema.Table;
-
-/**
- * Builder object for {@link Table} creation.
- *
- * @author Kasper Sørensen
- */
-public interface TableCreationBuilder {
-
- /**
- * Builds this table's columns based on another {@link Table} which will be
- * used as a prototype. Using this method simplifies the creation of a table
- * that is similar to an existing table.
- *
- * @param table
- * the {@link Table} to use as a prototype
- * @return a builder object for further table creation
- */
- public TableCreationBuilder like(Table table);
-
- /**
- * Adds a column to the current builder
- *
- * @param name
- * @return
- */
- public ColumnCreationBuilder withColumn(String name);
-
- /**
- * Returns this builder instance as a table. This allows for inspecting the
- * table that is being built, before it is actually created.
- *
- * @return a temporary representation of the table being built.
- */
- public Table toTable();
-
- /**
- * Gets a SQL representation of this create table operation. Note that the
- * generated SQL is dialect agnostic, so it is not accurately the same as
- * what will be passed to a potential backing database.
- *
- * @return a SQL representation of this create table operation.
- */
- public String toSql();
-
- /**
- * Commits the built table and requests that the table structure should be
- * written to the {@link DataContext}.
- *
- * @return the {@link Table} that was build
- * @throws MetaModelException
- * if the {@link DataContext} was not able to create the table
- */
- public Table execute() throws MetaModelException;
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/create/package-info.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/create/package-info.java b/core/src/main/java/org/eobjects/metamodel/create/package-info.java
deleted file mode 100644
index fef2d9e..0000000
--- a/core/src/main/java/org/eobjects/metamodel/create/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 creating tables
- */
-package org.eobjects.metamodel.create;
-
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/AbstractDataSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/AbstractDataSet.java b/core/src/main/java/org/eobjects/metamodel/data/AbstractDataSet.java
deleted file mode 100644
index 98b9416..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/AbstractDataSet.java
+++ /dev/null
@@ -1,171 +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.Iterator;
-import java.util.List;
-
-import javax.swing.table.TableModel;
-
-import org.eobjects.metamodel.MetaModelHelper;
-import org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.schema.Column;
-import org.eobjects.metamodel.util.BaseObject;
-
-/**
- * Abstract DataSet implementation. Provides convenient implementations of
- * trivial method and reusable parts of non-trivial methods of a DataSet.
- *
- * @author Kasper Sørensen
- */
-public abstract class AbstractDataSet extends BaseObject implements DataSet {
-
- private final DataSetHeader _header;
-
- /**
- * @deprecated use one of the other constructors, to provide header
- * information.
- */
- @Deprecated
- public AbstractDataSet() {
- _header = null;
- }
-
- public AbstractDataSet(SelectItem[] selectItems) {
- this(Arrays.asList(selectItems));
- }
-
- public AbstractDataSet(List<SelectItem> selectItems) {
- this(new CachingDataSetHeader(selectItems));
- }
-
- /**
- * Constructor appropriate for dataset implementations that wrap other
- * datasets, such as the {@link MaxRowsDataSet}, {@link FilteredDataSet} and
- * more.
- *
- * @param dataSet
- */
- public AbstractDataSet(DataSet dataSet) {
- if (dataSet instanceof AbstractDataSet) {
- _header = ((AbstractDataSet) dataSet).getHeader();
- } else {
- _header = new CachingDataSetHeader(Arrays.asList(dataSet.getSelectItems()));
- }
- }
-
- public AbstractDataSet(DataSetHeader header) {
- _header = header;
- }
-
- public AbstractDataSet(Column[] columns) {
- this(MetaModelHelper.createSelectItems(columns));
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public SelectItem[] getSelectItems() {
- return getHeader().getSelectItems();
- }
-
- protected DataSetHeader getHeader() {
- return _header;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final int indexOf(SelectItem item) {
- return getHeader().indexOf(item);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void close() {
- // do nothing
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final TableModel toTableModel() {
- TableModel tableModel = new DataSetTableModel(this);
- return tableModel;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public final List<Object[]> toObjectArrays() {
- try {
- List<Object[]> objects = new ArrayList<Object[]>();
- while (next()) {
- Row row = getRow();
- objects.add(row.getValues());
- }
- return objects;
- } finally {
- close();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return "DataSet[selectItems=" + Arrays.toString(getSelectItems()) + "]";
- }
-
- @Override
- protected void decorateIdentity(List<Object> identifiers) {
- identifiers.add(getClass());
- identifiers.add(getSelectItems());
- }
-
- @Override
- public List<Row> toRows() {
- try {
- List<Row> result = new ArrayList<Row>();
- while (next()) {
- result.add(getRow());
- }
- return result;
- } finally {
- close();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Iterator<Row> iterator() {
- return new DataSetIterator(this);
- }
-}
\ 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/AbstractRow.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/AbstractRow.java b/core/src/main/java/org/eobjects/metamodel/data/AbstractRow.java
deleted file mode 100644
index a879454..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/AbstractRow.java
+++ /dev/null
@@ -1,176 +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 org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.schema.Column;
-
-/**
- * An abstract row that decorates another row. Useful for virtual data that may
- * e.g. be converting physical data etc.
- */
-public abstract class AbstractRow implements Cloneable, Row {
-
- private static final long serialVersionUID = 1L;
-
- protected abstract DataSetHeader getHeader();
-
- @Override
- public final int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + Arrays.hashCode(getValues());
- 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;
- Row other = (Row) obj;
- if (!Arrays.equals(getValues(), other.getValues()))
- return false;
- return true;
- }
-
- @Override
- public final String toString() {
- return "Row[values=" + Arrays.toString(getValues()) + "]";
- }
-
- @Override
- public final Object getValue(SelectItem item) {
- int index = indexOf(item);
- if (index == -1) {
- return null;
- }
- return getValue(index);
- }
-
- @Override
- public final Style getStyle(SelectItem item) {
- int index = indexOf(item);
- if (index == -1) {
- return Style.NO_STYLE;
- }
- return getStyle(index);
- }
-
- @Override
- public final Style getStyle(Column column) {
- int index = indexOf(column);
- if (index == -1) {
- return Style.NO_STYLE;
- }
- return getStyle(index);
- }
-
- @Override
- public Object[] getValues() {
- final Object[] values = new Object[size()];
- for (int i = 0; i < values.length; i++) {
- values[i] = getValue(i);
- }
- return values;
- }
-
- @Override
- public final Object getValue(Column column) {
- int index = indexOf(column);
- if (index == -1) {
- return null;
- }
- return getValue(index);
- }
-
- @Override
- public final int indexOf(SelectItem item) {
- if (item == null) {
- return -1;
- }
- return getHeader().indexOf(item);
- }
-
- @Override
- public final int indexOf(Column column) {
- if (column == null) {
- return -1;
- }
- return getHeader().indexOf(column);
- }
-
- @Override
- public Row getSubSelection(final SelectItem[] selectItems) {
- final DataSetHeader header = new SimpleDataSetHeader(selectItems);
- return getSubSelection(header);
- }
-
- @Override
- public final SelectItem[] getSelectItems() {
- return getHeader().getSelectItems();
- }
-
- @Override
- public final int size() {
- return getHeader().size();
- }
-
- @Override
- public Style[] getStyles() {
- final Style[] styles = new Style[size()];
- for (int i = 0; i < styles.length; i++) {
- styles[i] = getStyle(i);
- }
- return styles;
- }
-
- @Override
- protected Row clone() {
- return new DefaultRow(getHeader(), getValues(), getStyles());
- }
-
- @Override
- public final Row getSubSelection(DataSetHeader header) {
- final int size = header.size();
- final Object[] values = new Object[size];
- final Style[] styles = new Style[size];
- for (int i = 0; i < size; i++) {
- final SelectItem selectItem = header.getSelectItem(i);
-
- if (selectItem.getSubQuerySelectItem() != null) {
- values[i] = getValue(selectItem.getSubQuerySelectItem());
- styles[i] = getStyle(selectItem.getSubQuerySelectItem());
- if (values[i] == null) {
- values[i] = getValue(selectItem);
- styles[i] = getStyle(selectItem);
- }
- } else {
- values[i] = getValue(selectItem);
- styles[i] = getStyle(selectItem);
- }
- }
- return new DefaultRow(header, values, styles);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/AbstractRowBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/AbstractRowBuilder.java b/core/src/main/java/org/eobjects/metamodel/data/AbstractRowBuilder.java
deleted file mode 100644
index b02fd8e..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/AbstractRowBuilder.java
+++ /dev/null
@@ -1,146 +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 org.eobjects.metamodel.schema.Column;
-import org.eobjects.metamodel.schema.Table;
-
-/**
- * Abstract {@link RowBuilder} implementation.
- */
-public abstract class AbstractRowBuilder<RB extends RowBuilder<?>> implements RowBuilder<RB> {
-
- private final Column[] _columns;
- private final Object[] _values;
- private final Style[] _styles;
- private final boolean[] _explicitNulls;
-
- public AbstractRowBuilder(Table table) {
- this(table.getColumns());
- }
-
- public AbstractRowBuilder(Column[] columns) {
- _columns = columns;
- _explicitNulls = new boolean[_columns.length];
- _values = new Object[_columns.length];
- _styles = new Style[_columns.length];
- }
-
- /**
- * Gets a boolean array indicating if any of the values have been explicitly
- * set to null (as opposed to just not set)
- *
- * @return
- */
- protected boolean[] getExplicitNulls() {
- return _explicitNulls;
- }
-
- protected Object[] getValues() {
- return _values;
- }
-
- protected Column[] getColumns() {
- return _columns;
- }
-
- protected Style[] getStyles() {
- return _styles;
- }
-
- @Override
- public final Row toRow() {
- return new DefaultRow(new SimpleDataSetHeader(_columns), _values);
- }
-
- @Override
- public final RB value(Column column, Object value) {
- return value(column, value, null);
- }
-
- @Override
- public RB value(Column column, Object value, Style style) {
- if (column == null) {
- throw new IllegalArgumentException("Column cannot be null");
- }
- boolean written = false;
- for (int i = 0; i < _columns.length; i++) {
- if (_columns[i].equals(column)) {
- value(i, value, style);
- written = true;
- break;
- }
- }
- if (!written) {
- throw new IllegalArgumentException("No such column in table: " + column);
- }
-
- @SuppressWarnings("unchecked")
- RB result = (RB) this;
- return result;
- }
-
- @Override
- public RB value(int columnIndex, Object value) {
- return value(columnIndex, value, null);
- }
-
- @Override
- public final RB value(int columnIndex, Object value, Style style) {
- _values[columnIndex] = value;
- _styles[columnIndex] = style;
- _explicitNulls[columnIndex] = (value == null);
-
- @SuppressWarnings("unchecked")
- RB result = (RB) this;
- return result;
- }
-
- @Override
- public RB value(String columnName, Object value) {
- return value(columnName, value, null);
- }
-
- @Override
- public final RB value(String columnName, Object value, Style style) {
- if (columnName == null) {
- throw new IllegalArgumentException("Column name cannot be null");
- }
- for (int i = 0; i < _columns.length; i++) {
- Column column = _columns[i];
- if (column.getName().equalsIgnoreCase(columnName)) {
- return value(i, value, style);
- }
- }
- throw new IllegalArgumentException("No such column in table: " + columnName + ", available columns are: "
- + Arrays.toString(_columns));
- }
-
- @Override
- public boolean isSet(Column column) {
- for (int i = 0; i < _columns.length; i++) {
- if (_columns[i].equals(column)) {
- return _values[i] != null || _explicitNulls[i];
- }
- }
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/CachingDataSetHeader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/CachingDataSetHeader.java b/core/src/main/java/org/eobjects/metamodel/data/CachingDataSetHeader.java
deleted file mode 100644
index 25bad2b..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/CachingDataSetHeader.java
+++ /dev/null
@@ -1,96 +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 java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.eobjects.metamodel.query.SelectItem;
-import org.eobjects.metamodel.schema.Column;
-
-/**
- * Most common implementation of {@link DataSetHeader}. This implementation is
- * 'caching' in the sense that index values of selectitems are cached in a map
- * to provide quick access when looking up by {@link SelectItem} or
- * {@link Column}.
- */
-public final class CachingDataSetHeader extends SimpleDataSetHeader implements DataSetHeader {
-
- private static final long serialVersionUID = 1L;
-
- // map of select item identity codes and indexes in the dataset
- private transient Map<Integer, Integer> _selectItemIndexCache;
-
- // map of column identity codes and indexes in the dataset
- private transient Map<Integer, Integer> _columnIndexCache;
-
- public CachingDataSetHeader(List<SelectItem> items) {
- super(items);
- }
-
- public CachingDataSetHeader(SelectItem[] items) {
- this(Arrays.asList(items));
- }
-
- @Override
- public int indexOf(Column column) {
- if (column == null) {
- return -1;
- }
-
- if (_columnIndexCache == null) {
- _columnIndexCache = new ConcurrentHashMap<Integer, Integer>(super.size());
- }
-
- final int identityCode = System.identityHashCode(column);
- Integer index = _columnIndexCache.get(identityCode);
- if (index == null) {
- index = super.indexOf(column);
-
- if (index != -1) {
- _columnIndexCache.put(identityCode, index);
- }
- }
- return index;
- }
-
- @Override
- public final int indexOf(SelectItem item) {
- if (item == null) {
- return -1;
- }
-
- if (_selectItemIndexCache == null) {
- _selectItemIndexCache = new ConcurrentHashMap<Integer, Integer>(super.size());
- }
-
- final int identityCode = System.identityHashCode(item);
- Integer index = _selectItemIndexCache.get(identityCode);
- if (index == null) {
- index = super.indexOf(item);
-
- if (index != -1) {
- _selectItemIndexCache.put(identityCode, index);
- }
- }
- return index;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/ColorImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/ColorImpl.java b/core/src/main/java/org/eobjects/metamodel/data/ColorImpl.java
deleted file mode 100644
index be2d14c..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/ColorImpl.java
+++ /dev/null
@@ -1,77 +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.data.Style.Color;
-import org.eobjects.metamodel.util.BaseObject;
-
-final class ColorImpl extends BaseObject implements Color {
-
- private static final long serialVersionUID = 1L;
-
- private final short _red;
- private final short _green;
- private final short _blue;
-
- public ColorImpl(short red, short green, short blue) {
- checkRange(red);
- checkRange(green);
- checkRange(blue);
- _red = red;
- _green = green;
- _blue = blue;
- }
-
- private void checkRange(short rgbComponent) throws IllegalArgumentException {
- if (rgbComponent < 0 || rgbComponent > 255) {
- throw new IllegalArgumentException(
- "All RGB components must be between 0 and 255. Found: "
- + rgbComponent);
- }
- }
-
- @Override
- public short getRed() {
- return _red;
- }
-
- @Override
- public short getGreen() {
- return _green;
- }
-
- @Override
- public short getBlue() {
- return _blue;
- }
-
- @Override
- protected void decorateIdentity(List<Object> identifiers) {
- identifiers.add(_red);
- identifiers.add(_green);
- identifiers.add(_blue);
- }
-
- @Override
- public String toString() {
- return "Color[" + _red + "," + _green + "," + _blue + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-metamodel/blob/e2e2b37a/core/src/main/java/org/eobjects/metamodel/data/DataSet.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/eobjects/metamodel/data/DataSet.java b/core/src/main/java/org/eobjects/metamodel/data/DataSet.java
deleted file mode 100644
index dc471b8..0000000
--- a/core/src/main/java/org/eobjects/metamodel/data/DataSet.java
+++ /dev/null
@@ -1,99 +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.Closeable;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.swing.table.TableModel;
-
-import org.eobjects.metamodel.query.SelectItem;
-
-/**
- * Represents a tabular DataSet where values are bound to columns and rows. A
- * DataSet works similarly to a slightly modularized ResultSet when you traverse
- * it - use the next() method to loop through the rows of the DataSet and use
- * the getRow() method to get the current row.
- *
- * @author Kasper Sørensen
- */
-public interface DataSet extends Closeable, Iterable<Row> {
-
- /**
- * @return the SelectItems that represent the columns of this DataSet
- */
- public SelectItem[] getSelectItems();
-
- /**
- * Finds the index of a given SelectItem
- *
- * @param item
- * @return the index (0-based) of the SelectItem or -1 if the SelectItem
- * doesn't exist in this DataSet.
- */
- public int indexOf(SelectItem item);
-
- /**
- * Moves forward to the next row.
- *
- * @return true if there is a next row or false if not.
- */
- public boolean next();
-
- /**
- * @return the current row.
- */
- public Row getRow();
-
- /**
- * Closes the DataSet and any resources it may be holding.
- */
- @Override
- public void close();
-
- /**
- * Converts the DataSet into a TableModel (will load all values into memory).
- *
- * @deprecated instantiate a new {@link DataSetTableModel} instead.
- */
- @Deprecated
- public TableModel toTableModel();
-
- /**
- * Converts the DataSet into a list of object arrays (will load all values
- * into memory)
- */
- public List<Object[]> toObjectArrays();
-
- /**
- * Converts the DataSet into a list of rows (will load all rows into memory)
- */
- public List<Row> toRows();
-
- /**
- * Converts the DataSet into an Iterator. Note that unlike many
- * {@link Iterable} objects, {@link DataSet}s are unlikely to allow creation
- * of multiple iterators without risking loss of data in each individual
- * iteration loop.
- */
- @Override
- public Iterator<Row> iterator();
-
-}
\ No newline at end of file