Skip to content

Commit

Permalink
disallow null time
Browse files Browse the repository at this point in the history
  • Loading branch information
JG1VPP committed Jun 2, 2024
1 parent cb361b8 commit ab7ff5b
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 25 deletions.
3 changes: 1 addition & 2 deletions src/main/java/gaas/table/CTxtEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public final void output(Item item) throws IOException {
* @throws IOException 書き込みに失敗した場合
*/
private void time(Time date) throws IOException {
if(date == null) space(" ".repeat(10));
else space(tstamp.format(date.local()));
space(tstamp.format(date.local()));
}
}
4 changes: 1 addition & 3 deletions src/main/java/gaas/table/CqwwEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ public final void output(Item item) throws IOException {
* @throws IOException 書き込みに失敗した場合
*/
private final void time(Time date) throws IOException {
final var format = tstamp.withZone(UTC);
if(date == null) space(" ".repeat(15));
else space(format.format(date.value()));
space(tstamp.withZone(UTC).format(date.value()));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/gaas/table/HBinDecoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public final class HBinDecoder extends BasicDecoder {
private final Map<Column, Integer> widths;
private final DataInputStream source;
private final DateTime hDTime;
private final DateTime chrono;

/**
* 指定された入力を読み込むデコーダを構築します。
Expand All @@ -41,7 +41,7 @@ public final class HBinDecoder extends BasicDecoder {
public HBinDecoder(InputStream stream) {
super("hbin");
this.source = new DataInputStream(stream);
this.hDTime = new DateTime();
this.chrono = new DateTime();
this.widths = new HashMap<>();
}

Expand Down Expand Up @@ -214,7 +214,7 @@ private final void time(Item item) throws IOException {
final int times = widths.get(Column.TIME);
final var bytes = new byte[dates + times];
source.readFully(bytes);
item.set(hDTime.decode(bytes));
item.set(chrono.decode(bytes));
}

/**
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/gaas/table/HBinEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
public final class HBinEncoder extends BasicEncoder {
private final DataOutputStream target;
private final DateTime hDTime;
private final DateTime chrono;

/**
* 指定された出力に書き込むエンコーダを構築します。
Expand All @@ -42,7 +42,7 @@ public final class HBinEncoder extends BasicEncoder {
public HBinEncoder(OutputStream stream) {
super("hbin");
this.target = new DataOutputStream(stream);
this.hDTime = new DateTime();
this.chrono = new DateTime();
}

/**
Expand Down Expand Up @@ -173,8 +173,7 @@ private final void head(Column col) throws IOException {
* @throws IOException 書き込みに失敗した場合
*/
private final void time(Time time) throws IOException {
if(time == null) target.write(new byte[6]);
else target.write(hDTime.encode(time));
target.write(chrono.encode(time));
}

/**
Expand All @@ -186,10 +185,8 @@ private final void time(Time time) throws IOException {
* @throws IOException 書き込みに失敗した場合
*/
private final void band(Band band) throws IOException {
if(band != null) {
final var val = band.toDecimalString(3);
final var any = new Any(Qxsl.BAND, val);
write(any, Column.FREQ);
} else write(null, Column.FREQ);
final var val = band.toDecimalString(3);
final var any = new Any(Qxsl.BAND, val);
write(any, Column.FREQ);
}
}
3 changes: 1 addition & 2 deletions src/main/java/gaas/table/JSwlEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ public final void output(Item item) throws IOException {
* @throws IOException 書き込みに失敗した場合
*/
private final void time(Time date) throws IOException {
if(date == null) space(" ".repeat(16));
else space(tstamp.format(date.local()));
space(tstamp.format(date.local()));
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/gaas/table/JarlEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ public final void output(Item item) throws IOException {
* @throws IOException 書き込みに失敗した場合
*/
private final void time(Time date) throws IOException {
if(date == null) space(" ".repeat(16));
else space(tstamp.format(date.local()));
space(tstamp.format(date.local()));
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/gaas/table/ZAllEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ public final void output(Item item) throws IOException {
* @throws IOException 書き込みに失敗した場合
*/
private final void time(Time date) throws IOException {
if(date == null) space(" ".repeat(16));
else space(tstamp.format(date.local()));
space(tstamp.format(date.local()));
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/gaas/table/ZDosEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ public final void output(Item item) throws IOException {
* @throws IOException 書き込みに失敗した場合
*/
private final void time(Time date) throws IOException {
if(date == null) space(" ".repeat(12));
else space(tstamp.format(date.local()));
space(tstamp.format(date.local()));
}

/**
Expand Down

0 comments on commit ab7ff5b

Please sign in to comment.