blob: fad2be818645dfeba23028903fdd6ea15bd5fc76 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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);
}
}
|