diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 04253e5..6b2aea9 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -30,8 +30,8 @@ jobs:
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
- java-version: '8'
- distribution: 'zulu'
+ java-version: '17'
+ distribution: 'temurin'
cache: 'maven'
- name: Biuld Package
run: mvn clean compile
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 679ac6c..10af115 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -16,8 +16,8 @@ jobs:
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
- java-version: '8'
- distribution: 'zulu'
+ java-version: '17'
+ distribution: 'temurin'
cache: 'maven'
server-id: ossrh
server-username: SONATYPE_USERNAME
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1acb0fd..e605c5e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+##### 1.0.0
+* Upgrade JDK to 17
+
##### 0.0.13
* Client can work with different charsets [#48](https://github.com/fintrace/tspl2-driver/pull/48). Fixes [#27](https://github.com/fintrace/tspl2-driver/issues/27)
diff --git a/README.md b/README.md
index b6b5d5e..f75a772 100644
--- a/README.md
+++ b/README.md
@@ -23,7 +23,7 @@ Add dependency in your pom
org.fintrace.core.drivers
tspl2-driver
- 0.0.13
+ 1.0.0
```
@@ -37,17 +37,12 @@ TSPLConnectionClient tsplConnectionClient = new USBConnectionClient(
(short) xxxx, 16)); // product id of TSPL2 based printer
// Or Ethernet Client
+// TSPLConnectionClient tsplConnectionClient = new EthernetConnectionClient("x.x.x.x", 9100);
-TSPLConnectionClient tsplConnectionClient = new EthernetConnectionClient("x.x.x.x", 9100);
-```
-
-Initialize the printer with defaults
-```java
+// Initialize the printer with defaults
tsplConnectionClient.init();
-```
-Once initialized, Establish the connection
-```java
+// Once initialized, Establish the connection
tsplConnectionClient.connect();
```
@@ -71,7 +66,6 @@ TSPLLabel tsplLabel = TSPLLabel.builder()
.build();
tsplConnectionClient.send(tsplLabel);
-
```
The above will send the following TSPL2 code to printer
@@ -110,10 +104,8 @@ Implement [ClientListener](src/main/java/org/fintrace/core/drivers/tspl/listener
Other documentation
=================
-Documentation about TSPL could be find here
-http://www.tscprinters.com/cms/upload/download_en/TSPL_TSPL2_Programming.pdf
-or
-http://mediaform.de/fileadmin/support/handbuecher/Armilla/Handbuecher/TSC_TSPL_TSPL2_Programming.pdf
+Documentation about TSPL2 could be found here
+https://shop.mediaform.de/media/wysiwyg/downloads/armilla/TSC_TSPL_TSPL2_Programming.pdf
Contributions
=================
diff --git a/pom.xml b/pom.xml
index 6d54bd1..5fd8804 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,22 +3,22 @@
org.fintrace.core.drivers
tspl2-driver
- 0.0.14-SNAPSHOT
+ 1.0.0-SNAPSHOT
jar
TSPL2 (by TSC) Java driver
https://github.com/fintrace/tspl2-driver
Java client for TSPL2 generator and USB communication
- 1.8
- 1.8
+ 17
+ 17
UTF-8
${maven.build.timestamp}
yyyyMMddHHmm
- 1.18.30
- 1.2.13
- 1.7.36
+ 1.18.32
+ 1.5.6
+ 2.0.13
1.3.0
- 5.9.0
+ 5.10.2
@@ -95,7 +95,7 @@
org.sonatype.plugins
nexus-staging-maven-plugin
- 1.6.2
+ 1.6.13
true
ossrh
@@ -145,7 +145,7 @@
com.coderplus.maven.plugins
copy-rename-maven-plugin
- 1.0
+ 1.0.1
copy-and-rename-file
@@ -163,7 +163,7 @@
org.apache.maven.plugins
maven-jar-plugin
- 3.3.0
+ 3.4.1
@@ -220,7 +220,7 @@
com.puppycrawl.tools
checkstyle
- 9.3
+ 10.16.0
@@ -285,7 +285,7 @@
org.junit.jupiter
- junit-jupiter-api
+ junit-jupiter
${junit.jupiter.version}
test
diff --git a/src/main/java/org/fintrace/core/drivers/tspl/commands/device/TSPLDeviceConfigurationCommands.java b/src/main/java/org/fintrace/core/drivers/tspl/commands/device/TSPLDeviceConfigurationCommands.java
index fe23132..8cd4b9d 100644
--- a/src/main/java/org/fintrace/core/drivers/tspl/commands/device/TSPLDeviceConfigurationCommands.java
+++ b/src/main/java/org/fintrace/core/drivers/tspl/commands/device/TSPLDeviceConfigurationCommands.java
@@ -48,7 +48,7 @@ public enum TSPLDeviceConfigurationCommands implements TSPLCommand {
/**
* Set number of printing labels per cut. 0<= pieces <=65535.
- * Shall append the this command with the number of pieces.
+ * Shall append the command with the number of pieces.
*/
PARTIAL_CUTTER_PIECES(DeviceConfigCommand.PARTIAL_CUTTER, PartialCutterValues.Pieces),
@@ -64,7 +64,7 @@ public enum TSPLDeviceConfigurationCommands implements TSPLCommand {
/**
* Set number of printing labels per cut. 0<= pieces <=65535.
- * Shall append the this command with the number of pieces.
+ * Shall append the command with the number of pieces.
*/
CUTTER_PIECES(DeviceConfigCommand.CUTTER, PartialCutterValues.Pieces),
@@ -108,15 +108,15 @@ public enum TSPLDeviceConfigurationCommands implements TSPLCommand {
*/
ENCODER_OFF(DeviceConfigCommand.ENCODER, EncoderCommandValues.OFF);
- private DeviceConfigCommand command;
- private CommandValues commandValue;
+ private final DeviceConfigCommand command;
+ private final CommandValues commandValue;
/**
* @param command
* @param commandValue
*/
TSPLDeviceConfigurationCommands(DeviceConfigCommand command,
- CommandValues commandValue) {
+ CommandValues commandValue) {
this.command = command;
this.commandValue = commandValue;
}
diff --git a/src/main/java/org/fintrace/core/drivers/tspl/commands/label/AztecBarcode.java b/src/main/java/org/fintrace/core/drivers/tspl/commands/label/AztecBarcode.java
index 2b8f1ae..4e689f0 100644
--- a/src/main/java/org/fintrace/core/drivers/tspl/commands/label/AztecBarcode.java
+++ b/src/main/java/org/fintrace/core/drivers/tspl/commands/label/AztecBarcode.java
@@ -107,75 +107,72 @@ public class AztecBarcode implements TSPLCommand {
*/
@Override
public String getCommand() {
+ validateRequiredFields();
+
+ return new StringBuilder(AZTEC.name())
+ .append(EMPTY_SPACE)
+ .append(xCoordinate).append(COMMA)
+ .append(yCoordinate).append(COMMA)
+ .append(rotation.getRotation()).append(COMMA)
+ .append(getModuleSizeCommandPart())
+ .append(getErrorControlCommandPart())
+ .append(getEscapeFlagCommandPart())
+ .append(getMenuCommandPart())
+ .append(getMultiCommandPart())
+ .append(getRevCommandPart())
+ .append(getBytesCommandPart())
+ .append(content)
+ .append(LF)
+ .toString();
+ }
+
+ private void validateRequiredFields() {
if (xCoordinate == null || yCoordinate == null) {
throw new LabelParserException("AZTEC: x and y positions are required");
}
-
if (rotation == null) {
throw new LabelParserException("AZTEC: rotation is required");
}
-
if (moduleSize != null && (moduleSize < 1 || moduleSize > 20)) {
throw new LabelParserException("AZTEC: invalid module size value");
}
-
- if (errorControl != null && (errorControl == 100
- || (errorControl > 104 && errorControl <= 200)
- || (errorControl > 232 && errorControl < 300)
- || (errorControl > 300))) {
+ if (errorControl != null && checkInvalidErrorControl()) {
throw new LabelParserException("AZTEC: invalid error control parameter");
}
+ }
- StringBuilder commandBuilder = new StringBuilder(AZTEC.name());
- commandBuilder.append(EMPTY_SPACE)
- .append(xCoordinate).append(COMMA)
- .append(yCoordinate).append(COMMA)
- .append(rotation.getRotation()).append(COMMA);
-
- if (moduleSize == null) {
- commandBuilder.append("6").append(COMMA);
- } else {
- commandBuilder.append(moduleSize).append(COMMA);
- }
-
- if (errorControl == null) {
- commandBuilder.append("0").append(COMMA);
- } else {
- commandBuilder.append(errorControl).append(COMMA);
- }
-
- commandBuilder.append(escapeFlag).append(COMMA);
+ private boolean checkInvalidErrorControl() {
+ return errorControl == 100
+ || (errorControl > 104 && errorControl <= 200)
+ || (errorControl > 232 && errorControl < 300)
+ || (errorControl > 300);
+ }
- if (menu == null) {
- commandBuilder.append("0").append(COMMA);
- } else {
- commandBuilder.append(menu ? "1" : "0").append(COMMA);
- }
+ private String getModuleSizeCommandPart() {
+ return (moduleSize == null ? "6" : moduleSize) + COMMA;
+ }
- if (multi == null) {
- commandBuilder.append("6").append(COMMA);
- } else {
- commandBuilder.append(multi).append(COMMA);
- }
+ private String getErrorControlCommandPart() {
+ return (errorControl == null ? "0" : errorControl) + COMMA;
+ }
- if (rev == null) {
- commandBuilder.append("0").append(COMMA);
- } else {
- commandBuilder.append(rev ? "1" : "0").append(COMMA);
- }
+ private String getEscapeFlagCommandPart() {
+ return escapeFlag + COMMA;
+ }
- if (bytes != null) {
- commandBuilder.append(bytes).append(COMMA)
- .append("\"");
- }
+ private String getMenuCommandPart() {
+ return (menu == null ? "0" : (menu ? "1" : "0")) + COMMA;
+ }
- commandBuilder.append(content);
+ private String getMultiCommandPart() {
+ return (multi == null ? "6" : multi) + COMMA;
+ }
- if (bytes != null) {
- commandBuilder.append("\"");
- }
+ private String getRevCommandPart() {
+ return (rev == null ? "0" : (rev ? "1" : "0")) + COMMA;
+ }
- commandBuilder.append(LF);
- return commandBuilder.toString();
+ private String getBytesCommandPart() {
+ return bytes == null ? "" : bytes + COMMA + '"';
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/org/fintrace/core/drivers/tspl/commands/label/Bar.java b/src/main/java/org/fintrace/core/drivers/tspl/commands/label/Bar.java
index 7c61d14..dd46ef3 100644
--- a/src/main/java/org/fintrace/core/drivers/tspl/commands/label/Bar.java
+++ b/src/main/java/org/fintrace/core/drivers/tspl/commands/label/Bar.java
@@ -84,11 +84,11 @@ public String getCommand() {
throw new LabelParserException("BAR: height is required");
}
- return LabelFormatCommand.BAR.name() + EMPTY_SPACE
- + xCoordinate + COMMA
- + yCoordinate + COMMA
- + width + COMMA
- + height
- + LF;
+ return new StringBuilder(LabelFormatCommand.BAR.name()).append(EMPTY_SPACE)
+ .append(xCoordinate).append(COMMA)
+ .append(yCoordinate).append(COMMA)
+ .append(width).append(COMMA)
+ .append(height).append(LF)
+ .toString();
}
}