summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java
blob: c7f520dfc95e8bd5c46a09f9103e1b61930b47df (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package org.uic.barcode.ssbFrame;

import org.uic.barcode.asn1.uper.BitBuffer;
import org.uic.barcode.asn1.uper.ByteBitBuffer;

public class SsbReservation extends SsbCommonTicketPart {
	
	private SsbStations stations = new SsbStations();
	
	private int ticketSubType = 0;
	
	private int departureDate = 0;
	
	private int departureTime = 0;
	
	private String train = null;
	
	private int coach = 0;
	
	private String place = null;
	
	private boolean overbooking = false;
	
	private int infoCode = 0;
	
	private String text = null;
	
	
	
	

	@Override
	protected void decodeContent(byte[] bytes) {
		
		int offset = decodeCommonPart(bytes);
		
		BitBuffer bits = new ByteBitBuffer(bytes);
		
		ticketSubType = bits.getInteger(offset, 2);
		offset = offset + 4;
		
		stations = new SsbStations();
		stations.decode(offset, bytes);
		
		/*
		 * 	Departure date : First day of validity from the issuing date	Num (<367)	9,000
			Departure Time	Num (<1440)	11,000
			Train number	AlphaNum + 5 Car	30,000
			Coach number	Num (< 999)	10,000
			Seat/berth number	3 AlphaNum	18,000
			Overbooking indicator	Bit Flag	1,000
			Information Messages	Num (< 9999)	14,000
			Open Tekst	6 Bit ASCII (27 Car)	162,000
		 */
		
		departureDate = bits.getInteger(offset, 9);
		offset = offset + 9;
		
		departureTime = bits.getInteger(offset, 11);
		offset = offset + 11;
		
		train = bits.getChar6String(offset, 30);
		offset = offset +30;
		
		coach = bits.getInteger(offset, 10);
		offset = offset + 10;
		
		place = bits.getChar6String(offset, 18);
		offset = offset + 18;
		
		overbooking = bits.get(offset);
		offset++;
		
		infoCode = bits.getInteger(offset, 14);
		offset = offset + 14;
		
		text = bits.getChar6String(offset, 162);
		offset = offset + 162;
	}

	@Override
	protected void encodeContent(byte[] bytes) {
		
		int offset = encodeCommonPart(bytes);
		
		BitBuffer bits = new ByteBitBuffer(bytes);
		
		bits.putInteger(offset, 2,ticketSubType);
		offset = offset + 4;

		offset = stations.encode(offset, bytes);
		
		/*
		 * 	Departure date : First day of validity from the issuing date	Num (<367)	9,000
			Departure Time	Num (<1440)	11,000
			Train number	AlphaNum + 5 Car	30,000
			Coach number	Num (< 999)	10,000
			Seat/berth number	3 AlphaNum	18,000
			Overbooking indicator	Bit Flag	1,000
			Information Messages	Num (< 9999)	14,000
			Open Tekst	6 Bit ASCII (27 Car)	162,000
		 */
		
		bits.putInteger(offset, 9, departureDate);
		offset = offset + 9;
		
		bits.putInteger(offset, 11,departureTime);
		offset = offset + 11;
		
		bits.putChar6String(offset, 30,train);
		offset = offset +30;
		
		bits.putInteger(offset, 10,coach);
		offset = offset + 10;
		
		bits.putChar6String(offset, 18,place);
		offset = offset + 18;
		
		bits.put(offset, overbooking);
		offset++;
		
		bits.putInteger(offset, 14, infoCode);
		offset = offset + 14;
		
		bits.putChar6String(offset, 162, text);
		offset = offset + 162;
		
	}

	public SsbStations getStations() {
		return stations;
	}

	public int getTicketSubType() {
		return ticketSubType;
	}

	public void setTicketSubType(int ticketSubType) {
		this.ticketSubType = ticketSubType;
	}

	public int getDepartureDate() {
		return departureDate;
	}

	public void setDepartureDate(int departureDate) {
		this.departureDate = departureDate;
	}

	public int getDepartureTime() {
		return departureTime;
	}

	public void setDepartureTime(int departureTime) {
		this.departureTime = departureTime;
	}

	public String getTrain() {
		return train;
	}

	public void setTrain(String train) {
		this.train = train;
	}

	public int getCoach() {
		return coach;
	}

	public void setCoach(int coach) {
		this.coach = coach;
	}

	public String getPlace() {
		return place;
	}

	public void setPlace(String place) {
		this.place = place;
	}

	public boolean isOverbooking() {
		return overbooking;
	}

	public void setOverbooking(boolean overbooking) {
		this.overbooking = overbooking;
	}

	public int getInfoCode() {
		return infoCode;
	}

	public void setInfoCode(int infoCode) {
		this.infoCode = infoCode;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}
	
	

}