mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
rss decoders ported, no tests
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded.decoders;
|
||||
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
final class AI013103decoder extends AI013x0xDecoder {
|
||||
|
||||
AI013103decoder(BitArray information) {
|
||||
super(information);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWeightCode(StringBuilder buf, int weight) {
|
||||
buf.append("(3103)");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int checkWeight(int weight) {
|
||||
return weight;
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded.decoders;
|
||||
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
final class AI01392xDecoder extends AI01decoder {
|
||||
|
||||
private static final int HEADER_SIZE = 5 + 1 + 2;
|
||||
private static final int LAST_DIGIT_SIZE = 2;
|
||||
|
||||
AI01392xDecoder(BitArray information) {
|
||||
super(information);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseInformation() throws NotFoundException, FormatException {
|
||||
if (this.getInformation().getSize() < HEADER_SIZE + GTIN_SIZE) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
encodeCompressedGtin(buf, HEADER_SIZE);
|
||||
|
||||
int lastAIdigit =
|
||||
this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE);
|
||||
buf.append("(392");
|
||||
buf.append(lastAIdigit);
|
||||
buf.append(')');
|
||||
|
||||
DecodedInformation decodedInformation =
|
||||
this.getGeneralDecoder().decodeGeneralPurposeField(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, null);
|
||||
buf.append(decodedInformation.getNewString());
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
package com.google.zxing.oned.rss.expanded.decoders;
|
||||
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
final class AI01393xDecoder extends AI01decoder {
|
||||
|
||||
private static final int HEADER_SIZE = 5 + 1 + 2;
|
||||
private static final int LAST_DIGIT_SIZE = 2;
|
||||
private static final int FIRST_THREE_DIGITS_SIZE = 10;
|
||||
|
||||
AI01393xDecoder(BitArray information) {
|
||||
super(information);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseInformation() throws NotFoundException, FormatException {
|
||||
if (this.getInformation().getSize() < HEADER_SIZE + GTIN_SIZE) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
}
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
encodeCompressedGtin(buf, HEADER_SIZE);
|
||||
|
||||
int lastAIdigit =
|
||||
this.getGeneralDecoder().extractNumericValueFromBitArray(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE);
|
||||
|
||||
buf.append("(393");
|
||||
buf.append(lastAIdigit);
|
||||
buf.append(')');
|
||||
|
||||
int firstThreeDigits = this.getGeneralDecoder().extractNumericValueFromBitArray(
|
||||
HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, FIRST_THREE_DIGITS_SIZE);
|
||||
if (firstThreeDigits / 100 == 0) {
|
||||
buf.append('0');
|
||||
}
|
||||
if (firstThreeDigits / 10 == 0) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(firstThreeDigits);
|
||||
|
||||
DecodedInformation generalInformation = this.getGeneralDecoder().decodeGeneralPurposeField(
|
||||
HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE + FIRST_THREE_DIGITS_SIZE, null);
|
||||
buf.append(generalInformation.getNewString());
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded.decoders;
|
||||
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
|
||||
*/
|
||||
final class AI013x0x1xDecoder extends AI01weightDecoder {
|
||||
|
||||
private static final int HEADER_SIZE = 7 + 1;
|
||||
private static final int WEIGHT_SIZE = 20;
|
||||
private static final int DATE_SIZE = 16;
|
||||
|
||||
private final String dateCode;
|
||||
private final String firstAIdigits;
|
||||
|
||||
AI013x0x1xDecoder(BitArray information, String firstAIdigits, String dateCode) {
|
||||
super(information);
|
||||
this.dateCode = dateCode;
|
||||
this.firstAIdigits = firstAIdigits;
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
private void encodeCompressedDate(StringBuilder buf, int currentPos) {
|
||||
int numericDate = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, DATE_SIZE);
|
||||
if (numericDate == 38400) {
|
||||
return;
|
||||
}
|
||||
|
||||
buf.append('(');
|
||||
buf.append(this.dateCode);
|
||||
buf.append(')');
|
||||
|
||||
int day = numericDate % 32;
|
||||
numericDate /= 32;
|
||||
int month = numericDate % 12 + 1;
|
||||
numericDate /= 12;
|
||||
int year = numericDate;
|
||||
|
||||
if (year / 10 == 0) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(year);
|
||||
if (month / 10 == 0) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(month);
|
||||
if (day / 10 == 0) {
|
||||
buf.append('0');
|
||||
}
|
||||
buf.append(day);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWeightCode(StringBuilder buf, int weight) {
|
||||
buf.append('(');
|
||||
buf.append(this.firstAIdigits);
|
||||
buf.append(weight / 100000);
|
||||
buf.append(')');
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int checkWeight(int weight) {
|
||||
return weight % 100000;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded.decoders;
|
||||
|
||||
import com.google.zxing.common.BitArray;
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
abstract class AI01weightDecoder extends AI01decoder {
|
||||
|
||||
AI01weightDecoder(BitArray information) {
|
||||
super(information);
|
||||
}
|
||||
|
||||
final void encodeCompressedWeight(StringBuilder buf, int currentPos, int weightSize) {
|
||||
int originalWeightNumeric = this.getGeneralDecoder().extractNumericValueFromBitArray(currentPos, weightSize);
|
||||
addWeightCode(buf, originalWeightNumeric);
|
||||
|
||||
int weightNumeric = checkWeight(originalWeightNumeric);
|
||||
|
||||
int currentDivisor = 100000;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
if (weightNumeric / currentDivisor == 0) {
|
||||
buf.append('0');
|
||||
}
|
||||
currentDivisor /= 10;
|
||||
}
|
||||
buf.append(weightNumeric);
|
||||
}
|
||||
|
||||
protected abstract void addWeightCode(StringBuilder buf, int weight);
|
||||
|
||||
protected abstract int checkWeight(int weight);
|
||||
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded.decoders;
|
||||
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.common.BitArray;
|
||||
import com.google.zxing.oned.rss.expanded.BinaryUtil;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
abstract class AbstractDecoderTest extends Assert {
|
||||
|
||||
static final String numeric10 = "..X..XX";
|
||||
static final String numeric12 = "..X.X.X";
|
||||
static final String numeric1FNC1 = "..XXX.X";
|
||||
// static final String numericFNC11 = "XXX.XXX";
|
||||
|
||||
static final String numeric2alpha = "....";
|
||||
|
||||
static final String alphaA = "X.....";
|
||||
static final String alphaFNC1 = ".XXXX";
|
||||
static final String alpha2numeric = "...";
|
||||
static final String alpha2isoiec646 = "..X..";
|
||||
|
||||
static final String i646B = "X.....X";
|
||||
static final String i646C = "X....X.";
|
||||
static final String i646FNC1 = ".XXXX";
|
||||
static final String isoiec6462alpha = "..X..";
|
||||
|
||||
static final String compressedGtin900123456798908 = ".........X..XXX.X.X.X...XX.XXXXX.XXXX.X.";
|
||||
static final String compressedGtin900000000000008 = "........................................";
|
||||
|
||||
static final String compressed15bitWeight1750 = "....XX.XX.X.XX.";
|
||||
static final String compressed15bitWeight11750 = ".X.XX.XXXX..XX.";
|
||||
static final String compressed15bitWeight0 = "...............";
|
||||
|
||||
static final String compressed20bitWeight1750 = ".........XX.XX.X.XX.";
|
||||
|
||||
static final String compressedDateMarch12th2010 = "....XXXX.X..XX..";
|
||||
static final String compressedDateEnd = "X..X.XX.........";
|
||||
|
||||
static void assertCorrectBinaryString(CharSequence binaryString,
|
||||
String expectedNumber) throws NotFoundException, FormatException {
|
||||
BitArray binary = BinaryUtil.buildBitArrayFromStringWithoutSpaces(binaryString);
|
||||
AbstractExpandedDecoder decoder = AbstractExpandedDecoder.createDecoder(binary);
|
||||
String result = decoder.parseInformation();
|
||||
assertEquals(expectedNumber, result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2010 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
use crate::oned::rss::expanded::{binary_util, decoders::AbstractExpandedDecoder};
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
|
||||
const numeric10: &str = "..X..XX";
|
||||
const numeric12: &str = "..X.X.X";
|
||||
const numeric1FNC1: &str = "..XXX.X";
|
||||
// static final String numericFNC11 = "XXX.XXX";
|
||||
|
||||
const numeric2alpha: &str = "....";
|
||||
|
||||
const alphaA: &str = "X.....";
|
||||
const alphaFNC1: &str = ".XXXX";
|
||||
const alpha2numeric: &str = "...";
|
||||
const alpha2isoiec646: &str = "..X..";
|
||||
|
||||
const i646B: &str = "X.....X";
|
||||
const i646C: &str = "X....X.";
|
||||
const i646FNC1: &str = ".XXXX";
|
||||
const isoiec6462alpha: &str = "..X..";
|
||||
|
||||
const compressedGtin900123456798908: &str = ".........X..XXX.X.X.X...XX.XXXXX.XXXX.X.";
|
||||
const compressedGtin900000000000008: &str = "........................................";
|
||||
|
||||
const compressed15bitWeight1750: &str = "....XX.XX.X.XX.";
|
||||
const compressed15bitWeight11750: &str = ".X.XX.XXXX..XX.";
|
||||
const compressed15bitWeight0: &str = "...............";
|
||||
|
||||
const compressed20bitWeight1750: &str = ".........XX.XX.X.XX.";
|
||||
|
||||
const compressedDateMarch12th2010: &str = "....XXXX.X..XX..";
|
||||
const compressedDateEnd: &str = "X..X.XX.........";
|
||||
|
||||
pub fn assertCorrectBinaryString(binaryString: &str, expectedNumber: &str) {
|
||||
let binary = binary_util::buildBitArrayFromStringWithoutSpaces(binaryString).expect("built");
|
||||
panic!("finish implementation for test");
|
||||
// let decoder = AbstractExpandedDecoder.createDecoder(binary);
|
||||
// let result = decoder.parseInformation();
|
||||
// assert_eq!(expectedNumber, result);
|
||||
}
|
||||
@@ -24,34 +24,37 @@
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded.decoders;
|
||||
use crate::common::BitArray;
|
||||
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.common.BitArray;
|
||||
use super::{AI013x0xDecoder, AI01decoder, AI01weightDecoder, AbstractExpandedDecoder};
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
abstract class AI013x0xDecoder extends AI01weightDecoder {
|
||||
pub struct AI013103decoder<'a>(AI013x0xDecoder<'a>);
|
||||
|
||||
private static final int HEADER_SIZE = 4 + 1;
|
||||
private static final int WEIGHT_SIZE = 15;
|
||||
|
||||
AI013x0xDecoder(BitArray information) {
|
||||
super(information);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseInformation() throws NotFoundException {
|
||||
if (this.getInformation().getSize() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE) {
|
||||
throw NotFoundException.getNotFoundInstance();
|
||||
impl AI01weightDecoder for AI013103decoder<'_> {
|
||||
fn addWeightCode(&self, buf: &mut String, _weight: u32) {
|
||||
buf.push_str("(3103)");
|
||||
}
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
encodeCompressedGtin(buf, HEADER_SIZE);
|
||||
encodeCompressedWeight(buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE);
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
fn checkWeight(&self, weight: u32) -> u32 {
|
||||
weight
|
||||
}
|
||||
}
|
||||
impl AbstractExpandedDecoder for AI013103decoder<'_> {
|
||||
fn parseInformation(&mut self) -> Result<String, crate::Exceptions> {
|
||||
self.0.parseInformation()
|
||||
}
|
||||
|
||||
fn getGeneralDecoder(&self) -> &super::GeneralAppIdDecoder {
|
||||
self.0.getGeneralDecoder()
|
||||
}
|
||||
}
|
||||
impl AI01decoder for AI013103decoder<'_> {}
|
||||
|
||||
impl<'a> AI013103decoder<'_> {
|
||||
pub fn new(information: &'a BitArray) -> AI013103decoder<'a> {
|
||||
AI013103decoder(AI013x0xDecoder::new(information))
|
||||
}
|
||||
}
|
||||
67
src/oned/rss/expanded/decoders/ai_01320x_decoder.rs
Normal file
67
src/oned/rss/expanded/decoders/ai_01320x_decoder.rs
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2010 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
use crate::common::BitArray;
|
||||
|
||||
use super::{AI013x0xDecoder, AI01decoder, AI01weightDecoder, AbstractExpandedDecoder};
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
pub struct AI01320xDecoder<'a>(AI013x0xDecoder<'a>);
|
||||
|
||||
impl AI01weightDecoder for AI01320xDecoder<'_> {
|
||||
fn addWeightCode(&self, buf: &mut String, weight: u32) {
|
||||
if weight < 10000 {
|
||||
buf.push_str("(3202)");
|
||||
} else {
|
||||
buf.push_str("(3203)");
|
||||
}
|
||||
}
|
||||
|
||||
fn checkWeight(&self, weight: u32) -> u32 {
|
||||
if weight < 10000 {
|
||||
weight
|
||||
} else {
|
||||
weight - 10000
|
||||
}
|
||||
}
|
||||
}
|
||||
impl AbstractExpandedDecoder for AI01320xDecoder<'_> {
|
||||
fn parseInformation(&mut self) -> Result<String, crate::Exceptions> {
|
||||
self.0.parseInformation()
|
||||
}
|
||||
|
||||
fn getGeneralDecoder(&self) -> &super::GeneralAppIdDecoder {
|
||||
self.0.getGeneralDecoder()
|
||||
}
|
||||
}
|
||||
impl AI01decoder for AI01320xDecoder<'_> {}
|
||||
impl<'a> AI01320xDecoder<'_> {
|
||||
pub fn new(information: &'a BitArray) -> AI01320xDecoder<'a> {
|
||||
AI01320xDecoder(AI013x0xDecoder::new(information))
|
||||
}
|
||||
}
|
||||
80
src/oned/rss/expanded/decoders/ai_01392x_decoder.rs
Normal file
80
src/oned/rss/expanded/decoders/ai_01392x_decoder.rs
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2010 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
use crate::common::BitArray;
|
||||
|
||||
use super::{AI01decoder, AbstractExpandedDecoder, GeneralAppIdDecoder};
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
pub struct AI01392xDecoder<'a> {
|
||||
information: &'a BitArray,
|
||||
general_decoder: GeneralAppIdDecoder<'a>,
|
||||
}
|
||||
impl AI01decoder for AI01392xDecoder<'_> {}
|
||||
impl AbstractExpandedDecoder for AI01392xDecoder<'_> {
|
||||
fn parseInformation(&mut self) -> Result<String, crate::Exceptions> {
|
||||
if self.information.getSize() < Self::HEADER_SIZE + Self::GTIN_SIZE as usize {
|
||||
return Err(crate::Exceptions::NotFoundException("".to_owned()));
|
||||
}
|
||||
|
||||
let mut buf = String::new();
|
||||
|
||||
self.encodeCompressedGtin(&mut buf, Self::HEADER_SIZE);
|
||||
|
||||
let lastAIdigit = self.getGeneralDecoder().extractNumericValueFromBitArray(
|
||||
Self::HEADER_SIZE + Self::GTIN_SIZE as usize,
|
||||
Self::LAST_DIGIT_SIZE as u32,
|
||||
);
|
||||
buf.push_str("(392");
|
||||
buf.push_str(&lastAIdigit.to_string());
|
||||
buf.push(')');
|
||||
|
||||
let decodedInformation = self.general_decoder.decodeGeneralPurposeField(
|
||||
Self::HEADER_SIZE + Self::GTIN_SIZE as usize + Self::LAST_DIGIT_SIZE,
|
||||
"",
|
||||
)?;
|
||||
buf.push_str(&decodedInformation.getNewString());
|
||||
|
||||
Ok(buf)
|
||||
}
|
||||
|
||||
fn getGeneralDecoder(&self) -> &super::GeneralAppIdDecoder {
|
||||
&self.general_decoder
|
||||
}
|
||||
}
|
||||
impl<'a> AI01392xDecoder<'_> {
|
||||
const HEADER_SIZE: usize = 5 + 1 + 2;
|
||||
const LAST_DIGIT_SIZE: usize = 2;
|
||||
|
||||
pub fn new(information: &'a BitArray) -> AI01392xDecoder<'a> {
|
||||
AI01392xDecoder {
|
||||
information,
|
||||
general_decoder: GeneralAppIdDecoder::new(information),
|
||||
}
|
||||
}
|
||||
}
|
||||
97
src/oned/rss/expanded/decoders/ai_01393x_decoder.rs
Normal file
97
src/oned/rss/expanded/decoders/ai_01393x_decoder.rs
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2010 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
use crate::common::BitArray;
|
||||
|
||||
use super::{AI01decoder, AbstractExpandedDecoder, GeneralAppIdDecoder};
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
pub struct AI01393xDecoder<'a> {
|
||||
information: &'a BitArray,
|
||||
general_decoder: GeneralAppIdDecoder<'a>,
|
||||
}
|
||||
impl AI01decoder for AI01393xDecoder<'_> {}
|
||||
impl AbstractExpandedDecoder for AI01393xDecoder<'_> {
|
||||
fn parseInformation(&mut self) -> Result<String, crate::Exceptions> {
|
||||
if self.information.getSize() < Self::HEADER_SIZE + Self::GTIN_SIZE as usize {
|
||||
return Err(crate::Exceptions::NotFoundException("".to_owned()));
|
||||
}
|
||||
|
||||
let mut buf = String::new();
|
||||
|
||||
self.encodeCompressedGtin(&mut buf, Self::HEADER_SIZE);
|
||||
|
||||
let lastAIdigit = self.getGeneralDecoder().extractNumericValueFromBitArray(
|
||||
Self::HEADER_SIZE + Self::GTIN_SIZE as usize,
|
||||
Self::LAST_DIGIT_SIZE as u32,
|
||||
);
|
||||
|
||||
buf.push_str("(393");
|
||||
buf.push_str(&lastAIdigit.to_string());
|
||||
buf.push(')');
|
||||
|
||||
let firstThreeDigits = self.getGeneralDecoder().extractNumericValueFromBitArray(
|
||||
Self::HEADER_SIZE + Self::GTIN_SIZE as usize + Self::LAST_DIGIT_SIZE,
|
||||
Self::FIRST_THREE_DIGITS_SIZE as u32,
|
||||
);
|
||||
if firstThreeDigits / 100 == 0 {
|
||||
buf.push('0');
|
||||
}
|
||||
if firstThreeDigits / 10 == 0 {
|
||||
buf.push('0');
|
||||
}
|
||||
buf.push_str(&firstThreeDigits.to_string());
|
||||
|
||||
let generalInformation = self.general_decoder.decodeGeneralPurposeField(
|
||||
Self::HEADER_SIZE
|
||||
+ Self::GTIN_SIZE as usize
|
||||
+ Self::LAST_DIGIT_SIZE
|
||||
+ Self::FIRST_THREE_DIGITS_SIZE,
|
||||
"",
|
||||
)?;
|
||||
buf.push_str(&generalInformation.getNewString());
|
||||
|
||||
Ok(buf)
|
||||
}
|
||||
|
||||
fn getGeneralDecoder(&self) -> &GeneralAppIdDecoder {
|
||||
&self.general_decoder
|
||||
}
|
||||
}
|
||||
impl<'a> AI01393xDecoder<'_> {
|
||||
const HEADER_SIZE: usize = 5 + 1 + 2;
|
||||
const LAST_DIGIT_SIZE: usize = 2;
|
||||
const FIRST_THREE_DIGITS_SIZE: usize = 10;
|
||||
|
||||
pub fn new(information: &'a BitArray) -> AI01393xDecoder<'a> {
|
||||
AI01393xDecoder {
|
||||
information,
|
||||
general_decoder: GeneralAppIdDecoder::new(information),
|
||||
}
|
||||
}
|
||||
}
|
||||
133
src/oned/rss/expanded/decoders/ai_013x0x1x_decoder.rs
Normal file
133
src/oned/rss/expanded/decoders/ai_013x0x1x_decoder.rs
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (C) 2010 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
use crate::common::BitArray;
|
||||
|
||||
use super::{AI01decoder, AI01weightDecoder, AbstractExpandedDecoder, GeneralAppIdDecoder};
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
|
||||
*/
|
||||
pub struct AI013x0x1xDecoder<'a> {
|
||||
information: &'a BitArray,
|
||||
decoder: GeneralAppIdDecoder<'a>,
|
||||
dateCode: String,
|
||||
firstAIdigits: String,
|
||||
}
|
||||
|
||||
impl AI01weightDecoder for AI013x0x1xDecoder<'_> {
|
||||
fn addWeightCode(&self, buf: &mut String, weight: u32) {
|
||||
buf.push('(');
|
||||
buf.push_str(&self.firstAIdigits);
|
||||
buf.push_str(&(weight / 100000).to_string());
|
||||
buf.push(')');
|
||||
}
|
||||
|
||||
fn checkWeight(&self, weight: u32) -> u32 {
|
||||
weight % 100000
|
||||
}
|
||||
}
|
||||
impl AI01decoder for AI013x0x1xDecoder<'_> {}
|
||||
impl AbstractExpandedDecoder for AI013x0x1xDecoder<'_> {
|
||||
fn parseInformation(&mut self) -> Result<String, crate::Exceptions> {
|
||||
if self.information.getSize()
|
||||
!= Self::HEADER_SIZE + Self::GTIN_SIZE as usize + Self::WEIGHT_SIZE + Self::DATE_SIZE
|
||||
{
|
||||
return Err(crate::Exceptions::NotFoundException("".to_owned()));
|
||||
}
|
||||
|
||||
let mut buf = String::new();
|
||||
|
||||
self.encodeCompressedGtin(&mut buf, Self::HEADER_SIZE);
|
||||
self.encodeCompressedWeight(
|
||||
&mut buf,
|
||||
Self::HEADER_SIZE + Self::GTIN_SIZE as usize,
|
||||
Self::WEIGHT_SIZE as u32,
|
||||
);
|
||||
self.encodeCompressedDate(
|
||||
&mut buf,
|
||||
Self::HEADER_SIZE + Self::GTIN_SIZE as usize + Self::WEIGHT_SIZE,
|
||||
);
|
||||
|
||||
Ok(buf)
|
||||
}
|
||||
|
||||
fn getGeneralDecoder(&self) -> &super::GeneralAppIdDecoder {
|
||||
&self.decoder
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AI013x0x1xDecoder<'_> {
|
||||
const HEADER_SIZE: usize = 7 + 1;
|
||||
const WEIGHT_SIZE: usize = 20;
|
||||
const DATE_SIZE: usize = 16;
|
||||
|
||||
pub fn new(
|
||||
information: &'a BitArray,
|
||||
firstAIdigits: String,
|
||||
dateCode: String,
|
||||
) -> AI013x0x1xDecoder<'a> {
|
||||
AI013x0x1xDecoder {
|
||||
information,
|
||||
decoder: GeneralAppIdDecoder::new(information),
|
||||
dateCode,
|
||||
firstAIdigits,
|
||||
}
|
||||
}
|
||||
|
||||
fn encodeCompressedDate(&self, buf: &mut String, currentPos: usize) {
|
||||
let mut numericDate = self
|
||||
.getGeneralDecoder()
|
||||
.extractNumericValueFromBitArray(currentPos, Self::DATE_SIZE as u32);
|
||||
if numericDate == 38400 {
|
||||
return;
|
||||
}
|
||||
|
||||
buf.push('(');
|
||||
buf.push_str(&self.dateCode);
|
||||
buf.push(')');
|
||||
|
||||
let day = numericDate % 32;
|
||||
numericDate /= 32;
|
||||
let month = numericDate % 12 + 1;
|
||||
numericDate /= 12;
|
||||
let year = numericDate;
|
||||
|
||||
if year / 10 == 0 {
|
||||
buf.push('0');
|
||||
}
|
||||
buf.push_str(&year.to_string());
|
||||
if month / 10 == 0 {
|
||||
buf.push('0');
|
||||
}
|
||||
buf.push_str(&month.to_string());
|
||||
if day / 10 == 0 {
|
||||
buf.push('0');
|
||||
}
|
||||
buf.push_str(&day.to_string());
|
||||
}
|
||||
}
|
||||
83
src/oned/rss/expanded/decoders/ai_013x0x_decoder.rs
Normal file
83
src/oned/rss/expanded/decoders/ai_013x0x_decoder.rs
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2010 ZXing authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
use crate::common::BitArray;
|
||||
|
||||
use super::{AI01decoder, AI01weightDecoder, AbstractExpandedDecoder, GeneralAppIdDecoder};
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
pub struct AI013x0xDecoder<'a> {
|
||||
information: &'a BitArray,
|
||||
decoder: GeneralAppIdDecoder<'a>,
|
||||
}
|
||||
impl AI01weightDecoder for AI013x0xDecoder<'_> {
|
||||
fn addWeightCode(&self, _buf: &mut String, _weight: u32) {
|
||||
unimplemented!("no java implementation exists")
|
||||
}
|
||||
|
||||
fn checkWeight(&self, _weight: u32) -> u32 {
|
||||
unimplemented!("no java implementation exists")
|
||||
}
|
||||
}
|
||||
impl AbstractExpandedDecoder for AI013x0xDecoder<'_> {
|
||||
fn parseInformation(&mut self) -> Result<String, crate::Exceptions> {
|
||||
if self.information.getSize()
|
||||
!= Self::HEADER_SIZE + Self::GTIN_SIZE as usize + Self::WEIGHT_SIZE
|
||||
{
|
||||
return Err(crate::Exceptions::NotFoundException("".to_owned()));
|
||||
}
|
||||
|
||||
let mut buf = String::new();
|
||||
|
||||
self.encodeCompressedGtin(&mut buf, Self::HEADER_SIZE);
|
||||
self.encodeCompressedWeight(
|
||||
&mut buf,
|
||||
Self::HEADER_SIZE + Self::GTIN_SIZE as usize,
|
||||
Self::WEIGHT_SIZE as u32,
|
||||
);
|
||||
|
||||
Ok(buf)
|
||||
}
|
||||
|
||||
fn getGeneralDecoder(&self) -> &GeneralAppIdDecoder {
|
||||
&self.decoder
|
||||
}
|
||||
}
|
||||
impl AI01decoder for AI013x0xDecoder<'_> {}
|
||||
|
||||
impl<'a> AI013x0xDecoder<'_> {
|
||||
const HEADER_SIZE: usize = 4 + 1;
|
||||
const WEIGHT_SIZE: usize = 15;
|
||||
|
||||
pub fn new(information: &'a BitArray) -> AI013x0xDecoder<'a> {
|
||||
AI013x0xDecoder {
|
||||
information,
|
||||
decoder: GeneralAppIdDecoder::new(information),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,34 +24,32 @@
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded.decoders;
|
||||
|
||||
import com.google.zxing.common.BitArray;
|
||||
use super::AI01decoder;
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
*/
|
||||
final class AI01320xDecoder extends AI013x0xDecoder {
|
||||
pub trait AI01weightDecoder: AI01decoder {
|
||||
fn encodeCompressedWeight(&self, buf: &mut String, currentPos: usize, weightSize: u32) {
|
||||
let originalWeightNumeric = self
|
||||
.getGeneralDecoder()
|
||||
.extractNumericValueFromBitArray(currentPos, weightSize);
|
||||
self.addWeightCode(buf, originalWeightNumeric);
|
||||
|
||||
AI01320xDecoder(BitArray information) {
|
||||
super(information);
|
||||
}
|
||||
let weightNumeric = self.checkWeight(originalWeightNumeric);
|
||||
|
||||
@Override
|
||||
protected void addWeightCode(StringBuilder buf, int weight) {
|
||||
if (weight < 10000) {
|
||||
buf.append("(3202)");
|
||||
} else {
|
||||
buf.append("(3203)");
|
||||
let mut currentDivisor = 100000;
|
||||
for _i in 0..5 {
|
||||
// for (int i = 0; i < 5; ++i) {
|
||||
if weightNumeric / currentDivisor == 0 {
|
||||
buf.push('0');
|
||||
}
|
||||
currentDivisor /= 10;
|
||||
}
|
||||
buf.push_str(&weightNumeric.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int checkWeight(int weight) {
|
||||
if (weight < 10000) {
|
||||
return weight;
|
||||
}
|
||||
return weight - 10000;
|
||||
}
|
||||
fn addWeightCode(&self, buf: &mut String, weight: u32);
|
||||
|
||||
fn checkWeight(&self, weight: u32) -> u32;
|
||||
}
|
||||
@@ -24,27 +24,36 @@
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded.decoders;
|
||||
use crate::common::BitArray;
|
||||
|
||||
import com.google.zxing.FormatException;
|
||||
import com.google.zxing.NotFoundException;
|
||||
import com.google.zxing.common.BitArray;
|
||||
use super::{AbstractExpandedDecoder, GeneralAppIdDecoder};
|
||||
|
||||
/**
|
||||
* @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
|
||||
* @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
|
||||
*/
|
||||
final class AnyAIDecoder extends AbstractExpandedDecoder {
|
||||
|
||||
private static final int HEADER_SIZE = 2 + 1 + 2;
|
||||
|
||||
AnyAIDecoder(BitArray information) {
|
||||
super(information);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseInformation() throws NotFoundException, FormatException {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
return this.getGeneralDecoder().decodeAllCodes(buf, HEADER_SIZE);
|
||||
}
|
||||
pub struct AnyAIDecoder<'a> {
|
||||
// information: &'a BitArray,
|
||||
general_decoder: GeneralAppIdDecoder<'a>,
|
||||
}
|
||||
impl AbstractExpandedDecoder for AnyAIDecoder<'_> {
|
||||
fn parseInformation(&mut self) -> Result<String, crate::Exceptions> {
|
||||
let buf = String::new();
|
||||
self.general_decoder.decodeAllCodes(buf, Self::HEADER_SIZE)
|
||||
}
|
||||
|
||||
fn getGeneralDecoder(&self) -> &super::GeneralAppIdDecoder {
|
||||
&self.general_decoder
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> AnyAIDecoder<'_> {
|
||||
const HEADER_SIZE: usize = 2 + 1 + 2;
|
||||
|
||||
pub fn new(information: &'a BitArray) -> AnyAIDecoder<'a> {
|
||||
AnyAIDecoder {
|
||||
// information,
|
||||
general_decoder: GeneralAppIdDecoder::new(information),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,3 +23,29 @@ mod block_parsed_result;
|
||||
pub use block_parsed_result::*;
|
||||
|
||||
pub mod field_parser;
|
||||
|
||||
mod ai_01_weight_decoder;
|
||||
pub use ai_01_weight_decoder::*;
|
||||
|
||||
mod ai_013x0x1x_decoder;
|
||||
pub use ai_013x0x1x_decoder::*;
|
||||
|
||||
mod abstract_decoder_test_utils;
|
||||
|
||||
mod ai_013x0x_decoder;
|
||||
pub use ai_013x0x_decoder::*;
|
||||
|
||||
mod ai_01320x_decoder;
|
||||
pub use ai_01320x_decoder::*;
|
||||
|
||||
mod any_ai_decoder;
|
||||
pub use any_ai_decoder::*;
|
||||
|
||||
mod ai_01392x_decoder;
|
||||
pub use ai_01392x_decoder::*;
|
||||
|
||||
mod ai_01393x_decoder;
|
||||
pub use ai_01393x_decoder::*;
|
||||
|
||||
mod ai_013103_decoder;
|
||||
pub use ai_013103_decoder::*;
|
||||
|
||||
Reference in New Issue
Block a user