import com.healthmarketscience.jackcess.impl.DatabaseImpl;
import com.healthmarketscience.jackcess.impl.JetFormat;
import com.healthmarketscience.jackcess.impl.PropertyMapImpl;
+import com.healthmarketscience.jackcess.impl.TableImpl;
+import com.healthmarketscience.jackcess.impl.TableMutator;
/**
* Builder style class for constructing a {@link Column}. See {@link
- * TableBuilder} for example usage.
+ * TableBuilder} for example usage. Additionally, a Column can be added to an
+ * existing Table using the {@link #addToTable(Table)} method.
*
* @author James Ahlborn
* @usage _general_class_
return this;
}
+ /**
+ * Adds a new Column to the given Table with the currently configured
+ * attributes.
+ */
+ public Column addToTable(Table table) throws IOException
+ {
+ return new TableMutator((TableImpl)table).addColumn(this);
+ }
+
private String withErrorContext(String msg) {
return msg + "(Column=" + getName() + ")";
}
package com.healthmarketscience.jackcess;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import com.healthmarketscience.jackcess.impl.IndexData;
import com.healthmarketscience.jackcess.impl.IndexImpl;
import com.healthmarketscience.jackcess.impl.JetFormat;
+import com.healthmarketscience.jackcess.impl.TableImpl;
+import com.healthmarketscience.jackcess.impl.TableMutator;
/**
* Builder style class for constructing an {@link Index}. See {@link
- * TableBuilder} for example usage.
+ * TableBuilder} for example usage. Additionally, an Index can be added to an
+ * existing Table using the {@link #addToTable(Table)} method.
*
* @author James Ahlborn
* @usage _general_class_
}
}
+ /**
+ * Adds a new Index to the given Table with the currently configured
+ * attributes.
+ */
+ public Index addToTable(Table table) throws IOException
+ {
+ return new TableMutator((TableImpl)table).addIndex(this);
+ }
+
private String withErrorContext(String msg) {
return msg + "(Index=" + getName() + ")";
}
+++ /dev/null
-/*
-Copyright (c) 2016 James Ahlborn
-
-Licensed 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 com.healthmarketscience.jackcess;
-
-import java.io.IOException;
-
-import com.healthmarketscience.jackcess.impl.TableImpl;
-import com.healthmarketscience.jackcess.impl.TableMutator;
-
-/**
- *
- * @author James Ahlborn
- */
-public class TableModBuilder
-{
- private Table _table;
-
- public TableModBuilder(Table table) {
- _table = table;
- }
-
- public AddColumn addColumn(ColumnBuilder column) {
- return new AddColumn(column);
- }
-
- public AddIndex addIndex(IndexBuilder index) {
- return new AddIndex(index);
- }
-
- public class AddColumn
- {
- private ColumnBuilder _column;
-
- private AddColumn(ColumnBuilder column) {
- _column = column;
- }
-
- public Column add() throws IOException
- {
- return new TableMutator((TableImpl)_table).addColumn(_column);
- }
- }
-
- public class AddIndex
- {
- private IndexBuilder _index;
-
- private AddIndex(IndexBuilder index) {
- _index = index;
- }
-
- public Index add() throws IOException
- {
- return new TableMutator((TableImpl)_table).addIndex(_index);
- }
- }
-}