From e023e674020f1a435f7b8c8b9276704f576ea6e5 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Mon, 29 Mar 2021 14:08:45 +0200 Subject: structure change 1 --- .../uic/barcode/staticFrame/UFLEXDataRecord.java | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/main/java/org/uic/barcode/staticFrame/UFLEXDataRecord.java (limited to 'src/main/java/org/uic/barcode/staticFrame/UFLEXDataRecord.java') diff --git a/src/main/java/org/uic/barcode/staticFrame/UFLEXDataRecord.java b/src/main/java/org/uic/barcode/staticFrame/UFLEXDataRecord.java new file mode 100644 index 0000000..fad2be8 --- /dev/null +++ b/src/main/java/org/uic/barcode/staticFrame/UFLEXDataRecord.java @@ -0,0 +1,90 @@ +package org.uic.barcode.staticFrame; + +import java.io.IOException; + +import org.uic.barcode.ticket.EncodingFormatException; +import org.uic.barcode.ticket.UicRailTicketCoder; +import org.uic.barcode.ticket.api.spec.IUicRailTicket; + +/** + * The Class UFLEXDataRecord implements the dara record to hold the data of an ASN.1 PER encoded UIC ticket. + */ +public class UFLEXDataRecord extends DataRecord { + + + /** The ticket. */ + private IUicRailTicket ticket; + + /** + * Instantiates a new UFLEX data record. + */ + public UFLEXDataRecord() { + super("U_FLEX"); + } + + /** + * Instantiates a new UFLEX data record. + * + * @param version the version + */ + public UFLEXDataRecord(String version) { + super("U_FLEX", version); + } + + + /** + * Gets the ticket. + * + * @return the ticket + * @throws IOException Signals that an I/O exception has occurred. + * @throws EncodingFormatException the encoding format exception + */ + public IUicRailTicket getTicket() throws IOException, EncodingFormatException { + if (ticket != null) { + return ticket; + } + return null; + } + + /** + * Sets the ticket. + * + * @param ticket the new ticket + * @throws IOException Signals that an I/O exception has occurred. + * @throws EncodingFormatException the encoding format exception + */ + public void setTicket(IUicRailTicket ticket) throws IOException, EncodingFormatException { + this.ticket = ticket; + super.setData(null); + } + + + /** + * Decode content. + * + * @throws IOException Signals that an I/O exception has occurred. + * @throws EncodingFormatException the encoding format exception + */ + @Override + protected void decodeContent() throws IOException, EncodingFormatException { + UicRailTicketCoder coder = new UicRailTicketCoder(); + int version = Integer.parseInt(super.getVersionId()); + this.ticket = coder.decodeFromAsn(content,version); + } + + /** + * Encode content. + * + * @throws IOException Signals that an I/O exception has occurred. + * @throws EncodingFormatException the encoding format exception + */ + @Override + protected void encodeContent() throws IOException, EncodingFormatException { + UicRailTicketCoder coder = new UicRailTicketCoder(); + int version = Integer.parseInt(super.getVersionId()); + content = coder.encode(ticket, version); + } + + + +} -- cgit v1.2.3