Skip to content

Commit

Permalink
Remove redundant throws clauses
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Feb 27, 2024
1 parent dbd1eea commit 432875f
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ protected ByteBuffer writeRealData(Object obj, int remainingRowLength,
private static class CalcTextColImpl extends TextColumnImpl {
private CalcColEvalContext _calcCol;

CalcTextColImpl(InitArgs args) throws IOException {
CalcTextColImpl(InitArgs args) {
super(args);
}

Expand Down Expand Up @@ -302,7 +302,7 @@ protected ByteBuffer writeLongValue(byte[] value, int remainingRowLength)
private static class CalcNumericColImpl extends NumericColumnImpl {
private CalcColEvalContext _calcCol;

CalcNumericColImpl(InitArgs args) throws IOException {
CalcNumericColImpl(InitArgs args) {
super(args);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/spannm/jackcess/impl/IndexData.java
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ protected void readDataPage(DataPage dataPage) throws IOException {
/**
* Returns a new Entry of the correct type for the given data and page type.
*/
private static Entry newEntry(ByteBuffer buffer, int entryLength, boolean isLeaf) throws IOException {
private static Entry newEntry(ByteBuffer buffer, int entryLength, boolean isLeaf) {
if (isLeaf) {
return new Entry(buffer, entryLength);
}
Expand Down Expand Up @@ -1561,7 +1561,7 @@ protected void writeNonNullValue(Object value, ByteStream bout) throws IOExcepti
* ColumnDescriptor for new-style fixed point based columns.
*/
private static final class FixedPointColumnDescriptor extends LegacyFixedPointColumnDescriptor {
private FixedPointColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private FixedPointColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

import static io.github.spannm.jackcess.impl.IndexData.*;

import io.github.spannm.jackcess.impl.IndexData.DataPage;
import io.github.spannm.jackcess.impl.IndexData.Entry;
import io.github.spannm.jackcess.util.ToStringBuilder;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package io.github.spannm.jackcess.impl;

import java.io.IOException;

/**
* ColumnImpl subclass which is used for Memo data types.
*
Expand All @@ -39,7 +37,7 @@ class MemoColumnImpl extends LongValueColumnImpl {
*/
private final boolean _hyperlink;

MemoColumnImpl(InitArgs args) throws IOException {
MemoColumnImpl(InitArgs args) {
super(args);

// co-located w/ precision/scale
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/io/github/spannm/jackcess/impl/UsageMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,7 @@ private void moveToNewStartPageForRemove(int firstPage, int newPageNumber)
*/
private class ReferenceHandler extends Handler {
/** Buffer that contains the current reference map page */
private final TempPageHolder _mapPageHolder =
TempPageHolder.newHolder(TempBufferHolder.Type.SOFT);
private final TempPageHolder _mapPageHolder = TempPageHolder.newHolder(TempBufferHolder.Type.SOFT);
private final int _maxPagesPerUsageMapPage;

private ReferenceHandler() throws IOException {
Expand Down
80 changes: 36 additions & 44 deletions src/main/java/io/github/spannm/jackcess/util/ImportUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -383,57 +383,52 @@ public static String importReader(BufferedReader in, Database db, String name, S

Pattern delimPat = Pattern.compile(delim);

try {
name = TableBuilder.escapeIdentifier(name);
Table table = null;
if (!useExistingTable || (table = db.getTable(name)) == null) {
name = TableBuilder.escapeIdentifier(name);
Table table = null;
if (!useExistingTable || (table = db.getTable(name)) == null) {

List<ColumnBuilder> columns = new ArrayList<>();
Object[] columnNames = splitLine(line, delimPat, quote, in, 0);
List<ColumnBuilder> columns = new ArrayList<>();
Object[] columnNames = splitLine(line, delimPat, quote, in, 0);

for (Object columnName : columnNames) {
columns.add(new ColumnBuilder((String) columnName, DataType.TEXT).escapeName().withLength((short) DataType.TEXT.getMaxSize()).toColumn());
}
for (Object columnName : columnNames) {
columns.add(new ColumnBuilder((String) columnName, DataType.TEXT).escapeName().withLength((short) DataType.TEXT.getMaxSize()).toColumn());
}

table = createUniqueTable(db, name, columns, null, filter);
table = createUniqueTable(db, name, columns, null, filter);

// the first row was a header row
header = true;
}
// the first row was a header row
header = true;
}

List<Object[]> rows = new ArrayList<>(COPY_TABLE_BATCH_SIZE);
int numColumns = table.getColumnCount();
List<Object[]> rows = new ArrayList<>(COPY_TABLE_BATCH_SIZE);
int numColumns = table.getColumnCount();

if (!header) {
// first line is _not_ a header line
Object[] data = splitLine(line, delimPat, quote, in, numColumns);
data = filter.filterRow(data);
if (data != null) {
rows.add(data);
}
if (!header) {
// first line is _not_ a header line
Object[] data = splitLine(line, delimPat, quote, in, numColumns);
data = filter.filterRow(data);
if (data != null) {
rows.add(data);
}
}

while ((line = in.readLine()) != null) {
Object[] data = splitLine(line, delimPat, quote, in, numColumns);
data = filter.filterRow(data);
if (data == null) {
continue;
}
rows.add(data);
if (rows.size() == COPY_TABLE_BATCH_SIZE) {
table.addRows(rows);
rows.clear();
}
while ((line = in.readLine()) != null) {
Object[] data = splitLine(line, delimPat, quote, in, numColumns);
data = filter.filterRow(data);
if (data == null) {
continue;
}
if (!rows.isEmpty()) {
rows.add(data);
if (rows.size() == COPY_TABLE_BATCH_SIZE) {
table.addRows(rows);
rows.clear();
}

return table.getName();

} catch (SQLException e) {
throw new IOException(e.getMessage(), e);
}
if (!rows.isEmpty()) {
table.addRows(rows);
}

return table.getName();
}

/**
Expand Down Expand Up @@ -516,11 +511,8 @@ private static Object[] splitLine(String line, Pattern delim, char quote,
/**
* Returns a new table with a unique name and the given table definition.
*/
private static Table createUniqueTable(Database db, String name,
List<ColumnBuilder> columns,
ResultSetMetaData md,
ImportFilter filter)
throws IOException, SQLException {
private static Table createUniqueTable(Database db, String name, List<ColumnBuilder> columns,
ResultSetMetaData md, ImportFilter filter) throws IOException {
// otherwise, find unique name and create new table
String baseName = name;
int counter = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ private static int getNumChunks(long size) {
}

@Override
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException {
public long write(ByteBuffer[] srcs, int offset, int length) {
long numBytes = 0L;
for (int i = offset; i < offset + length; ++i) {
numBytes += write(srcs[i]);
Expand All @@ -417,7 +417,7 @@ public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
}

@Override
public long read(ByteBuffer[] dsts, int offset, int length) throws IOException {
public long read(ByteBuffer[] dsts, int offset, int length) {
long numBytes = 0L;
for (int i = offset; i < offset + length; ++i) {
if (_position >= _size) {
Expand Down
17 changes: 8 additions & 9 deletions src/test/java/io/github/spannm/jackcess/TableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@
*/
class TableTest extends AbstractBaseTest {

private final PageChannel _pageChannel = new PageChannel(true) {
};
private List<ColumnImpl> _columns = new ArrayList<>();
private TestTable _testTable;
private int _varLenIdx;
private int _fixedOffset;
private final PageChannel _pageChannel = new PageChannel(true) {
};
private final List<ColumnImpl> _columns = new ArrayList<>();
private TestTable _testTable;
private int _varLenIdx;
private int _fixedOffset;

private void reset() {
_testTable = null;
_columns = new ArrayList<>();
_columns.clear();
_varLenIdx = 0;
_fixedOffset = 0;
}
Expand Down Expand Up @@ -142,8 +142,7 @@ private static byte[] toBytes(ByteBuffer buffer) {
return b;
}

private TableImpl newTestTable()
throws Exception {
private TableImpl newTestTable() {
_testTable = new TestTable();
return _testTable;
}
Expand Down

0 comments on commit 432875f

Please sign in to comment.