Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Upgrade to JDK 17 #61

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
20 changes: 6 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Add dependency in your pom
<dependency>
<groupId>org.fintrace.core.drivers</groupId>
<artifactId>tspl2-driver</artifactId>
<version>0.0.13</version>
<version>1.0.0</version>
</dependency>
```

Expand All @@ -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();
```

Expand All @@ -71,7 +66,6 @@ TSPLLabel tsplLabel = TSPLLabel.builder()
.build();

tsplConnectionClient.send(tsplLabel);

```

The above will send the following TSPL2 code to printer
Expand Down Expand Up @@ -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
=================
Expand Down
24 changes: 12 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@

<groupId>org.fintrace.core.drivers</groupId>
<artifactId>tspl2-driver</artifactId>
<version>0.0.14-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TSPL2 (by TSC) Java driver</name>
<url>https://github.com/fintrace/tspl2-driver</url>
<description>Java client for TSPL2 generator and USB communication</description>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
<lombok.version>1.18.30</lombok.version>
<logback.version>1.2.13</logback.version>
<slf4j.version>1.7.36</slf4j.version>
<lombok.version>1.18.32</lombok.version>
<logback.version>1.5.6</logback.version>
<slf4j.version>2.0.13</slf4j.version>
<usb4java.version>1.3.0</usb4java.version>
<junit.jupiter.version>5.9.0</junit.jupiter.version>
<junit.jupiter.version>5.10.2</junit.jupiter.version>
</properties>
<profiles>
<profile>
Expand Down Expand Up @@ -95,7 +95,7 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.2</version>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
Expand Down Expand Up @@ -145,7 +145,7 @@
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
<version>1.0.1</version>
<executions>
<execution>
<id>copy-and-rename-file</id>
Expand All @@ -163,7 +163,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.1</version>
<configuration>
<archive>
<manifestEntries>
Expand Down Expand Up @@ -220,7 +220,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>9.3</version>
<version>10.16.0</version>
</dependency>
</dependencies>
<configuration>
Expand Down Expand Up @@ -285,7 +285,7 @@

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand All @@ -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),

Expand Down Expand Up @@ -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<String> commandValue;

/**
* @param command
* @param commandValue
*/
TSPLDeviceConfigurationCommands(DeviceConfigCommand command,
CommandValues commandValue) {
CommandValues<String> commandValue) {
this.command = command;
this.commandValue = commandValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '"';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Loading