Skip to content

Commit

Permalink
Remove redundant throws
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Feb 16, 2024
1 parent 5259be8 commit cb9c8e3
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 95 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/github/spannm/jackcess/Row.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ public interface Row extends Map<String, Object> {
* <p>
* Note, <i>the OleBlob should be closed after use</i>.
*/
OleBlob getBlob(String name) throws IOException;
OleBlob getBlob(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private static ByteBuffer prepareWrappedCalcValue(int dataLen, ByteOrder order)
private static class CalcColImpl extends ColumnImpl {
private CalcColEvalContext _calcCol;

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

Expand Down Expand Up @@ -175,7 +175,7 @@ protected ByteBuffer writeRealData(Object obj, int remainingRowLength,
private static class CalcBooleanColImpl extends ColumnImpl {
private CalcColEvalContext _calcCol;

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

Expand Down Expand Up @@ -241,7 +241,7 @@ protected int calcLengthInUnits() {
}

@Override
public Object read(byte[] data, ByteOrder order) throws IOException {
public Object read(byte[] data, ByteOrder order) {
return decodeTextValue(unwrapCalculatedValue(data));
}

Expand Down
6 changes: 2 additions & 4 deletions src/main/java/io/github/spannm/jackcess/impl/ColumnImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1875,8 +1875,7 @@ public static boolean isRawData(Object value) {
*
* @param buffer Buffer to write to
*/
protected static void writeDefinitions(TableCreator creator, ByteBuffer buffer)
throws IOException {
protected static void writeDefinitions(TableCreator creator, ByteBuffer buffer) {
// we specifically put the "long variable" values after the normal
// variable length values so that we have a better chance of fitting it
// all (because "long variable" values can go in separate pages)
Expand Down Expand Up @@ -1961,8 +1960,7 @@ protected static void writeDefinition(
}

protected static void writeColUsageMapDefinitions(
TableCreator creator, ByteBuffer buffer)
throws IOException {
TableCreator creator, ByteBuffer buffer) {
// write long value column usage map references
for (ColumnBuilder lvalCol : creator.getLongValueColumns()) {
writeColUsageMapDefinition(creator, lvalCol, buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,7 @@ private static void writeUnprintableCodes(
/**
* Encode the given crazy code bytes into the given byte stream.
*/
private static void writeCrazyCodes(ByteStream crazyCodes, ByteStream bout)
throws IOException {
private static void writeCrazyCodes(ByteStream crazyCodes, ByteStream bout) {
// CRAZY_CODE_2 flags at the end are ignored, so ditch them
trimExtraCodes(crazyCodes, CRAZY_CODE_2, CRAZY_CODE_2);

Expand Down
28 changes: 14 additions & 14 deletions src/main/java/io/github/spannm/jackcess/impl/IndexData.java
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ public String toString() {
* ColumnDescriptor for integer based columns.
*/
private static final class IntegerColumnDescriptor extends ColumnDescriptor {
private IntegerColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private IntegerColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand All @@ -1492,7 +1492,7 @@ protected void writeNonNullValue(Object value, ByteStream bout) throws IOExcepti
* ColumnDescriptor for floating point based columns.
*/
private static final class FloatingPointColumnDescriptor extends ColumnDescriptor {
private FloatingPointColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private FloatingPointColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand Down Expand Up @@ -1525,7 +1525,7 @@ protected void writeNonNullValue(Object value, ByteStream bout) throws IOExcepti
* ColumnDescriptor for fixed point based columns (legacy sort order).
*/
private static class LegacyFixedPointColumnDescriptor extends ColumnDescriptor {
private LegacyFixedPointColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private LegacyFixedPointColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand Down Expand Up @@ -1588,7 +1588,7 @@ protected void handleNegationAndOrder(boolean isNegative, byte[] valueBytes) {
* ColumnDescriptor for byte based columns.
*/
private static final class ByteColumnDescriptor extends ColumnDescriptor {
private ByteColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private ByteColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand All @@ -1611,7 +1611,7 @@ protected void writeNonNullValue(Object value, ByteStream bout) throws IOExcepti
* ColumnDescriptor for boolean columns.
*/
private static final class BooleanColumnDescriptor extends ColumnDescriptor {
private BooleanColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private BooleanColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand All @@ -1631,7 +1631,7 @@ protected void writeNonNullValue(Object value, ByteStream bout) {
* ColumnDescriptor for "general legacy" sort order text based columns.
*/
private static final class GenLegTextColumnDescriptor extends ColumnDescriptor {
private GenLegTextColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private GenLegTextColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand All @@ -1645,7 +1645,7 @@ protected void writeNonNullValue(Object value, ByteStream bout) throws IOExcepti
* ColumnDescriptor for "general" sort order (2010+) text based columns.
*/
private static final class GenTextColumnDescriptor extends ColumnDescriptor {
private GenTextColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private GenTextColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand All @@ -1659,7 +1659,7 @@ protected void writeNonNullValue(Object value, ByteStream bout) throws IOExcepti
* ColumnDescriptor for "general 97" sort order text based columns.
*/
private static final class Gen97TextColumnDescriptor extends ColumnDescriptor {
private Gen97TextColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private Gen97TextColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand All @@ -1673,7 +1673,7 @@ protected void writeNonNullValue(Object value, ByteStream bout) throws IOExcepti
* ColumnDescriptor for guid columns.
*/
private static final class GuidColumnDescriptor extends ColumnDescriptor {
private GuidColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private GuidColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand All @@ -1687,7 +1687,7 @@ protected void writeNonNullValue(Object value, ByteStream bout) throws IOExcepti
* ColumnDescriptor for BINARY columns.
*/
private static final class BinaryColumnDescriptor extends ColumnDescriptor {
private BinaryColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private BinaryColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand All @@ -1701,7 +1701,7 @@ protected void writeNonNullValue(Object value, ByteStream bout) throws IOExcepti
* ColumnDescriptor for extended date/time based columns.
*/
private static final class ExtDateColumnDescriptor extends ColumnDescriptor {
private ExtDateColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private ExtDateColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand Down Expand Up @@ -1737,7 +1737,7 @@ protected void writeNonNullValue(Object value, ByteStream bout) throws IOExcepti
* ColumnDescriptor for columns which we cannot currently write.
*/
private final class ReadOnlyColumnDescriptor extends ColumnDescriptor {
private ReadOnlyColumnDescriptor(ColumnImpl column, byte flags) throws IOException {
private ReadOnlyColumnDescriptor(ColumnImpl column, byte flags) {
super(column, flags);
}

Expand Down Expand Up @@ -1784,7 +1784,7 @@ private Entry(byte[] entryBytes, RowIdImpl rowId) {
/**
* Read an existing entry in from a buffer
*/
private Entry(ByteBuffer buffer, int entryLen) throws IOException {
private Entry(ByteBuffer buffer, int entryLen) {
this(buffer, entryLen, 0);
}

Expand Down Expand Up @@ -1961,7 +1961,7 @@ private NodeEntry(byte[] entryBytes, RowIdImpl rowId, EntryType type, Integer su
/**
* Read an existing node entry in from a buffer
*/
private NodeEntry(ByteBuffer buffer, int entryLen) throws IOException {
private NodeEntry(ByteBuffer buffer, int entryLen) {
// we need 4 trailing bytes for the sub-page number
super(buffer, entryLen, 4);

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/io/github/spannm/jackcess/impl/IndexImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,7 @@ public int compareTo(IndexImpl other) {
* @param buffer Buffer to write to
*/
protected static void writeDefinitions(
TableCreator creator, ByteBuffer buffer)
throws IOException {
TableCreator creator, ByteBuffer buffer) {
// write logical index information
for (IndexBuilder idx : creator.getIndexes()) {
writeDefinition(creator, idx, buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class LongValueColumnImpl extends ColumnImpl {
private LongValueBufferHolder _lvalBufferH;
private int _maxLenInUnits = INVALID_LENGTH;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NumericColumnImpl extends ColumnImpl {
/** Numeric scale */
private final byte _scale;

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

_precision = args.buffer.get(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/spannm/jackcess/impl/RowImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public ComplexValueForeignKey getForeignKey(String name) {
}

@Override
public OleBlob getBlob(String name) throws IOException {
public OleBlob getBlob(String name) {
byte[] bytes = getBytes(name);
return bytes != null ? OleBlob.Builder.fromInternalData(bytes) : null;
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/io/github/spannm/jackcess/impl/TableImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3079,8 +3079,7 @@ boolean isThisTable(Identifier identifier) {
* Returns {@code true} if a row of the given size will fit on the given data page, {@code false} otherwise.
*/
public static boolean rowFitsOnDataPage(
int rowLength, ByteBuffer dataPage, JetFormat format)
throws IOException {
int rowLength, ByteBuffer dataPage, JetFormat format) {
int rowSpaceUsage = getRowSpaceUsage(rowLength, format);
short freeSpaceInPage = dataPage.getShort(format.OFFSET_FREE_SPACE);
int rowsOnPage = getRowsOnDataPage(dataPage, format);
Expand Down Expand Up @@ -3305,7 +3304,7 @@ public Object[] getRowCacheValues() {
return dupeRow(_rowValues, _rowValues.length);
}

public NullMask getNullMask(ByteBuffer rowBuffer) throws IOException {
public NullMask getNullMask(ByteBuffer rowBuffer) {
if (_nullMask == null) {
_nullMask = getRowNullMask(rowBuffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TextColumnImpl extends ColumnImpl {
/** the code page for a text field (for certain db versions) */
private final short _codePage;

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

// co-located w/ precision/scale
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class UnsupportedColumnImpl extends ColumnImpl {
private final byte _originalType;

UnsupportedColumnImpl(InitArgs args) throws IOException {
UnsupportedColumnImpl(InitArgs args) {
super(args);
_originalType = args.colType;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/spannm/jackcess/impl/UsageMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ protected final void moveToNewStartPage(int newStartPage, int newPageNumber)
* should be called by PageChannel.
*/
private class GlobalInlineHandler extends InlineHandler {
private GlobalInlineHandler() throws IOException {
private GlobalInlineHandler() {
}

@Override
Expand Down Expand Up @@ -774,7 +774,7 @@ private class GlobalReferenceHandler extends ReferenceHandler {
private boolean _allocatingPage;
private Integer _pendingPage;

private GlobalReferenceHandler() throws IOException {
private GlobalReferenceHandler() {
}

@Override
Expand Down
81 changes: 38 additions & 43 deletions src/main/java/io/github/spannm/jackcess/util/ImportUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,60 +388,55 @@ public static String importReader(BufferedReader in, Database db,

Pattern delimPat = Pattern.compile(delim);

try {
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);

for (Object columnName : columnNames) {
columns.add(new ColumnBuilder((String) columnName, DataType.TEXT)
.escapeName()
.withLength((short) DataType.TEXT.getMaxSize())
.toColumn());
}
name = TableBuilder.escapeIdentifier(name);
Table table = null;
if (!useExistingTable || (table = db.getTable(name)) == null) {

table = createUniqueTable(db, name, columns, null, filter);
List<ColumnBuilder> columns = new ArrayList<>();
Object[] columnNames = splitLine(line, delimPat, quote, in, 0);

// the first row was a header row
header = true;
for (Object columnName : columnNames) {
columns.add(new ColumnBuilder((String) columnName, DataType.TEXT)
.escapeName()
.withLength((short) DataType.TEXT.getMaxSize())
.toColumn());
}

List<Object[]> rows = new ArrayList<>(COPY_TABLE_BATCH_SIZE);
int numColumns = table.getColumnCount();
table = createUniqueTable(db, name, columns, null, filter);

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);
}
}
// the first row was a header row
header = true;
}

while ((line = in.readLine()) != null) {
Object[] data = splitLine(line, delimPat, quote, in, numColumns);
data = filter.filterRow(data);
if (data == null) {
continue;
}
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 (rows.size() == COPY_TABLE_BATCH_SIZE) {
table.addRows(rows);
rows.clear();
}
}
if (!rows.isEmpty()) {
}

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();
}

return table.getName();

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

return table.getName();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/spannm/jackcess/util/Joiner.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public EntryIterableBuilder findRows(Object[] fromRow) {
* @param fromRow row from the "from" table (which must include the relevant columns for this join relationship)
* @return {@code true} if any "to" rows were deleted, {@code false} otherwise
*/
public boolean deleteRows(Map<String, ?> fromRow) throws IOException {
public boolean deleteRows(Map<String, ?> fromRow) {
return deleteRowsImpl(findRows(fromRow).withColumnNames(Set.of()).iterator());
}

Expand All @@ -180,7 +180,7 @@ public boolean deleteRows(Map<String, ?> fromRow) throws IOException {
* @param fromRow row from the "from" table (which must include the relevant columns for this join relationship)
* @return {@code true} if any "to" rows were deleted, {@code false} otherwise
*/
public boolean deleteRows(Object[] fromRow) throws IOException {
public boolean deleteRows(Object[] fromRow) {
return deleteRowsImpl(findRows(fromRow).withColumnNames(Set.of()).iterator());
}

Expand Down
Loading

0 comments on commit cb9c8e3

Please sign in to comment.