git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/mutateops@1000 f203690c-595d-4dc9-a70b-905162fa7fd2tags/jackcess-2.1.5
@@ -25,10 +25,13 @@ import com.healthmarketscience.jackcess.impl.ColumnImpl; | |||
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_ | |||
@@ -472,6 +475,15 @@ public class ColumnBuilder { | |||
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() + ")"; | |||
} |
@@ -16,6 +16,7 @@ limitations under the License. | |||
package com.healthmarketscience.jackcess; | |||
import java.io.IOException; | |||
import java.util.ArrayList; | |||
import java.util.HashSet; | |||
import java.util.List; | |||
@@ -25,10 +26,13 @@ import com.healthmarketscience.jackcess.impl.DatabaseImpl; | |||
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_ | |||
@@ -185,6 +189,15 @@ public class IndexBuilder | |||
} | |||
} | |||
/** | |||
* 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() + ")"; | |||
} |
@@ -1,71 +0,0 @@ | |||
/* | |||
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); | |||
} | |||
} | |||
} |