1 /* 2 Copyright (c) 2022 James Ahlborn 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package com.healthmarketscience.jackcess.impl; 18 19 import java.io.IOException; 20 import java.nio.ByteBuffer; 21 import java.util.List; 22 23 /** 24 * A database table definition which does not allow any actual data 25 * interaction (read or write). 26 * <p> 27 * Note, in an ideal world, TableImpl would extend TableDefinitionImpl. 28 * However, since TableDefinitionImpl came later, it was easier to do it this 29 * way and avoid a lot of unnecessary code shuffling. 30 * <p> 31 * Is not thread-safe. 32 * 33 * @author James Ahlborn 34 * @usage _advanced_class_ 35 */ 36 public class TableDefinitionImpl extends TableImpl 37 { 38 protected TableDefinitionImpl(DatabaseImpl database, ByteBuffer tableBuffer, 39 int pageNumber, String name, int flags) 40 throws IOException { 41 super(database, tableBuffer, pageNumber, name, flags); 42 } 43 44 @Override 45 protected List<? extends Object[]> addRows(List<? extends Object[]> rows, 46 final boolean isBatchWrite) 47 throws IOException { 48 // all row additions eventually flow through this method 49 throw new UnsupportedOperationException( 50 withErrorContext("TableDefinition has no data access")); 51 } 52 53 @Override 54 public RowState createRowState() { 55 // RowState is needed for all traversal operations, so this kills any data 56 // reading as well as update/delete methods 57 throw new UnsupportedOperationException( 58 withErrorContext("TableDefinition has no data access")); 59 } 60 }