summaryrefslogtreecommitdiffstats
path: root/src/org/uic/ticket/UicRailTicketCoder.java
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2020-12-18 17:20:12 +0100
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2020-12-18 17:20:12 +0100
commit8f7af5fde7283b519a2efccdaf84c63ecd9c680d (patch)
treeff9933a419a241b6e5c230c911cab8e46aa288fa /src/org/uic/ticket/UicRailTicketCoder.java
parentMerge branch 'master' of https://github.com/UnionInternationalCheminsdeFer/UIC-barcode (diff)
downloadUIC-barcode-8f7af5fde7283b519a2efccdaf84c63ecd9c680d.tar
UIC-barcode-8f7af5fde7283b519a2efccdaf84c63ecd9c680d.tar.gz
UIC-barcode-8f7af5fde7283b519a2efccdaf84c63ecd9c680d.tar.bz2
UIC-barcode-8f7af5fde7283b519a2efccdaf84c63ecd9c680d.tar.lz
UIC-barcode-8f7af5fde7283b519a2efccdaf84c63ecd9c680d.tar.xz
UIC-barcode-8f7af5fde7283b519a2efccdaf84c63ecd9c680d.tar.zst
UIC-barcode-8f7af5fde7283b519a2efccdaf84c63ecd9c680d.zip
Diffstat (limited to 'src/org/uic/ticket/UicRailTicketCoder.java')
-rw-r--r--src/org/uic/ticket/UicRailTicketCoder.java49
1 files changed, 4 insertions, 45 deletions
diff --git a/src/org/uic/ticket/UicRailTicketCoder.java b/src/org/uic/ticket/UicRailTicketCoder.java
index 82a546f..a4dc97f 100644
--- a/src/org/uic/ticket/UicRailTicketCoder.java
+++ b/src/org/uic/ticket/UicRailTicketCoder.java
@@ -19,47 +19,6 @@ import org.uic.ticket.api.utils.OpenAsn2ApiDecoderV2;
* The Class UicRailTicketCoder.
*/
public class UicRailTicketCoder {
-
-
- /**
- * encode an UicRailTicket to asn.1 format using PER unaligned encoding
- *
- * @param outputStream the output stream for the encoded data
- * @param uicRailTicket the uic rail ticket to be encoded
- * @param version version of the asn1 specification
- * @throws IOException signals that an I/O exception has occurred.
- * @throws EncodingFormatException signals that a format rule of the asn.1 specification was violated.
- */
- public byte[] encodeTag(IUicRailTicket uicRailTicket, int version) throws IOException, EncodingFormatException {
-
-
- byte[] content = encode(uicRailTicket, version);
-
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
-
- String idTag = "U_FLEX";
- String versionId = "01";
- int length = 8;
-
- //size of data
- length = length + content.length;
-
- //size of length element
- length = length + 4;
- String lengthElement = String.format("%04d",length);
-
- outputStream.write(idTag.getBytes());
- outputStream.write(versionId.getBytes());
- outputStream.write(lengthElement.getBytes());
-
- outputStream.write(content);
-
- return outputStream.toByteArray();
-
-}
-
-
-
/**
* encode an UicRailTicket to asn.1 format using PER unaligned encoding
@@ -73,7 +32,7 @@ public class UicRailTicketCoder {
public byte[] encode (IUicRailTicket uicRailTicket, int version) throws IOException, EncodingFormatException{
- if (version == 1) {
+ if (version == 13) {
Api2OpenAsnEncoder uicEncoder = new Api2OpenAsnEncoder();
@@ -107,7 +66,7 @@ public class UicRailTicketCoder {
- if (version == 1) {
+ if (version == 13) {
Api2OpenAsnEncoder uicEncoder = new Api2OpenAsnEncoder();
@@ -144,7 +103,7 @@ public class UicRailTicketCoder {
*/
public IUicRailTicket decodeFromAsn (byte[] byteData, int version) throws IOException, EncodingFormatException{
- if (version == 1) {
+ if (version == 1 || version == 13) {
OpenAsn2ApiDecoder uicDecoder = new OpenAsn2ApiDecoder();
@@ -177,7 +136,7 @@ public class UicRailTicketCoder {
*/
public IUicRailTicket decodeFromAsn (InputStream input, int version) throws IOException, EncodingFormatException{
- if (version != 1) {
+ if (version != 1 && version != 2 && version != 13) {
throw new EncodingFormatException(String.format("Encoding version %d not supported", version));
}