diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2023-03-14 10:31:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 10:31:01 +0100 |
commit | 4d2d3658c70347e9cffa049898b2b768bafe6174 (patch) | |
tree | 2b41ba728d15dace11d75a7d8b62976b69fcb379 /src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java | |
parent | check for inflater return code added (diff) | |
parent | update version number (diff) | |
download | UIC-barcode-1.4.0.tar UIC-barcode-1.4.0.tar.gz UIC-barcode-1.4.0.tar.bz2 UIC-barcode-1.4.0.tar.lz UIC-barcode-1.4.0.tar.xz UIC-barcode-1.4.0.tar.zst UIC-barcode-1.4.0.zip |
Diffstat (limited to 'src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java')
-rw-r--r-- | src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java b/src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java new file mode 100644 index 0000000..1f0049e --- /dev/null +++ b/src/main/java/org/uic/barcode/ssbFrame/SsbNonUic.java @@ -0,0 +1,69 @@ +package org.uic.barcode.ssbFrame; + +import org.uic.barcode.asn1.uper.AsnUtils; +import org.uic.barcode.asn1.uper.BitBuffer; +import org.uic.barcode.asn1.uper.ByteBitBuffer; + +public class SsbNonUic extends SsbTicketPart { + + + + + byte[] openData = null; + + @Override + 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"); + } + + openData = AsnUtils.fromBooleanString(sb.toString()); + + return offset + openDataLength ; + + } + + @Override + protected int encodeContent(byte[] bytes, int offset) { + + BitBuffer bits = new ByteBitBuffer(bytes); + + String bitString = AsnUtils.toBooleanString(openData); + + + for (int i = 0; i< openDataLength ; i++) { + if (i < bitString.length() && bitString.charAt(i) == '0') { + bits.put(offset + i, true); + } else { + bits.put(offset + i, false); + } + } + + return offset + openDataLength; + } + + public byte[] getOpenData() { + return openData; + } + + public void setOpenData(byte[] openData) { + this.openData = openData; + } + + + +} |