private boolean isNumericToAlphaNumericLatch(int pos) { // Next is alphanumeric if there are 4 positions and they are all zeros, or // if there is a subset of this just before the end of the symbol if (pos + 1 > this.information.getSize()) { return false; } for (int i = 0; i < 4 && i + pos < this.information.getSize(); ++i) { if (this.information.get(pos + i)) { return false; } } return true; } }
private boolean isAlphaOr646ToNumericLatch(int pos) { // Next is alphanumeric if there are 3 positions and they are all zeros if (pos + 3 > this.information.getSize()) { return false; } for (int i = pos; i < pos + 3; ++i) { if (this.information.get(i)) { return false; } } return true; }
private boolean isAlphaOr646ToNumericLatch(int pos) { // Next is alphanumeric if there are 3 positions and they are all zeros if (pos + 3 > this.information.getSize()) { return false; } for (int i = pos; i < pos + 3; ++i) { if (this.information.get(i)) { return false; } } return true; }
private boolean isStillNumeric(int pos) { // It's numeric if it still has 7 positions // and one of the first 4 bits is "1". if (pos + 7 > this.information.getSize()) { return pos + 4 <= this.information.getSize(); } for (int i = pos; i < pos + 3; ++i) { if (this.information.get(i)) { return true; } } return this.information.get(pos + 3); }
private boolean isStillNumeric(int pos) { // It's numeric if it still has 7 positions // and one of the first 4 bits is "1". if (pos + 7 > this.information.getSize()) { return pos + 4 <= this.information.getSize(); } for (int i = pos; i < pos + 3; ++i) { if (this.information.get(i)) { return true; } } return this.information.get(pos + 3); }
private boolean isStillAlpha(int pos) { if (pos + 5 > this.information.getSize()) { return false; } // We now check if it's a valid 5-bit value (0..9 and FNC1) int fiveBitValue = extractNumericValueFromBitArray(pos, 5); if (fiveBitValue >= 5 && fiveBitValue < 16) { return true; } if (pos + 6 > this.information.getSize()) { return false; } int sixBitValue = extractNumericValueFromBitArray(pos, 6); return sixBitValue >= 16 && sixBitValue < 63; // 63 not included }
private DecodedNumeric decodeNumeric(int pos) throws FormatException { if (pos + 7 > this.information.getSize()) { int numeric = extractNumericValueFromBitArray(pos, 4); if (numeric == 0) { return new DecodedNumeric(this.information.getSize(), DecodedNumeric.FNC1, DecodedNumeric.FNC1); } return new DecodedNumeric(this.information.getSize(), numeric - 1, DecodedNumeric.FNC1); } int numeric = extractNumericValueFromBitArray(pos, 7); int digit1 = (numeric - 8) / 11; int digit2 = (numeric - 8) % 11; return new DecodedNumeric(pos + 7, digit1, digit2); }
private DecodedNumeric decodeNumeric(int pos) throws FormatException { if (pos + 7 > this.information.getSize()) { int numeric = extractNumericValueFromBitArray(pos, 4); if (numeric == 0) { return new DecodedNumeric(this.information.getSize(), DecodedNumeric.FNC1, DecodedNumeric.FNC1); } return new DecodedNumeric(this.information.getSize(), numeric - 1, DecodedNumeric.FNC1); } int numeric = extractNumericValueFromBitArray(pos, 7); int digit1 = (numeric - 8) / 11; int digit2 = (numeric - 8) % 11; return new DecodedNumeric(pos + 7, digit1, digit2); }
public static void makeVersionInfoBits(int version, BitArray bits) throws WriterException { bits.appendBits(version, 6); int bchCode = calculateBCHCode(version, VERSION_INFO_POLY); bits.appendBits(bchCode, 12); if (bits.getSize() != 18) { // Just in case. throw new WriterException("should not happen but we got: " + bits.getSize()); } }
public static void makeVersionInfoBits(int version, BitArray bits) throws WriterException { bits.appendBits(version, 6); int bchCode = calculateBCHCode(version, VERSION_INFO_POLY); bits.appendBits(bchCode, 12); if (bits.getSize() != 18) { // Just in case. throw new WriterException("should not happen but we got: " + bits.getSize()); } }
@Override public String parseInformation() throws NotFoundException { if (this.getInformation().getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE) { throw NotFoundException.getNotFoundInstance(); } StringBuilder buf = new StringBuilder(); encodeCompressedGtin(buf, HEADER_SIZE); encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); return buf.toString(); } }
@Override public String parseInformation() throws NotFoundException { if (this.getInformation().getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE) { throw NotFoundException.getNotFoundInstance(); } StringBuilder buf = new StringBuilder(); encodeCompressedGtin(buf, HEADER_SIZE); encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); return buf.toString(); } }
static void makeVersionInfoBits(Version version, BitArray bits) throws WriterException { bits.appendBits(version.getVersionNumber(), 6); int bchCode = calculateBCHCode(version.getVersionNumber(), VERSION_INFO_POLY); bits.appendBits(bchCode, 12); if (bits.getSize() != 18) { // Just in case. throw new WriterException("should not happen but we got: " + bits.getSize()); } }
@Override public String parseInformation() throws NotFoundException { if (this.getInformation().getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE + DATE_SIZE) { throw NotFoundException.getNotFoundInstance(); } StringBuilder buf = new StringBuilder(); encodeCompressedGtin(buf, HEADER_SIZE); encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); encodeCompressedDate(buf, HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE); return buf.toString(); }
@Override public String parseInformation() throws NotFoundException { if (this.getInformation().getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE + DATE_SIZE) { throw NotFoundException.getNotFoundInstance(); } StringBuilder buf = new StringBuilder(); encodeCompressedGtin(buf, HEADER_SIZE); encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE); encodeCompressedDate(buf, HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE); return buf.toString(); }
static void makeVersionInfoBits(Version version, BitArray bits) throws WriterException { bits.appendBits(version.getVersionNumber(), 6); int bchCode = calculateBCHCode(version.getVersionNumber(), VERSION_INFO_POLY); bits.appendBits(bchCode, 12); if (bits.getSize() != 18) { // Just in case. throw new WriterException("should not happen but we got: " + bits.getSize()); } }
public void appendBitArray(BitArray other) { int otherSize = other.getSize(); ensureCapacity(size + otherSize); for (int i = 0; i < otherSize; i++) { appendBit(other.get(i)); } }
public void appendBitArray(BitArray other) { int otherSize = other.getSize(); ensureCapacity(size + otherSize); for (int i = 0; i < otherSize; i++) { appendBit(other.get(i)); } }