From 119a99ff49d314cf33b94d1c922f5091a26489d6 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Mon, 28 Jun 2021 16:54:11 +0200 Subject: - initial implementation of FCB version 3.0.0 - !!Tests still missing!! --- .../org/uic/barcode/ticket/UicRailTicketCoder.java | 32 +++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/main/java/org/uic/barcode/ticket/UicRailTicketCoder.java') diff --git a/src/main/java/org/uic/barcode/ticket/UicRailTicketCoder.java b/src/main/java/org/uic/barcode/ticket/UicRailTicketCoder.java index 62fda2d..e9d2eb4 100644 --- a/src/main/java/org/uic/barcode/ticket/UicRailTicketCoder.java +++ b/src/main/java/org/uic/barcode/ticket/UicRailTicketCoder.java @@ -10,8 +10,10 @@ import java.io.InputStream; import org.uic.barcode.ticket.api.spec.IUicRailTicket; import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoder; import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV2; +import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3; import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder; import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV2; +import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3; /** @@ -44,7 +46,14 @@ public class UicRailTicketCoder { return uicEncoder.encode(uicRailTicket); + } else if (version == 3) { + + Api2OpenAsnEncoderV3 uicEncoder = new Api2OpenAsnEncoderV3(); + + return uicEncoder.encode(uicRailTicket); + } + throw new EncodingFormatException(String.format("Encoding version %d not supported", version)); @@ -86,7 +95,19 @@ public class UicRailTicketCoder { return; + + } else if (version == 3) { + + Api2OpenAsnEncoderV3 uicEncoder = new Api2OpenAsnEncoderV3(); + + org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData asnUicRailTicketData = uicEncoder.populateToAsn1Model(uicRailTicket); + + outputStream.write(asnUicRailTicketData.encode()); + + return; + } + throw new EncodingFormatException(String.format("Encoding version %d not supported", version)); @@ -118,7 +139,16 @@ public class UicRailTicketCoder { return uicRailTicket; + } else if (version == 3) { + + OpenAsn2ApiDecoderV3 uicDecoder = new OpenAsn2ApiDecoderV3(); + + IUicRailTicket uicRailTicket = uicDecoder.decodeFromAsn(byteData); + + return uicRailTicket; + } + throw new EncodingFormatException(String.format("Encoding version %d not supported", version)); @@ -135,7 +165,7 @@ public class UicRailTicketCoder { */ public IUicRailTicket decodeFromAsn (InputStream input, int version) throws IOException, EncodingFormatException{ - if (version != 1 && version != 2 && version != 13) { + if (version != 1 && version != 2 && version != 13 && version != 3) { throw new EncodingFormatException(String.format("Encoding version %d not supported", version)); } -- cgit v1.2.3