diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2023-03-10 16:49:58 +0100 |
---|---|---|
committer | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2023-03-10 16:49:58 +0100 |
commit | 7ec06722923d96d2e51300bafb44b920ca341d58 (patch) | |
tree | 3a3635f56092a4fe1d6c15d88872ea699fb97666 /src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java | |
parent | ssb added to encoder and decoder (diff) | |
download | UIC-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 '')
-rw-r--r-- | src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java | 41 |
1 files changed, 32 insertions, 9 deletions
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() { |