summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/uic/barcode
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2023-03-10 16:49:58 +0100
committerCGantert345 <57003061+CGantert345@users.noreply.github.com>2023-03-10 16:49:58 +0100
commit7ec06722923d96d2e51300bafb44b920ca341d58 (patch)
tree3a3635f56092a4fe1d6c15d88872ea699fb97666 /src/main/java/org/uic/barcode
parentssb added to encoder and decoder (diff)
downloadUIC-barcode-7ec06722923d96d2e51300bafb44b920ca341d58.tar
UIC-barcode-7ec06722923d96d2e51300bafb44b920ca341d58.tar.gz
UIC-barcode-7ec06722923d96d2e51300bafb44b920ca341d58.tar.bz2
UIC-barcode-7ec06722923d96d2e51300bafb44b920ca341d58.tar.lz
UIC-barcode-7ec06722923d96d2e51300bafb44b920ca341d58.tar.xz
UIC-barcode-7ec06722923d96d2e51300bafb44b920ca341d58.tar.zst
UIC-barcode-7ec06722923d96d2e51300bafb44b920ca341d58.zip
Diffstat (limited to 'src/main/java/org/uic/barcode')
-rw-r--r--src/main/java/org/uic/barcode/Decoder.java9
-rw-r--r--src/main/java/org/uic/barcode/Encoder.java2
-rw-r--r--src/main/java/org/uic/barcode/asn1/uper/ByteBitBuffer.java1
-rw-r--r--src/main/java/org/uic/barcode/package.html30
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbCommonTicketPart.java7
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java102
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbGroup.java19
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java8
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbNonReservation.java14
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java41
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbPass.java11
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java24
-rw-r--r--src/main/java/org/uic/barcode/ssbFrame/SsbTicketPart.java10
-rw-r--r--src/main/java/org/uic/barcode/staticFrame/package.html29
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/asn/package.html8
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/impl/package.html7
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/spec/package.html10
-rw-r--r--src/main/java/org/uic/barcode/ticket/api/utils/package.html7
-rw-r--r--src/main/java/org/uic/barcode/ticket/package.html12
-rw-r--r--src/main/java/org/uic/barcode/utils/package.html21
20 files changed, 249 insertions, 123 deletions
diff --git a/src/main/java/org/uic/barcode/Decoder.java b/src/main/java/org/uic/barcode/Decoder.java
index 1b3fb0c..85faa4a 100644
--- a/src/main/java/org/uic/barcode/Decoder.java
+++ b/src/main/java/org/uic/barcode/Decoder.java
@@ -213,6 +213,13 @@ public class Decoder {
} else {
throw e;
}
+ } catch (AssertionError e) {
+ dynamicFrame = null;
+ if (isSsbFrame(data)) {
+ decodeSsbFrame(data);
+ } else {
+ throw new EncodingFormatException(e.getMessage());
+ }
}
} else if (isStaticHeader(data)){
@@ -292,7 +299,7 @@ public class Decoder {
* @return true, if is static header
*/
private boolean isSsbFrame(byte[] data) {
- if (data.length == 144) {
+ if (data.length == 114) {
return true;
}
return false;
diff --git a/src/main/java/org/uic/barcode/Encoder.java b/src/main/java/org/uic/barcode/Encoder.java
index cf2d4d2..f2b9b0c 100644
--- a/src/main/java/org/uic/barcode/Encoder.java
+++ b/src/main/java/org/uic/barcode/Encoder.java
@@ -462,6 +462,8 @@ public class Encoder {
return DynamicFrameCoder.encode(dynamicFrame);
} else if (staticFrame != null) {
return staticFrame.encode();
+ } else if (ssbFrame != null) {
+ return ssbFrame.encode();
}
return null;
}
diff --git a/src/main/java/org/uic/barcode/asn1/uper/ByteBitBuffer.java b/src/main/java/org/uic/barcode/asn1/uper/ByteBitBuffer.java
index e409005..ce5ca60 100644
--- a/src/main/java/org/uic/barcode/asn1/uper/ByteBitBuffer.java
+++ b/src/main/java/org/uic/barcode/asn1/uper/ByteBitBuffer.java
@@ -125,6 +125,7 @@ public class ByteBitBuffer implements BitBuffer {
public ByteBitBuffer(byte[] backingArray) {
this.bytes = backingArray;
this.isFinite = true;
+ this.limit = backingArray.length * 8;
}
private ByteBitBuffer(int initialCapacity) {
diff --git a/src/main/java/org/uic/barcode/package.html b/src/main/java/org/uic/barcode/package.html
index 4a6ee0d..075af29 100644
--- a/src/main/java/org/uic/barcode/package.html
+++ b/src/main/java/org/uic/barcode/package.html
@@ -3,19 +3,21 @@
<head></head>
<body>
- <p>Provides the decoder and encoder for a UIC barcode</p>
-
-
- <p> Included features:<br/><br/>
- <ul>
- <li>dynamic bar code (DOSIPA) (version 1)</li>
- <li>static bar code (version 1 and 2)</li>
- <li>- FCB version 1</li>
- <li>- FCB version 2 (dynamic bar code only)</li>
- <li>- TLB (static bar code only)</li>
- </ul>
- </p>
-
-
+ <p>Provides the decoder and encoder for a UIC barcode</p>
+
+
+ <p>
+ Included features:<br />
+ <br />
+ <ul>
+ <li>dynamic bar code (DOSIPA) (version 1)</li>
+ <li>static bar code (version 1 and 2)</li>
+ <li>- FCB version 1</li>
+ <li>- FCB version 2 (dynamic bar code only)</li>
+ <li>- TLB (static bar code only)</li>
+ </ul>
+ </p>
+
+
</body>
</html> \ No newline at end of file
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbCommonTicketPart.java b/src/main/java/org/uic/barcode/ssbFrame/SsbCommonTicketPart.java
index 9512fc1..0a158f3 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbCommonTicketPart.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbCommonTicketPart.java
@@ -46,14 +46,13 @@ public abstract class SsbCommonTicketPart extends SsbTicketPart {
return offset;
}
- protected int encodeCommonPart(byte[] bytes) {
+ protected int encodeCommonPart(byte[] bytes, int offset) {
BitBuffer bits = new ByteBitBuffer(bytes);
-
- int offset = 27; // header offset
+
bits.putInteger(offset,7, numberOfAdults);
offset = offset + 7;
- bits.putInteger(numberOfChildren,offset, 7);
+ bits.putInteger(offset, 7, numberOfChildren);
offset = offset + 7;
bits.put(offset,specimen);
offset++;
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java b/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java
index 81b5eb4..1ee68bb 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java
@@ -20,7 +20,7 @@ import org.uic.barcode.utils.SecurityUtils;
public class SsbFrame {
- private SsbHeader header = null;
+ private SsbHeader header = new SsbHeader();
private byte[] signaturePart1 = null;
@@ -42,33 +42,38 @@ public class SsbFrame {
throw new EncodingFormatException("Data size does not fit to SSB");
}
- header = new SsbHeader();
- header.decode(bytes);
+ if (header == null) {
+ header = new SsbHeader();
+ }
+
+ int offset = 0;
+
+ offset = offset + header.decodeContent(bytes,0);
if (header.getTicketType().equals(SsbTicketType.UIC_1_IRT_RES_BOA)) {
reservationData = new SsbReservation();
- reservationData.decode(bytes);
+ offset = offset + reservationData.decodeContent(bytes,offset);
} else if (header.getTicketType().equals(SsbTicketType.UIC_2_NRT)) {
nonReservationData = new SsbNonReservation();
- nonReservationData.decode(bytes);
+ offset = offset + nonReservationData.decodeContent(bytes,offset);
} else if (header.getTicketType().equals(SsbTicketType.UIC_3_GRP)) {
groupData = new SsbGroup();
- groupData.decode(bytes);
+ offset = offset + groupData.decodeContent(bytes, offset);
} else if (header.getTicketType().equals(SsbTicketType.UIC_4_RPT)) {
passData = new SsbPass();
- passData.decode(bytes);
+ offset = offset + passData.decodeContent(bytes,offset);
} else {
nonUicData = new SsbNonUic();
- nonUicData.decode(bytes);
+ offset = offset + nonUicData.decodeContent(bytes,offset);
}
@@ -76,8 +81,8 @@ public class SsbFrame {
signaturePart2 = new byte[28];
for (int i = 0 ; i < 28;i++) {
- signaturePart1[i] = bytes[59 + i];
- signaturePart2[i] = bytes[59 + 28 + i];
+ signaturePart1[i] = bytes[58 + i];
+ signaturePart2[i] = bytes[58 + 28 + i];
}
}
@@ -86,27 +91,48 @@ public class SsbFrame {
byte[] bytes = new byte[114];
- header.encode(bytes);
+ int offset = header.encodeContent(bytes,0);
+
+
if (nonUicData != null) {
- nonUicData.encode(bytes);
+ offset = nonUicData.encodeContent(bytes, offset);
} else if (nonReservationData != null) {
- nonReservationData.encode(bytes);
+ offset = nonReservationData.encodeContent(bytes, offset);
} else if (reservationData != null) {
- reservationData.encode(bytes);
+ offset = reservationData.encodeContent(bytes, offset);
} else if (groupData != null) {
- groupData.encode(bytes);
+ offset = groupData.encodeContent(bytes, offset);
} else if (passData != null) {
- passData.encode(bytes);
+ offset = passData.encodeContent(bytes, offset);
} else {
throw new EncodingFormatException("Data Content for SSB missing");
};
- for (int i = 0 ; i < 28;i++) {
- bytes[59 + i] = signaturePart1[i];
- bytes[59 + 28 + i] = signaturePart2[i];
+
+ if (signaturePart1.length > 28) {
+ throw new EncodingFormatException("Signature too large");
+ }
+ if (signaturePart2.length > 28) {
+ throw new EncodingFormatException("Signature too large");
}
+ for (int i = 1 ; i < 29; i++) {
+ int sigInd = signaturePart1.length - i;
+ if (sigInd < signaturePart1.length && sigInd >= 0) {
+ bytes[58 + 28 - i] = signaturePart1[sigInd];
+ } else {
+ bytes[58 + 28 - i] = '\0';
+ }
+ sigInd = signaturePart2.length - i;
+ if (sigInd < signaturePart2.length && sigInd >= 0) {
+ bytes[58 + 28 + 28 - i] = signaturePart2[sigInd];
+ } else {
+ bytes[58 + 28 + 28 - i] = '\0';
+ }
+ }
+
+
return bytes;
}
@@ -115,18 +141,19 @@ public class SsbFrame {
byte[] bytes = new byte[58];
- header.encode(bytes);
+ int offset = header.encodeContent(bytes,0);
+
if (nonUicData != null) {
- nonUicData.encode(bytes);
+ offset = nonUicData.encodeContent(bytes, offset);
} else if (nonReservationData != null) {
- nonReservationData.encode(bytes);
+ offset = nonReservationData.encodeContent(bytes, offset);
} else if (reservationData != null) {
- reservationData.encode(bytes);
+ offset = reservationData.encodeContent(bytes, offset);
} else if (groupData != null) {
- groupData.encode(bytes);
+ offset = groupData.encodeContent(bytes, offset);
} else if (passData != null) {
- passData.encode(bytes);
+ offset = passData.encodeContent(bytes, offset);
} else {
throw new EncodingFormatException("Data Content for SSB missing");
};
@@ -165,6 +192,10 @@ public class SsbFrame {
public void setNonUicData(SsbNonUic nonUicData) {
this.nonUicData = nonUicData;
+ this.nonReservationData = null;
+ this.reservationData = null;
+ this.groupData = null;
+ this.passData = null;
}
public SsbNonReservation getNonReservationData() {
@@ -173,6 +204,11 @@ public class SsbFrame {
public void setNonReservationData(SsbNonReservation nonReservationData) {
this.nonReservationData = nonReservationData;
+ header.setTicketType(SsbTicketType.UIC_2_NRT);
+ this.reservationData = null;
+ this.nonUicData = null;
+ this.groupData = null;
+ this.passData = null;
}
public SsbReservation getReservationData() {
@@ -180,6 +216,11 @@ public class SsbFrame {
}
public void setReservationData(SsbReservation reservationData) {
+ header.setTicketType(SsbTicketType.UIC_1_IRT_RES_BOA);
+ this.nonReservationData = null;
+ this.nonUicData = null;
+ this.groupData = null;
+ this.passData = null;
this.reservationData = reservationData;
}
@@ -189,6 +230,12 @@ public class SsbFrame {
public void setGroupData(SsbGroup groupData) {
this.groupData = groupData;
+ header.setTicketType(SsbTicketType.UIC_3_GRP);
+ this.nonReservationData = null;
+ this.nonUicData = null;
+ this.reservationData = null;
+ this.passData = null;
+
}
public SsbPass getPassData() {
@@ -197,6 +244,11 @@ public class SsbFrame {
public void setPassData(SsbPass passData) {
this.passData = passData;
+ header.setTicketType(SsbTicketType.UIC_4_RPT);
+ this.nonReservationData = null;
+ this.nonUicData = null;
+ this.groupData = null;
+ this.reservationData = null;
}
public void signLevel1(PrivateKey key, Provider prov, String keyId, String algorithmOid) throws Exception {
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbGroup.java b/src/main/java/org/uic/barcode/ssbFrame/SsbGroup.java
index 52c3a52..1b2f6e7 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbGroup.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbGroup.java
@@ -18,9 +18,9 @@ public class SsbGroup extends SsbCommonTicketPart {
@Override
- protected void decodeContent(byte[] bytes) {
+ protected int decodeContent(byte[] bytes, int offset) {
- int offset = decodeCommonPart(bytes);
+ offset = offset + decodeCommonPart(bytes);
BitBuffer bits = new ByteBitBuffer(bytes);
@@ -44,15 +44,17 @@ public class SsbGroup extends SsbCommonTicketPart {
infoCode = bits.getInteger(offset, 14);
offset = offset + 14;
- text = bits.getChar6String(offset, 222);
- offset = offset + 222;
+ text = bits.getChar6String(offset, 144);
+ offset = offset + 144;
+
+ return offset;
}
@Override
- protected void encodeContent(byte[] bytes) {
+ protected int encodeContent(byte[] bytes, int offset) {
- int offset = encodeCommonPart(bytes);
+ offset = offset + encodeCommonPart(bytes, offset);
BitBuffer bits = new ByteBitBuffer(bytes);
@@ -65,7 +67,7 @@ public class SsbGroup extends SsbCommonTicketPart {
bits.putInteger(offset, 9, lastDayOfValidity);
offset = offset + 9;
- offset = stations.decode(offset, bytes);
+ offset = stations.encode(offset, bytes);
bits.putChar6String(offset, 72,groupName);
offset = offset + 72;
@@ -77,8 +79,9 @@ public class SsbGroup extends SsbCommonTicketPart {
offset = offset + 14;
bits.putChar6String(offset, 144, text);
- offset = offset + 222;
+ offset = offset + 144;
+ return offset;
}
public int getFirstDayOfValidity() {
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java b/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java
index 0d5424b..2ea4a51 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbHeader.java
@@ -27,7 +27,7 @@ public class SsbHeader extends SsbTicketPart {
public SsbHeader() {
}
- public void decodeContent(byte[] headerData) {
+ public int decodeContent(byte[] headerData, int offset) {
BitBuffer bits = new ByteBitBuffer(headerData);
@@ -36,11 +36,11 @@ public class SsbHeader extends SsbTicketPart {
keyId = bits.getInteger(18, 4);
ticketType = SsbTicketType.values()[bits.getInteger(22, 5)];
- return;
+ return 4 + 14 + 4 + 5;
}
- public void encodeContent(byte[] bytes) {
+ public int encodeContent(byte[] bytes, int offset) {
BitBuffer bits = new ByteBitBuffer(bytes);
@@ -49,6 +49,8 @@ public class SsbHeader extends SsbTicketPart {
bits.putInteger(18, 4, keyId);
bits.putInteger(22, 5, ticketType.ordinal());
+ return 4 + 14 + 4 + 5;
+
}
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbNonReservation.java b/src/main/java/org/uic/barcode/ssbFrame/SsbNonReservation.java
index e96e853..a1fb3ae 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbNonReservation.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbNonReservation.java
@@ -14,9 +14,9 @@ public class SsbNonReservation extends SsbCommonTicketPart {
@Override
- protected void decodeContent(byte[] bytes) {
+ protected int decodeContent(byte[] bytes, int offset) {
- int offset = decodeCommonPart(bytes);
+ offset = offset + decodeCommonPart(bytes);
BitBuffer bits = new ByteBitBuffer(bytes);
@@ -37,12 +37,14 @@ public class SsbNonReservation extends SsbCommonTicketPart {
text = bits.getChar6String(offset, 222);
offset = offset + 222;
+ return offset;
+
}
@Override
- protected void encodeContent(byte[] bytes) {
+ protected int encodeContent(byte[] bytes, int offset) {
- int offset = encodeCommonPart(bytes);
+ offset = offset + encodeCommonPart(bytes, offset);
BitBuffer bits = new ByteBitBuffer(bytes);
@@ -55,7 +57,7 @@ public class SsbNonReservation extends SsbCommonTicketPart {
bits.putInteger(offset, 9, lastDayOfValidity);
offset = offset + 9;
- offset = stations.decode(offset, bytes);
+ offset = stations.encode(offset, bytes);
bits.putInteger(offset, 14, infoCode);
offset = offset + 14;
@@ -63,6 +65,8 @@ public class SsbNonReservation extends SsbCommonTicketPart {
bits.putChar6String(offset, 222, text);
offset = offset + 222;
+ return offset;
+
}
public int getFirstDayOfValidity() {
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java b/src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java
index 28e5105..1f0049e 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java
@@ -6,31 +6,54 @@ import org.uic.barcode.asn1.uper.ByteBitBuffer;
public class SsbNonUic extends SsbTicketPart {
+
+
+
byte[] openData = null;
@Override
- protected void decodeContent(byte[] bytes) {
+ protected int decodeContent(byte[] bytes, int offset) {
+
+ BitBuffer bits = new ByteBitBuffer(bytes);
+
+ StringBuffer sb = new StringBuffer();
+
+
+ for (int i = offset; i < openDataLength; i++) {
+ if (bits.get(i) == false) {
+ sb.append("1");
+ } else {
+ sb.append("0");
+ }
+ }
+
+ for (int i = openDataLength; i < 440; i++) {
+ sb.append("0");
+ }
- String bitString = AsnUtils.toBooleanString(bytes);
-
- openData = AsnUtils.fromBooleanString(bitString);
+ openData = AsnUtils.fromBooleanString(sb.toString());
+
+ return offset + openDataLength ;
}
@Override
- protected void encodeContent(byte[] bytes) {
+ protected int encodeContent(byte[] bytes, int offset) {
BitBuffer bits = new ByteBitBuffer(bytes);
String bitString = AsnUtils.toBooleanString(openData);
- for (int i = 0;i< 58 *8 ;i++) {
- if (bitString.charAt(i) == '0') {
- bits.put(27 + i, true);
+
+ for (int i = 0; i< openDataLength ; i++) {
+ if (i < bitString.length() && bitString.charAt(i) == '0') {
+ bits.put(offset + i, true);
} else {
- bits.put(27 + i, false);
+ bits.put(offset + i, false);
}
}
+
+ return offset + openDataLength;
}
public byte[] getOpenData() {
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbPass.java b/src/main/java/org/uic/barcode/ssbFrame/SsbPass.java
index a38dfaf..3598efd 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbPass.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbPass.java
@@ -35,9 +35,9 @@ public class SsbPass extends SsbCommonTicketPart {
private String text = null;
@Override
- protected void decodeContent(byte[] bytes) {
+ protected int decodeContent(byte[] bytes, int offset) {
- int offset = decodeCommonPart(bytes);
+ offset = offset + decodeCommonPart(bytes);
BitBuffer bits = new ByteBitBuffer(bytes);
@@ -77,12 +77,13 @@ public class SsbPass extends SsbCommonTicketPart {
text = bits.getChar6String(offset, 240);
offset = offset + 240;
+ return offset;
}
@Override
- protected void encodeContent(byte[] bytes) {
+ protected int encodeContent(byte[] bytes, int offset) {
- int offset = encodeCommonPart(bytes);
+ offset = offset + encodeCommonPart(bytes, offset);
BitBuffer bits = new ByteBitBuffer(bytes);
@@ -121,6 +122,8 @@ public class SsbPass extends SsbCommonTicketPart {
bits.putChar6String(offset, 240,text);
offset = offset + 240;
+
+ return offset;
}
public int getPassSubType() {
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java b/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java
index c7f520d..73017d7 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbReservation.java
@@ -30,17 +30,17 @@ public class SsbReservation extends SsbCommonTicketPart {
@Override
- protected void decodeContent(byte[] bytes) {
+ protected int decodeContent(byte[] bytes, int offset) {
- int offset = decodeCommonPart(bytes);
+ offset = offset + decodeCommonPart(bytes);
BitBuffer bits = new ByteBitBuffer(bytes);
ticketSubType = bits.getInteger(offset, 2);
- offset = offset + 4;
+ offset = offset + 2;
stations = new SsbStations();
- stations.decode(offset, bytes);
+ offset = stations.decode(offset, bytes);
/*
* Departure date : First day of validity from the issuing date Num (<367) 9,000
@@ -60,7 +60,7 @@ public class SsbReservation extends SsbCommonTicketPart {
offset = offset + 11;
train = bits.getChar6String(offset, 30);
- offset = offset +30;
+ offset = offset + 30;
coach = bits.getInteger(offset, 10);
offset = offset + 10;
@@ -76,17 +76,19 @@ public class SsbReservation extends SsbCommonTicketPart {
text = bits.getChar6String(offset, 162);
offset = offset + 162;
+
+ return offset;
}
@Override
- protected void encodeContent(byte[] bytes) {
+ protected int encodeContent(byte[] bytes, int offset) {
- int offset = encodeCommonPart(bytes);
+ offset = offset + encodeCommonPart(bytes, offset);
BitBuffer bits = new ByteBitBuffer(bytes);
bits.putInteger(offset, 2,ticketSubType);
- offset = offset + 4;
+ offset = offset + 2;
offset = stations.encode(offset, bytes);
@@ -108,7 +110,7 @@ public class SsbReservation extends SsbCommonTicketPart {
offset = offset + 11;
bits.putChar6String(offset, 30,train);
- offset = offset +30;
+ offset = offset + 30;
bits.putInteger(offset, 10,coach);
offset = offset + 10;
@@ -117,7 +119,7 @@ public class SsbReservation extends SsbCommonTicketPart {
offset = offset + 18;
bits.put(offset, overbooking);
- offset++;
+ offset++;
bits.putInteger(offset, 14, infoCode);
offset = offset + 14;
@@ -125,6 +127,8 @@ public class SsbReservation extends SsbCommonTicketPart {
bits.putChar6String(offset, 162, text);
offset = offset + 162;
+ return offset;
+
}
public SsbStations getStations() {
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbTicketPart.java b/src/main/java/org/uic/barcode/ssbFrame/SsbTicketPart.java
index 3855c5c..5583e66 100644
--- a/src/main/java/org/uic/barcode/ssbFrame/SsbTicketPart.java
+++ b/src/main/java/org/uic/barcode/ssbFrame/SsbTicketPart.java
@@ -4,23 +4,25 @@ import org.uic.barcode.ticket.EncodingFormatException;
public abstract class SsbTicketPart {
+ public static int openDataLength = 437;
+
public void decode(byte[] bytes) throws EncodingFormatException {
if (bytes.length != 114) {
throw new EncodingFormatException("Data size does not fit to SSB");
}
- decodeContent(bytes);
+ decodeContent(bytes, 0);
};
- protected abstract void decodeContent(byte[] bytes);
+ protected abstract int decodeContent(byte[] bytes , int offset);
public void encode(byte[] bytes) throws EncodingFormatException {
if (bytes.length != 114) {
throw new EncodingFormatException("Data size does not fit to SSB");
}
- encodeContent(bytes);
+ encodeContent(bytes, 0);
}
- protected abstract void encodeContent(byte[] bytes);
+ protected abstract int encodeContent(byte[] bytes, int offset);
diff --git a/src/main/java/org/uic/barcode/staticFrame/package.html b/src/main/java/org/uic/barcode/staticFrame/package.html
index b76540b..5ad7515 100644
--- a/src/main/java/org/uic/barcode/staticFrame/package.html
+++ b/src/main/java/org/uic/barcode/staticFrame/package.html
@@ -3,19 +3,24 @@
<head></head>
<body>
-<h1>static bar code header frame</h1>
+ <h1>static bar code header frame</h1>
-<p>Provides an implementation of the static bar code header frame specified in UIC IRS 90918-9 including:<br/><br/>
-
-<ul>
- <li> encoding of the data for creating a bar code</li>
- <li> decoding of data from bar code content</li>
- <li> support for the additional header information required with the TLB content</li>
- <li> support for the TLB bar code content</li>
- <li> support for the FCB content (using the UIC FCB implementation)</li>
- <li> support for bilaterally on unilaterally defined additional content </li>
-</ul>
-</p>
+ <p>
+ Provides an implementation of the static bar code header frame
+ specified in UIC IRS 90918-9 including:<br />
+ <br />
+ <ul>
+ <li>encoding of the data for creating a bar code</li>
+ <li>decoding of data from bar code content</li>
+ <li>support for the additional header information required with
+ the TLB content</li>
+ <li>support for the TLB bar code content</li>
+ <li>support for the FCB content (using the UIC FCB
+ implementation)</li>
+ <li>support for bilaterally on unilaterally defined additional
+ content</li>
+ </ul>
+ </p>
</body>
</html> \ No newline at end of file
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/package.html b/src/main/java/org/uic/barcode/ticket/api/asn/package.html
index 307075e..214572b 100644
--- a/src/main/java/org/uic/barcode/ticket/api/asn/package.html
+++ b/src/main/java/org/uic/barcode/ticket/api/asn/package.html
@@ -1,7 +1,9 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
-<head>asn</head>
-<body>
- Provides code generated from the asn.1 specification using the openAsn compiler to implement the asn.1 encoduing and decoding using unaligned PER encoding.
+<head>asn
+</head>
+<body>Provides code generated from the asn.1 specification using
+ the openAsn compiler to implement the asn.1 encoduing and decoding
+ using unaligned PER encoding.
</body>
</html> \ No newline at end of file
diff --git a/src/main/java/org/uic/barcode/ticket/api/impl/package.html b/src/main/java/org/uic/barcode/ticket/api/impl/package.html
index 587b741..f2ef54e 100644
--- a/src/main/java/org/uic/barcode/ticket/api/impl/package.html
+++ b/src/main/java/org/uic/barcode/ticket/api/impl/package.html
@@ -1,7 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
-<head>Ticket Data Implementation</head>
+<head>Ticket Data Implementation
+</head>
<body>
- Provides a simple implementation of the ticket data interface specified in package <b>spec</b>.
+ Provides a simple implementation of the ticket data interface specified
+ in package
+ <b>spec</b>.
</body>
</html> \ No newline at end of file
diff --git a/src/main/java/org/uic/barcode/ticket/api/spec/package.html b/src/main/java/org/uic/barcode/ticket/api/spec/package.html
index 18d8b53..f3961b8 100644
--- a/src/main/java/org/uic/barcode/ticket/api/spec/package.html
+++ b/src/main/java/org/uic/barcode/ticket/api/spec/package.html
@@ -1,7 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
-<head>UIC ticket interface</head>
+<head>UIC ticket interface
+</head>
<body>
- Provides the interface specification of the ticket data. Any ticket data implementation which wants to use the provided encoder / decoder function must implement this interface. A simple implementation is provided in package <b>impl</p>.
+ Provides the interface specification of the ticket data. Any ticket
+ data implementation which wants to use the provided encoder / decoder
+ function must implement this interface. A simple implementation is
+ provided in package
+ <b>impl
+ </p>.
</body>
</html> \ No newline at end of file
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/package.html b/src/main/java/org/uic/barcode/ticket/api/utils/package.html
index a926c2d..baf156e 100644
--- a/src/main/java/org/uic/barcode/ticket/api/utils/package.html
+++ b/src/main/java/org/uic/barcode/ticket/api/utils/package.html
@@ -1,7 +1,8 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
-<head>Utilities</head>
-<body>
- Provides utilities for the asn.1 encoding and decoding of ticket data.
+<head>Utilities
+</head>
+<body>Provides utilities for the asn.1 encoding and decoding of
+ ticket data.
</body>
</html> \ No newline at end of file
diff --git a/src/main/java/org/uic/barcode/ticket/package.html b/src/main/java/org/uic/barcode/ticket/package.html
index 993e0c4..6f10316 100644
--- a/src/main/java/org/uic/barcode/ticket/package.html
+++ b/src/main/java/org/uic/barcode/ticket/package.html
@@ -1,9 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
-<head>UIC ticket data API</head>
+<head>UIC ticket data API
+</head>
<body>
- This API provides a specification of ticket data as an interface and an implementation of an encoder/decoder to encode and decode ticket data to an asn.1 PER encoded byte stream according to the UIC specification.
- <br/>
- Any ticket data implementing the interface defined in package <b>spec</b> can be encoded/decoded. The package <b>impl</b> provides a simple implementation of the ticket.
+ This API provides a specification of ticket data as an interface and an
+ implementation of an encoder/decoder to encode and decode ticket data
+ to an asn.1 PER encoded byte stream according to the UIC specification.
+ <br /> Any ticket data implementing the interface defined in package
+ <b>spec</b> can be encoded/decoded. The package
+ <b>impl</b> provides a simple implementation of the ticket.
</body>
</html> \ No newline at end of file
diff --git a/src/main/java/org/uic/barcode/utils/package.html b/src/main/java/org/uic/barcode/utils/package.html
index 45a73a9..73917d7 100644
--- a/src/main/java/org/uic/barcode/utils/package.html
+++ b/src/main/java/org/uic/barcode/utils/package.html
@@ -3,18 +3,19 @@
<head></head>
<body>
-<h1>Implementation of the header frames to bundle all data for a bar code.</h1>
+ <h1>Implementation of the header frames to bundle all data for a
+ bar code.</h1>
-<p>
+ <p>
- Provides a decoding and encoding of the header data frames for:<br/><br/>
-
- <ul>
- <li> static header as defined in UIC IRS 90918-9</li>
- <li> dynamic header as drafted for the UIC IRS 90918-9</li>
+ Provides a decoding and encoding of the header data frames for:<br />
+ <br />
+ <ul>
+ <li>static header as defined in UIC IRS 90918-9</li>
+ <li>dynamic header as drafted for the UIC IRS 90918-9</li>
+
+ </ul>
+ </p>
- </ul>
-</p>
-
</body>
</html> \ No newline at end of file