, id: &String) {
- self.ranges.add(&range);
- self.country_identifiers.add(&id);
- }
-
- fn init_if_needed(&self) {
- if !self.ranges.is_empty() {
- return;
- }
- self.add( : vec![i32; 2] = vec![0, 19, ]
- , "US/CA");
- self.add( : vec![i32; 2] = vec![30, 39, ]
- , "US");
- self.add( : vec![i32; 2] = vec![60, 139, ]
- , "US/CA");
- self.add( : vec![i32; 2] = vec![300, 379, ]
- , "FR");
- self.add( : vec![i32; 1] = vec![380, ]
- , "BG");
- self.add( : vec![i32; 1] = vec![383, ]
- , "SI");
- self.add( : vec![i32; 1] = vec![385, ]
- , "HR");
- self.add( : vec![i32; 1] = vec![387, ]
- , "BA");
- self.add( : vec![i32; 2] = vec![400, 440, ]
- , "DE");
- self.add( : vec![i32; 2] = vec![450, 459, ]
- , "JP");
- self.add( : vec![i32; 2] = vec![460, 469, ]
- , "RU");
- self.add( : vec![i32; 1] = vec![471, ]
- , "TW");
- self.add( : vec![i32; 1] = vec![474, ]
- , "EE");
- self.add( : vec![i32; 1] = vec![475, ]
- , "LV");
- self.add( : vec![i32; 1] = vec![476, ]
- , "AZ");
- self.add( : vec![i32; 1] = vec![477, ]
- , "LT");
- self.add( : vec![i32; 1] = vec![478, ]
- , "UZ");
- self.add( : vec![i32; 1] = vec![479, ]
- , "LK");
- self.add( : vec![i32; 1] = vec![480, ]
- , "PH");
- self.add( : vec![i32; 1] = vec![481, ]
- , "BY");
- self.add( : vec![i32; 1] = vec![482, ]
- , "UA");
- self.add( : vec![i32; 1] = vec![484, ]
- , "MD");
- self.add( : vec![i32; 1] = vec![485, ]
- , "AM");
- self.add( : vec![i32; 1] = vec![486, ]
- , "GE");
- self.add( : vec![i32; 1] = vec![487, ]
- , "KZ");
- self.add( : vec![i32; 1] = vec![489, ]
- , "HK");
- self.add( : vec![i32; 2] = vec![490, 499, ]
- , "JP");
- self.add( : vec![i32; 2] = vec![500, 509, ]
- , "GB");
- self.add( : vec![i32; 1] = vec![520, ]
- , "GR");
- self.add( : vec![i32; 1] = vec![528, ]
- , "LB");
- self.add( : vec![i32; 1] = vec![529, ]
- , "CY");
- self.add( : vec![i32; 1] = vec![531, ]
- , "MK");
- self.add( : vec![i32; 1] = vec![535, ]
- , "MT");
- self.add( : vec![i32; 1] = vec![539, ]
- , "IE");
- self.add( : vec![i32; 2] = vec![540, 549, ]
- , "BE/LU");
- self.add( : vec![i32; 1] = vec![560, ]
- , "PT");
- self.add( : vec![i32; 1] = vec![569, ]
- , "IS");
- self.add( : vec![i32; 2] = vec![570, 579, ]
- , "DK");
- self.add( : vec![i32; 1] = vec![590, ]
- , "PL");
- self.add( : vec![i32; 1] = vec![594, ]
- , "RO");
- self.add( : vec![i32; 1] = vec![599, ]
- , "HU");
- self.add( : vec![i32; 2] = vec![600, 601, ]
- , "ZA");
- self.add( : vec![i32; 1] = vec![603, ]
- , "GH");
- self.add( : vec![i32; 1] = vec![608, ]
- , "BH");
- self.add( : vec![i32; 1] = vec![609, ]
- , "MU");
- self.add( : vec![i32; 1] = vec![611, ]
- , "MA");
- self.add( : vec![i32; 1] = vec![613, ]
- , "DZ");
- self.add( : vec![i32; 1] = vec![616, ]
- , "KE");
- self.add( : vec![i32; 1] = vec![618, ]
- , "CI");
- self.add( : vec![i32; 1] = vec![619, ]
- , "TN");
- self.add( : vec![i32; 1] = vec![621, ]
- , "SY");
- self.add( : vec![i32; 1] = vec![622, ]
- , "EG");
- self.add( : vec![i32; 1] = vec![624, ]
- , "LY");
- self.add( : vec![i32; 1] = vec![625, ]
- , "JO");
- self.add( : vec![i32; 1] = vec![626, ]
- , "IR");
- self.add( : vec![i32; 1] = vec![627, ]
- , "KW");
- self.add( : vec![i32; 1] = vec![628, ]
- , "SA");
- self.add( : vec![i32; 1] = vec![629, ]
- , "AE");
- self.add( : vec![i32; 2] = vec![640, 649, ]
- , "FI");
- self.add( : vec![i32; 2] = vec![690, 695, ]
- , "CN");
- self.add( : vec![i32; 2] = vec![700, 709, ]
- , "NO");
- self.add( : vec![i32; 1] = vec![729, ]
- , "IL");
- self.add( : vec![i32; 2] = vec![730, 739, ]
- , "SE");
- self.add( : vec![i32; 1] = vec![740, ]
- , "GT");
- self.add( : vec![i32; 1] = vec![741, ]
- , "SV");
- self.add( : vec![i32; 1] = vec![742, ]
- , "HN");
- self.add( : vec![i32; 1] = vec![743, ]
- , "NI");
- self.add( : vec![i32; 1] = vec![744, ]
- , "CR");
- self.add( : vec![i32; 1] = vec![745, ]
- , "PA");
- self.add( : vec![i32; 1] = vec![746, ]
- , "DO");
- self.add( : vec![i32; 1] = vec![750, ]
- , "MX");
- self.add( : vec![i32; 2] = vec![754, 755, ]
- , "CA");
- self.add( : vec![i32; 1] = vec![759, ]
- , "VE");
- self.add( : vec![i32; 2] = vec![760, 769, ]
- , "CH");
- self.add( : vec![i32; 1] = vec![770, ]
- , "CO");
- self.add( : vec![i32; 1] = vec![773, ]
- , "UY");
- self.add( : vec![i32; 1] = vec![775, ]
- , "PE");
- self.add( : vec![i32; 1] = vec![777, ]
- , "BO");
- self.add( : vec![i32; 1] = vec![779, ]
- , "AR");
- self.add( : vec![i32; 1] = vec![780, ]
- , "CL");
- self.add( : vec![i32; 1] = vec![784, ]
- , "PY");
- self.add( : vec![i32; 1] = vec![785, ]
- , "PE");
- self.add( : vec![i32; 1] = vec![786, ]
- , "EC");
- self.add( : vec![i32; 2] = vec![789, 790, ]
- , "BR");
- self.add( : vec![i32; 2] = vec![800, 839, ]
- , "IT");
- self.add( : vec![i32; 2] = vec![840, 849, ]
- , "ES");
- self.add( : vec![i32; 1] = vec![850, ]
- , "CU");
- self.add( : vec![i32; 1] = vec![858, ]
- , "SK");
- self.add( : vec![i32; 1] = vec![859, ]
- , "CZ");
- self.add( : vec![i32; 1] = vec![860, ]
- , "YU");
- self.add( : vec![i32; 1] = vec![865, ]
- , "MN");
- self.add( : vec![i32; 1] = vec![867, ]
- , "KP");
- self.add( : vec![i32; 2] = vec![868, 869, ]
- , "TR");
- self.add( : vec![i32; 2] = vec![870, 879, ]
- , "NL");
- self.add( : vec![i32; 1] = vec![880, ]
- , "KR");
- self.add( : vec![i32; 1] = vec![885, ]
- , "TH");
- self.add( : vec![i32; 1] = vec![888, ]
- , "SG");
- self.add( : vec![i32; 1] = vec![890, ]
- , "IN");
- self.add( : vec![i32; 1] = vec![893, ]
- , "VN");
- self.add( : vec![i32; 1] = vec![896, ]
- , "PK");
- self.add( : vec![i32; 1] = vec![899, ]
- , "ID");
- self.add( : vec![i32; 2] = vec![900, 919, ]
- , "AT");
- self.add( : vec![i32; 2] = vec![930, 939, ]
- , "AU");
- self.add( : vec![i32; 2] = vec![940, 949, ]
- , "AZ");
- self.add( : vec![i32; 1] = vec![955, ]
- , "MY");
- self.add( : vec![i32; 1] = vec![958, ]
- , "MO");
- }
-}
-
diff --git a/port_src/output/zxing/oned/i_t_f_reader.rs b/port_src/output/zxing/oned/i_t_f_reader.rs
deleted file mode 100644
index b758864..0000000
--- a/port_src/output/zxing/oned/i_t_f_reader.rs
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Copyright 2008 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.
- */
-// package com::google::zxing::oned;
-
-/**
- * Implements decoding of the ITF format, or Interleaved Two of Five.
- *
- * This Reader will scan ITF barcodes of certain lengths only.
- * At the moment it reads length 6, 8, 10, 12, 14, 16, 18, 20, 24, and 44 as these have appeared "in the wild". Not all
- * lengths are scanned, especially shorter ones, to avoid false positives. This in turn is due to a lack of
- * required checksum function.
- *
- * The checksum is optional and is not applied by this Reader. The consumer of the decoded
- * value will have to apply a checksum if required.
- *
- * http://en.wikipedia.org/wiki/Interleaved_2_of_5
- * is a great reference for Interleaved 2 of 5 information.
- *
- * @author kevin.osullivan@sita.aero, SITA Lab.
- */
-
- const MAX_AVG_VARIANCE: f32 = 0.38f;
-
- const MAX_INDIVIDUAL_VARIANCE: f32 = 0.5f;
-
-// Pixel width of a 3x wide line
- const W: i32 = 3;
-
-// Pixel width of a 2x wide line
- let w: i32 = 2;
-
-// Pixed width of a narrow line
- const N: i32 = 1;
-
-/** Valid ITF lengths. Anything longer than the largest value is also allowed. */
- const DEFAULT_ALLOWED_LENGTHS: vec![Vec; 5] = vec![6, 8, 10, 12, 14, ]
-;
-
-/**
- * Start/end guard pattern.
- *
- * Note: The end pattern is reversed because the row is reversed before
- * searching for the END_PATTERN
- */
- const START_PATTERN: vec![Vec; 4] = vec![N, N, N, N, ]
-;
-
- const END_PATTERN_REVERSED: vec![vec![Vec>; 3]; 2] = vec![// 2x
-vec![N, N, w, ]
-, // 3x
-vec![N, N, W, ]
-, ]
-;
-
-// See ITFWriter.PATTERNS
-/**
- * Patterns of Wide / Narrow lines to indicate each digit
- */
- const PATTERNS: vec![vec![Vec>; 5]; 20] = vec![// 0
-vec![N, N, w, w, N, ]
-, // 1
-vec![w, N, N, N, w, ]
-, // 2
-vec![N, w, N, N, w, ]
-, // 3
-vec![w, w, N, N, N, ]
-, // 4
-vec![N, N, w, N, w, ]
-, // 5
-vec![w, N, w, N, N, ]
-, // 6
-vec![N, w, w, N, N, ]
-, // 7
-vec![N, N, N, w, w, ]
-, // 8
-vec![w, N, N, w, N, ]
-, // 9
-vec![N, w, N, w, N, ]
-, // 0
-vec![N, N, W, W, N, ]
-, // 1
-vec![W, N, N, N, W, ]
-, // 2
-vec![N, W, N, N, W, ]
-, // 3
-vec![W, W, N, N, N, ]
-, // 4
-vec![N, N, W, N, W, ]
-, // 5
-vec![W, N, W, N, N, ]
-, // 6
-vec![N, W, W, N, N, ]
-, // 7
-vec![N, N, N, W, W, ]
-, // 8
-vec![W, N, N, W, N, ]
-, // 9
-vec![N, W, N, W, N, ]
-, ]
-;
-pub struct ITFReader {
- super: OneDReader;
-
- // Stores the actual narrow line width of the image being decoded.
- let narrow_line_width: i32 = -1;
-}
-
-impl ITFReader {
-
- pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws FormatException, NotFoundException */Result> {
- // Find out where the Middle section (payload) starts & ends
- let start_range: Vec = self.decode_start(row);
- let end_range: Vec = self.decode_end(row);
- let result: StringBuilder = StringBuilder::new(20);
- ::decode_middle(row, start_range[1], end_range[0], &result);
- let result_string: String = result.to_string();
- let allowed_lengths: Vec = null;
- if hints != null {
- allowed_lengths = hints.get(DecodeHintType::ALLOWED_LENGTHS) as Vec;
- }
- if allowed_lengths == null {
- allowed_lengths = DEFAULT_ALLOWED_LENGTHS;
- }
- // To avoid false positives with 2D barcodes (and other patterns), make
- // an assumption that the decoded string must be a 'standard' length if it's short
- let length: i32 = result_string.length();
- let length_o_k: bool = false;
- let max_allowed_length: i32 = 0;
- for let allowed_length: i32 in allowed_lengths {
- if length == allowed_length {
- length_o_k = true;
- break;
- }
- if allowed_length > max_allowed_length {
- max_allowed_length = allowed_length;
- }
- }
- if !length_o_k && length > max_allowed_length {
- length_o_k = true;
- }
- if !length_o_k {
- throw FormatException::get_format_instance();
- }
- let result_object: Result = Result::new(&result_string, // no natural byte representation for these barcodes
- null, : vec![ResultPoint; 2] = vec![ResultPoint::new(start_range[1], row_number), ResultPoint::new(end_range[0], row_number), ]
- , BarcodeFormat::ITF);
- result_object.put_metadata(ResultMetadataType::SYMBOLOGY_IDENTIFIER, "]I0");
- return Ok(result_object);
- }
-
- /**
- * @param row row of black/white values to search
- * @param payloadStart offset of start pattern
- * @param resultString {@link StringBuilder} to append decoded chars to
- * @throws NotFoundException if decoding could not complete successfully
- */
- fn decode_middle( row: &BitArray, payload_start: i32, payload_end: i32, result_string: &StringBuilder) -> /* throws NotFoundException */Result> {
- // Digits are interleaved in pairs - 5 black lines for one digit, and the
- // 5
- // interleaved white lines for the second digit.
- // Therefore, need to scan 10 lines and then
- // split these into two arrays
- let counter_digit_pair: [i32; 10] = [0; 10];
- let counter_black: [i32; 5] = [0; 5];
- let counter_white: [i32; 5] = [0; 5];
- while payload_start < payload_end {
- // Get 10 runs of black/white.
- record_pattern(row, payload_start, &counter_digit_pair);
- // Split them into each array
- {
- let mut k: i32 = 0;
- while k < 5 {
- {
- let two_k: i32 = 2 * k;
- counter_black[k] = counter_digit_pair[two_k];
- counter_white[k] = counter_digit_pair[two_k + 1];
- }
- k += 1;
- }
- }
-
- let best_match: i32 = ::decode_digit(&counter_black);
- result_string.append(('0' + best_match) as char);
- best_match = ::decode_digit(&counter_white);
- result_string.append(('0' + best_match) as char);
- for let counter_digit: i32 in counter_digit_pair {
- payload_start += counter_digit;
- }
- }
- }
-
- /**
- * Identify where the start of the middle / payload section starts.
- *
- * @param row row of black/white values to search
- * @return Array, containing index of start of 'start block' and end of
- * 'start block'
- */
- fn decode_start(&self, row: &BitArray) -> /* throws NotFoundException */Result, Rc> {
- let end_start: i32 = ::skip_white_space(row);
- let start_pattern: Vec = ::find_guard_pattern(row, end_start, &START_PATTERN);
- // Determine the width of a narrow line in pixels. We can do this by
- // getting the width of the start pattern and dividing by 4 because its
- // made up of 4 narrow lines.
- self.narrowLineWidth = (start_pattern[1] - start_pattern[0]) / 4;
- self.validate_quiet_zone(row, start_pattern[0]);
- return Ok(start_pattern);
- }
-
- /**
- * The start & end patterns must be pre/post fixed by a quiet zone. This
- * zone must be at least 10 times the width of a narrow line. Scan back until
- * we either get to the start of the barcode or match the necessary number of
- * quiet zone pixels.
- *
- * Note: Its assumed the row is reversed when using this method to find
- * quiet zone after the end pattern.
- *
- * ref: http://www.barcode-1.net/i25code.html
- *
- * @param row bit array representing the scanned barcode.
- * @param startPattern index into row of the start or end pattern.
- * @throws NotFoundException if the quiet zone cannot be found
- */
- fn validate_quiet_zone(&self, row: &BitArray, start_pattern: i32) -> /* throws NotFoundException */Result> {
- // expect to find this many pixels of quiet zone
- let quiet_count: i32 = self.narrowLineWidth * 10;
- // if there are not so many pixel at all let's try as many as possible
- quiet_count = Math::min(quiet_count, start_pattern);
- {
- let mut i: i32 = start_pattern - 1;
- while quiet_count > 0 && i >= 0 {
- {
- if row.get(i) {
- break;
- }
- quiet_count -= 1;
- }
- i -= 1;
- }
- }
-
- if quiet_count != 0 {
- // Unable to find the necessary number of quiet zone pixels.
- throw NotFoundException::get_not_found_instance();
- }
- }
-
- /**
- * Skip all whitespace until we get to the first black line.
- *
- * @param row row of black/white values to search
- * @return index of the first black line.
- * @throws NotFoundException Throws exception if no black lines are found in the row
- */
- fn skip_white_space( row: &BitArray) -> /* throws NotFoundException */Result> {
- let width: i32 = row.get_size();
- let end_start: i32 = row.get_next_set(0);
- if end_start == width {
- throw NotFoundException::get_not_found_instance();
- }
- return Ok(end_start);
- }
-
- /**
- * Identify where the end of the middle / payload section ends.
- *
- * @param row row of black/white values to search
- * @return Array, containing index of start of 'end block' and end of 'end
- * block'
- */
- fn decode_end(&self, row: &BitArray) -> /* throws NotFoundException */Result, Rc> {
- // For convenience, reverse the row and then
- // search from 'the start' for the end block
- row.reverse();
- let tryResult1 = 0;
- 'try1: loop {
- {
- let end_start: i32 = ::skip_white_space(row);
- let end_pattern: Vec;
- let tryResult2 = 0;
- 'try2: loop {
- {
- end_pattern = ::find_guard_pattern(row, end_start, END_PATTERN_REVERSED[0]);
- }
- break 'try2
- }
- match tryResult2 {
- catch ( nfe: &NotFoundException) {
- end_pattern = ::find_guard_pattern(row, end_start, END_PATTERN_REVERSED[1]);
- } 0 => break
- }
-
- // The start & end patterns must be pre/post fixed by a quiet zone. This
- // zone must be at least 10 times the width of a narrow line.
- // ref: http://www.barcode-1.net/i25code.html
- self.validate_quiet_zone(row, end_pattern[0]);
- // Now recalculate the indices of where the 'endblock' starts & stops to
- // accommodate
- // the reversed nature of the search
- let temp: i32 = end_pattern[0];
- end_pattern[0] = row.get_size() - end_pattern[1];
- end_pattern[1] = row.get_size() - temp;
- return Ok(end_pattern);
- }
- break 'try1
- }
- match tryResult1 {
- 0 => break
- }
- finally {
- // Put the row back the right way.
- row.reverse();
- }
- }
-
- /**
- * @param row row of black/white values to search
- * @param rowOffset position to start search
- * @param pattern pattern of counts of number of black and white pixels that are
- * being searched for as a pattern
- * @return start/end horizontal offset of guard pattern, as an array of two
- * ints
- * @throws NotFoundException if pattern is not found
- */
- fn find_guard_pattern( row: &BitArray, row_offset: i32, pattern: &Vec) -> /* throws NotFoundException */Result, Rc> {
- let pattern_length: i32 = pattern.len();
- let mut counters: [i32; pattern_length] = [0; pattern_length];
- let width: i32 = row.get_size();
- let is_white: bool = false;
- let counter_position: i32 = 0;
- let pattern_start: i32 = row_offset;
- {
- let mut x: i32 = row_offset;
- while x < width {
- {
- if row.get(x) != is_white {
- counters[counter_position] += 1;
- } else {
- if counter_position == pattern_length - 1 {
- if pattern_match_variance(&counters, &pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE {
- return Ok( : vec![i32; 2] = vec![pattern_start, x, ]
- );
- }
- pattern_start += counters[0] + counters[1];
- System::arraycopy(&counters, 2, &counters, 0, counter_position - 1);
- counters[counter_position - 1] = 0;
- counters[counter_position] = 0;
- counter_position -= 1;
- } else {
- counter_position += 1;
- }
- counters[counter_position] = 1;
- is_white = !is_white;
- }
- }
- x += 1;
- }
- }
-
- throw NotFoundException::get_not_found_instance();
- }
-
- /**
- * Attempts to decode a sequence of ITF black/white lines into single
- * digit.
- *
- * @param counters the counts of runs of observed black/white/black/... values
- * @return The decoded digit
- * @throws NotFoundException if digit cannot be decoded
- */
- fn decode_digit( counters: &Vec) -> /* throws NotFoundException */Result> {
- // worst variance we'll accept
- let best_variance: f32 = MAX_AVG_VARIANCE;
- let best_match: i32 = -1;
- let max: i32 = PATTERNS.len();
- {
- let mut i: i32 = 0;
- while i < max {
- {
- let pattern: Vec = PATTERNS[i];
- let variance: f32 = pattern_match_variance(&counters, &pattern, MAX_INDIVIDUAL_VARIANCE);
- if variance < best_variance {
- best_variance = variance;
- best_match = i;
- } else if variance == best_variance {
- // if we find a second 'best match' with the same variance, we can not reliably report to have a suitable match
- best_match = -1;
- }
- }
- i += 1;
- }
- }
-
- if best_match >= 0 {
- return Ok(best_match % 10);
- } else {
- throw NotFoundException::get_not_found_instance();
- }
- }
-}
-
diff --git a/port_src/output/zxing/oned/i_t_f_writer.rs b/port_src/output/zxing/oned/i_t_f_writer.rs
deleted file mode 100644
index af953bc..0000000
--- a/port_src/output/zxing/oned/i_t_f_writer.rs
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 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.
- */
-// package com::google::zxing::oned;
-
-/**
- * This object renders a ITF code as a {@link BitMatrix}.
- *
- * @author erik.barbara@gmail.com (Erik Barbara)
- */
-
- const START_PATTERN: vec![Vec; 4] = vec![1, 1, 1, 1, ]
-;
-
- const END_PATTERN: vec![Vec; 3] = vec![3, 1, 1, ]
-;
-
-// Pixel width of a 3x wide line
- const W: i32 = 3;
-
-// Pixed width of a narrow line
- const N: i32 = 1;
-
-// See ITFReader.PATTERNS
- const PATTERNS: vec![vec![Vec>; 5]; 10] = vec![// 0
-vec![N, N, W, W, N, ]
-, // 1
-vec![W, N, N, N, W, ]
-, // 2
-vec![N, W, N, N, W, ]
-, // 3
-vec![W, W, N, N, N, ]
-, // 4
-vec![N, N, W, N, W, ]
-, // 5
-vec![W, N, W, N, N, ]
-, // 6
-vec![N, W, W, N, N, ]
-, // 7
-vec![N, N, N, W, W, ]
-, // 8
-vec![W, N, N, W, N, ]
-, // 9
-vec![N, W, N, W, N, ]
-, ]
-;
-pub struct ITFWriter {
- super: OneDimensionalCodeWriter;
-}
-
-impl ITFWriter {
-
- pub fn get_supported_write_formats(&self) -> Collection {
- return Collections::singleton(BarcodeFormat::ITF);
- }
-
- pub fn encode(&self, contents: &String) -> Vec {
- let length: i32 = contents.length();
- if length % 2 != 0 {
- throw IllegalArgumentException::new("The length of the input should be even");
- }
- if length > 80 {
- throw IllegalArgumentException::new(format!("Requested contents should be less than 80 digits long, but got {}", length));
- }
- check_numeric(&contents);
- let result: [bool; 9 + 9 * length] = [false; 9 + 9 * length];
- let mut pos: i32 = append_pattern(&result, 0, &START_PATTERN, true);
- {
- let mut i: i32 = 0;
- while i < length {
- {
- let one: i32 = Character::digit(&contents.char_at(i), 10);
- let two: i32 = Character::digit(&contents.char_at(i + 1), 10);
- let mut encoding: [i32; 10] = [0; 10];
- {
- let mut j: i32 = 0;
- while j < 5 {
- {
- encoding[2 * j] = PATTERNS[one][j];
- encoding[2 * j + 1] = PATTERNS[two][j];
- }
- j += 1;
- }
- }
-
- pos += append_pattern(&result, pos, &encoding, true);
- }
- i += 2;
- }
- }
-
- append_pattern(&result, pos, &END_PATTERN, true);
- return result;
- }
-}
-
diff --git a/port_src/output/zxing/oned/multi_format_one_d_reader.rs b/port_src/output/zxing/oned/multi_format_one_d_reader.rs
deleted file mode 100644
index bc7d76b..0000000
--- a/port_src/output/zxing/oned/multi_format_one_d_reader.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2008 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.
- */
-// package com::google::zxing::oned;
-
-/**
- * @author dswitkin@google.com (Daniel Switkin)
- * @author Sean Owen
- */
-
- const EMPTY_ONED_ARRAY: [Option; 0] = [None; 0];
-pub struct MultiFormatOneDReader {
- super: OneDReader;
-
- let readers: Vec;
-}
-
-impl MultiFormatOneDReader {
-
- pub fn new( hints: &Map) -> MultiFormatOneDReader {
- let possible_formats: Collection = if hints == null { null } else { hints.get(DecodeHintType::POSSIBLE_FORMATS) as Collection };
- let use_code39_check_digit: bool = hints != null && hints.get(DecodeHintType::ASSUME_CODE_39_CHECK_DIGIT) != null;
- let mut readers: Collection = ArrayList<>::new();
- if possible_formats != null {
- if possible_formats.contains(BarcodeFormat::EAN_13) || possible_formats.contains(BarcodeFormat::UPC_A) || possible_formats.contains(BarcodeFormat::EAN_8) || possible_formats.contains(BarcodeFormat::UPC_E) {
- readers.add(MultiFormatUPCEANReader::new(&hints));
- }
- if possible_formats.contains(BarcodeFormat::CODE_39) {
- readers.add(Code39Reader::new(use_code39_check_digit));
- }
- if possible_formats.contains(BarcodeFormat::CODE_93) {
- readers.add(Code93Reader::new());
- }
- if possible_formats.contains(BarcodeFormat::CODE_128) {
- readers.add(Code128Reader::new());
- }
- if possible_formats.contains(BarcodeFormat::ITF) {
- readers.add(ITFReader::new());
- }
- if possible_formats.contains(BarcodeFormat::CODABAR) {
- readers.add(CodaBarReader::new());
- }
- if possible_formats.contains(BarcodeFormat::RSS_14) {
- readers.add(RSS14Reader::new());
- }
- if possible_formats.contains(BarcodeFormat::RSS_EXPANDED) {
- readers.add(RSSExpandedReader::new());
- }
- }
- if readers.is_empty() {
- readers.add(MultiFormatUPCEANReader::new(&hints));
- readers.add(Code39Reader::new());
- readers.add(CodaBarReader::new());
- readers.add(Code93Reader::new());
- readers.add(Code128Reader::new());
- readers.add(ITFReader::new());
- readers.add(RSS14Reader::new());
- readers.add(RSSExpandedReader::new());
- }
- let .readers = readers.to_array(EMPTY_ONED_ARRAY);
- }
-
- pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException */Result> {
- for let reader: OneDReader in self.readers {
- let tryResult1 = 0;
- 'try1: loop {
- {
- return Ok(reader.decode_row(row_number, row, &hints));
- }
- break 'try1
- }
- match tryResult1 {
- catch ( re: &ReaderException) {
- } 0 => break
- }
-
- }
- throw NotFoundException::get_not_found_instance();
- }
-
- pub fn reset(&self) {
- for let reader: Reader in self.readers {
- reader.reset();
- }
- }
-}
-
diff --git a/port_src/output/zxing/oned/multi_format_u_p_c_e_a_n_reader.rs b/port_src/output/zxing/oned/multi_format_u_p_c_e_a_n_reader.rs
deleted file mode 100644
index eb43fe3..0000000
--- a/port_src/output/zxing/oned/multi_format_u_p_c_e_a_n_reader.rs
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2008 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.
- */
-// package com::google::zxing::oned;
-
-/**
- * A reader that can read all available UPC/EAN formats. If a caller wants to try to
- * read all such formats, it is most efficient to use this implementation rather than invoke
- * individual readers.
- *
- * @author Sean Owen
- */
-
- const EMPTY_READER_ARRAY: [Option; 0] = [None; 0];
-pub struct MultiFormatUPCEANReader {
- super: OneDReader;
-
- let readers: Vec;
-}
-
-impl MultiFormatUPCEANReader {
-
- pub fn new( hints: &Map) -> MultiFormatUPCEANReader {
- let possible_formats: Collection = if hints == null { null } else { hints.get(DecodeHintType::POSSIBLE_FORMATS) as Collection };
- let mut readers: Collection = ArrayList<>::new();
- if possible_formats != null {
- if possible_formats.contains(BarcodeFormat::EAN_13) {
- readers.add(EAN13Reader::new());
- } else if possible_formats.contains(BarcodeFormat::UPC_A) {
- readers.add(UPCAReader::new());
- }
- if possible_formats.contains(BarcodeFormat::EAN_8) {
- readers.add(EAN8Reader::new());
- }
- if possible_formats.contains(BarcodeFormat::UPC_E) {
- readers.add(UPCEReader::new());
- }
- }
- if readers.is_empty() {
- readers.add(EAN13Reader::new());
- // UPC-A is covered by EAN-13
- readers.add(EAN8Reader::new());
- readers.add(UPCEReader::new());
- }
- let .readers = readers.to_array(EMPTY_READER_ARRAY);
- }
-
- pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException */Result> {
- // Compute this location once and reuse it on multiple implementations
- let start_guard_pattern: Vec = UPCEANReader::find_start_guard_pattern(row);
- for let reader: UPCEANReader in self.readers {
- let tryResult1 = 0;
- 'try1: loop {
- {
- let result: Result = reader.decode_row(row_number, row, &start_guard_pattern, &hints);
- // Special case: a 12-digit code encoded in UPC-A is identical to a "0"
- // followed by those 12 digits encoded as EAN-13. Each will recognize such a code,
- // UPC-A as a 12-digit string and EAN-13 as a 13-digit string starting with "0".
- // Individually these are correct and their readers will both read such a code
- // and correctly call it EAN-13, or UPC-A, respectively.
- //
- // In this case, if we've been looking for both types, we'd like to call it
- // a UPC-A code. But for efficiency we only run the EAN-13 decoder to also read
- // UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A
- // result if appropriate.
- //
- // But, don't return UPC-A if UPC-A was not a requested format!
- let ean13_may_be_u_p_c_a: bool = result.get_barcode_format() == BarcodeFormat::EAN_13 && result.get_text().char_at(0) == '0';
- let possible_formats: Collection = if hints == null { null } else { hints.get(DecodeHintType::POSSIBLE_FORMATS) as Collection };
- let can_return_u_p_c_a: bool = possible_formats == null || possible_formats.contains(BarcodeFormat::UPC_A);
- if ean13_may_be_u_p_c_a && can_return_u_p_c_a {
- // Transfer the metadata across
- let result_u_p_c_a: Result = Result::new(&result.get_text().substring(1), &result.get_raw_bytes(), &result.get_result_points(), BarcodeFormat::UPC_A);
- result_u_p_c_a.put_all_metadata(&result.get_result_metadata());
- return Ok(result_u_p_c_a);
- }
- return Ok(result);
- }
- break 'try1
- }
- match tryResult1 {
- catch ( ignored: &ReaderException) {
- } 0 => break
- }
-
- }
- throw NotFoundException::get_not_found_instance();
- }
-
- pub fn reset(&self) {
- for let reader: Reader in self.readers {
- reader.reset();
- }
- }
-}
-
diff --git a/port_src/output/zxing/oned/one_d_reader.rs b/port_src/output/zxing/oned/one_d_reader.rs
deleted file mode 100644
index 906885e..0000000
--- a/port_src/output/zxing/oned/one_d_reader.rs
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Copyright 2008 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.
- */
-// package com::google::zxing::oned;
-
-/**
- * Encapsulates functionality and implementation that is common to all families
- * of one-dimensional barcodes.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- * @author Sean Owen
- */
-#[derive(Reader)]
-pub struct OneDReader {
-}
-
-impl OneDReader {
-
- pub fn decode(&self, image: &BinaryBitmap) -> /* throws NotFoundException, FormatException */Result> {
- return Ok(self.decode(image, null));
- }
-
- // Note that we don't try rotation without the try harder flag, even if rotation was supported.
- pub fn decode(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException, FormatException */Result> {
- let tryResult1 = 0;
- 'try1: loop {
- {
- return Ok(self.do_decode(image, &hints));
- }
- break 'try1
- }
- match tryResult1 {
- catch ( nfe: &NotFoundException) {
- let try_harder: bool = hints != null && hints.contains_key(DecodeHintType::TRY_HARDER);
- if try_harder && image.is_rotate_supported() {
- let rotated_image: BinaryBitmap = image.rotate_counter_clockwise();
- let result: Result = self.do_decode(rotated_image, &hints);
- let metadata: Map = result.get_result_metadata();
- let mut orientation: i32 = 270;
- if metadata != null && metadata.contains_key(ResultMetadataType::ORIENTATION) {
- orientation = (orientation + metadata.get(ResultMetadataType::ORIENTATION) as Integer) % 360;
- }
- result.put_metadata(ResultMetadataType::ORIENTATION, orientation);
- let mut points: Vec = result.get_result_points();
- if points != null {
- let height: i32 = rotated_image.get_height();
- {
- let mut i: i32 = 0;
- while i < points.len() {
- {
- points[i] = ResultPoint::new(height - points[i].get_y() - 1, &points[i].get_x());
- }
- i += 1;
- }
- }
-
- }
- return Ok(result);
- } else {
- throw nfe;
- }
- } 0 => break
- }
-
- }
-
- pub fn reset(&self) {
- // do nothing
- }
-
- /**
- * We're going to examine rows from the middle outward, searching alternately above and below the
- * middle, and farther out each time. rowStep is the number of rows between each successive
- * attempt above and below the middle. So we'd scan row middle, then middle - rowStep, then
- * middle + rowStep, then middle - (2 * rowStep), etc.
- * rowStep is bigger as the image is taller, but is always at least 1. We've somewhat arbitrarily
- * decided that moving up and down by about 1/16 of the image is pretty good; we try more of the
- * image if "trying harder".
- *
- * @param image The image to decode
- * @param hints Any hints that were requested
- * @return The contents of the decoded barcode
- * @throws NotFoundException Any spontaneous errors which occur
- */
- fn do_decode(&self, image: &BinaryBitmap, hints: &Map) -> /* throws NotFoundException */Result> {
- let width: i32 = image.get_width();
- let height: i32 = image.get_height();
- let mut row: BitArray = BitArray::new(width);
- let try_harder: bool = hints != null && hints.contains_key(DecodeHintType::TRY_HARDER);
- let row_step: i32 = Math::max(1, height >> ( if try_harder { 8 } else { 5 }));
- let max_lines: i32;
- if try_harder {
- // Look at the whole image, not just the center
- max_lines = height;
- } else {
- // 15 rows spaced 1/32 apart is roughly the middle half of the image
- max_lines = 15;
- }
- let middle: i32 = height / 2;
- {
- let mut x: i32 = 0;
- while x < max_lines {
- {
- // Scanning from the middle out. Determine which row we're looking at next:
- let row_steps_above_or_below: i32 = (x + 1) / 2;
- // i.e. is x even?
- let is_above: bool = (x & 0x01) == 0;
- let row_number: i32 = middle + row_step * ( if is_above { row_steps_above_or_below } else { -row_steps_above_or_below });
- if row_number < 0 || row_number >= height {
- // Oops, if we run off the top or bottom, stop
- break;
- }
- // Estimate black point for this row and load it:
- let tryResult1 = 0;
- 'try1: loop {
- {
- row = image.get_black_row(row_number, row);
- }
- break 'try1
- }
- match tryResult1 {
- catch ( ignored: &NotFoundException) {
- continue;
- } 0 => break
- }
-
- // handle decoding upside down barcodes.
- {
- let mut attempt: i32 = 0;
- while attempt < 2 {
- {
- if attempt == 1 {
- // trying again?
- // reverse the row and continue
- row.reverse();
- // that start on the center line.
- if hints != null && hints.contains_key(DecodeHintType::NEED_RESULT_POINT_CALLBACK) {
- let new_hints: Map = EnumMap<>::new(DecodeHintType.class);
- new_hints.put_all(&hints);
- new_hints.remove(DecodeHintType::NEED_RESULT_POINT_CALLBACK);
- hints = new_hints;
- }
- }
- let tryResult1 = 0;
- 'try1: loop {
- {
- // Look for a barcode
- let result: Result = self.decode_row(row_number, row, &hints);
- // We found our barcode
- if attempt == 1 {
- // But it was upside down, so note that
- result.put_metadata(ResultMetadataType::ORIENTATION, 180);
- // And remember to flip the result points horizontally.
- let mut points: Vec = result.get_result_points();
- if points != null {
- points[0] = ResultPoint::new(width - points[0].get_x() - 1, &points[0].get_y());
- points[1] = ResultPoint::new(width - points[1].get_x() - 1, &points[1].get_y());
- }
- }
- return Ok(result);
- }
- break 'try1
- }
- match tryResult1 {
- catch ( re: &ReaderException) {
- } 0 => break
- }
-
- }
- attempt += 1;
- }
- }
-
- }
- x += 1;
- }
- }
-
- throw NotFoundException::get_not_found_instance();
- }
-
- /**
- * Records the size of successive runs of white and black pixels in a row, starting at a given point.
- * The values are recorded in the given array, and the number of runs recorded is equal to the size
- * of the array. If the row starts on a white pixel at the given start point, then the first count
- * recorded is the run of white pixels starting from that point; likewise it is the count of a run
- * of black pixels if the row begin on a black pixels at that point.
- *
- * @param row row to count from
- * @param start offset into row to start at
- * @param counters array into which to record counts
- * @throws NotFoundException if counters cannot be filled entirely from row before running out
- * of pixels
- */
- pub fn record_pattern( row: &BitArray, start: i32, counters: &Vec) -> /* throws NotFoundException */Result> {
- let num_counters: i32 = counters.len();
- Arrays::fill(&counters, 0, num_counters, 0);
- let end: i32 = row.get_size();
- if start >= end {
- throw NotFoundException::get_not_found_instance();
- }
- let is_white: bool = !row.get(start);
- let counter_position: i32 = 0;
- let mut i: i32 = start;
- while i < end {
- if row.get(i) != is_white {
- counters[counter_position] += 1;
- } else {
- if counter_position += 1 == num_counters {
- break;
- } else {
- counters[counter_position] = 1;
- is_white = !is_white;
- }
- }
- i += 1;
- }
- // the last counter but ran off the side of the image, OK. Otherwise, a problem.
- if !(counter_position == num_counters || (counter_position == num_counters - 1 && i == end)) {
- throw NotFoundException::get_not_found_instance();
- }
- }
-
- pub fn record_pattern_in_reverse( row: &BitArray, start: i32, counters: &Vec) -> /* throws NotFoundException */Result> {
- // This could be more efficient I guess
- let num_transitions_left: i32 = counters.len();
- let mut last: bool = row.get(start);
- while start > 0 && num_transitions_left >= 0 {
- if row.get(start -= 1) != last {
- num_transitions_left -= 1;
- last = !last;
- }
- }
- if num_transitions_left >= 0 {
- throw NotFoundException::get_not_found_instance();
- }
- ::record_pattern(row, start + 1, &counters);
- }
-
- /**
- * Determines how closely a set of observed counts of runs of black/white values matches a given
- * target pattern. This is reported as the ratio of the total variance from the expected pattern
- * proportions across all pattern elements, to the length of the pattern.
- *
- * @param counters observed counters
- * @param pattern expected pattern
- * @param maxIndividualVariance The most any counter can differ before we give up
- * @return ratio of total variance between counters and pattern compared to total pattern size
- */
- pub fn pattern_match_variance( counters: &Vec, pattern: &Vec, max_individual_variance: f32) -> f32 {
- let num_counters: i32 = counters.len();
- let mut total: i32 = 0;
- let pattern_length: i32 = 0;
- {
- let mut i: i32 = 0;
- while i < num_counters {
- {
- total += counters[i];
- pattern_length += pattern[i];
- }
- i += 1;
- }
- }
-
- if total < pattern_length {
- // to reliably match, so fail:
- return Float::POSITIVE_INFINITY;
- }
- let unit_bar_width: f32 = total as f32 / pattern_length;
- max_individual_variance *= unit_bar_width;
- let total_variance: f32 = 0.0f;
- {
- let mut x: i32 = 0;
- while x < num_counters {
- {
- let counter: i32 = counters[x];
- let scaled_pattern: f32 = pattern[x] * unit_bar_width;
- let variance: f32 = if counter > scaled_pattern { counter - scaled_pattern } else { scaled_pattern - counter };
- if variance > max_individual_variance {
- return Float::POSITIVE_INFINITY;
- }
- total_variance += variance;
- }
- x += 1;
- }
- }
-
- return total_variance / total;
- }
-
- /**
- * Attempts to decode a one-dimensional barcode format given a single row of
- * an image.
- *
- * @param rowNumber row number from top of the row
- * @param row the black/white pixel data of the row
- * @param hints decode hints
- * @return {@link Result} containing encoded string and start/end of barcode
- * @throws NotFoundException if no potential barcode is found
- * @throws ChecksumException if a potential barcode is found but does not pass its checksum
- * @throws FormatException if a potential barcode is found but format is invalid
- */
- pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException, ChecksumException, FormatException */Result> ;
-}
-
diff --git a/port_src/output/zxing/oned/one_dimensional_code_writer.rs b/port_src/output/zxing/oned/one_dimensional_code_writer.rs
deleted file mode 100644
index 2247765..0000000
--- a/port_src/output/zxing/oned/one_dimensional_code_writer.rs
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright 2011 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.
- */
-// package com::google::zxing::oned;
-
-/**
- * Encapsulates functionality and implementation that is common to one-dimensional barcodes.
- *
- * @author dsbnatut@gmail.com (Kazuki Nishiura)
- */
-
- const NUMERIC: Pattern = Pattern::compile("[0-9]+");
-#[derive(Writer)]
-pub struct OneDimensionalCodeWriter {
-}
-
-impl OneDimensionalCodeWriter {
-
- /**
- * Encode the contents to boolean array expression of one-dimensional barcode.
- * Start code and end code should be included in result, and side margins should not be included.
- *
- * @param contents barcode contents to encode
- * @return a {@code boolean[]} of horizontal pixels (false = white, true = black)
- */
- pub fn encode(&self, contents: &String) -> Vec ;
-
- /**
- * Can be overwritten if the encode requires to read the hints map. Otherwise it defaults to {@code encode}.
- * @param contents barcode contents to encode
- * @param hints encoding hints
- * @return a {@code boolean[]} of horizontal pixels (false = white, true = black)
- */
- pub fn encode(&self, contents: &String, hints: &Map) -> Vec {
- return self.encode(&contents);
- }
-
- pub fn encode(&self, contents: &String, format: &BarcodeFormat, width: i32, height: i32) -> BitMatrix {
- return self.encode(&contents, format, width, height, null);
- }
-
- /**
- * Encode the contents following specified format.
- * {@code width} and {@code height} are required size. This method may return bigger size
- * {@code BitMatrix} when specified size is too small. The user can set both {@code width} and
- * {@code height} to zero to get minimum size barcode. If negative value is set to {@code width}
- * or {@code height}, {@code IllegalArgumentException} is thrown.
- */
- pub fn encode(&self, contents: &String, format: &BarcodeFormat, width: i32, height: i32, hints: &Map) -> BitMatrix {
- if contents.is_empty() {
- throw IllegalArgumentException::new("Found empty contents");
- }
- if width < 0 || height < 0 {
- throw IllegalArgumentException::new(format!("Negative size is not allowed. Input: {}x{}", width, height));
- }
- let supported_formats: Collection = self.get_supported_write_formats();
- if supported_formats != null && !supported_formats.contains(format) {
- throw IllegalArgumentException::new(format!("Can only encode {}, but got {}", supported_formats, format));
- }
- let sides_margin: i32 = self.get_default_margin();
- if hints != null && hints.contains_key(EncodeHintType::MARGIN) {
- sides_margin = Integer::parse_int(&hints.get(EncodeHintType::MARGIN).to_string());
- }
- let code: Vec = self.encode(&contents, &hints);
- return ::render_result(&code, width, height, sides_margin);
- }
-
- pub fn get_supported_write_formats(&self) -> Collection {
- return null;
- }
-
- /**
- * @return a byte array of horizontal pixels (0 = white, 1 = black)
- */
- fn render_result( code: &Vec, width: i32, height: i32, sides_margin: i32) -> BitMatrix {
- let input_width: i32 = code.len();
- // Add quiet zone on both sides.
- let full_width: i32 = input_width + sides_margin;
- let output_width: i32 = Math::max(width, full_width);
- let output_height: i32 = Math::max(1, height);
- let multiple: i32 = output_width / full_width;
- let left_padding: i32 = (output_width - (input_width * multiple)) / 2;
- let output: BitMatrix = BitMatrix::new(output_width, output_height);
- {
- let input_x: i32 = 0, let output_x: i32 = left_padding;
- while input_x < input_width {
- {
- if code[input_x] {
- output.set_region(output_x, 0, multiple, output_height);
- }
- }
- input_x += 1;
- output_x += multiple;
- }
- }
-
- return output;
- }
-
- /**
- * @param contents string to check for numeric characters
- * @throws IllegalArgumentException if input contains characters other than digits 0-9.
- */
- pub fn check_numeric( contents: &String) {
- if !NUMERIC::matcher(&contents)::matches() {
- throw IllegalArgumentException::new("Input should only contain digits 0-9");
- }
- }
-
- /**
- * @param target encode black/white pattern into this array
- * @param pos position to start encoding at in {@code target}
- * @param pattern lengths of black/white runs to encode
- * @param startColor starting color - false for white, true for black
- * @return the number of elements added to target.
- */
- pub fn append_pattern( target: &Vec, pos: i32, pattern: &Vec, start_color: bool) -> i32 {
- let mut color: bool = start_color;
- let num_added: i32 = 0;
- for let len: i32 in pattern {
- {
- let mut j: i32 = 0;
- while j < len {
- {
- target[pos += 1 !!!check!!! post increment] = color;
- }
- j += 1;
- }
- }
-
- num_added += len;
- // flip color after each segment
- color = !color;
- }
- return num_added;
- }
-
- pub fn get_default_margin(&self) -> i32 {
- // This seems like a decent idea for a default for all formats.
- return 10;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/abstract_r_s_s_reader.rs b/port_src/output/zxing/oned/rss/abstract_r_s_s_reader.rs
deleted file mode 100644
index 81d14fb..0000000
--- a/port_src/output/zxing/oned/rss/abstract_r_s_s_reader.rs
+++ /dev/null
@@ -1,165 +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.
- */
-// package com::google::zxing::oned::rss;
-
-/**
- * Superclass of {@link OneDReader} implementations that read barcodes in the RSS family
- * of formats.
- */
-
- const MAX_AVG_VARIANCE: f32 = 0.2f;
-
- const MAX_INDIVIDUAL_VARIANCE: f32 = 0.45f;
-
- const MIN_FINDER_PATTERN_RATIO: f32 = 9.5f / 12.0f;
-
- const MAX_FINDER_PATTERN_RATIO: f32 = 12.5f / 14.0f;
-pub struct AbstractRSSReader {
- super: OneDReader;
-
- let decode_finder_counters: Vec;
-
- let data_character_counters: Vec;
-
- let odd_rounding_errors: Vec;
-
- let even_rounding_errors: Vec;
-
- let odd_counts: Vec;
-
- let even_counts: Vec;
-}
-
-impl AbstractRSSReader {
-
- pub fn new() -> AbstractRSSReader {
- decode_finder_counters = : [i32; 4] = [0; 4];
- data_character_counters = : [i32; 8] = [0; 8];
- odd_rounding_errors = : [f32; 4.0] = [0.0; 4.0];
- even_rounding_errors = : [f32; 4.0] = [0.0; 4.0];
- odd_counts = : [i32; data_character_counters.len() / 2] = [0; data_character_counters.len() / 2];
- even_counts = : [i32; data_character_counters.len() / 2] = [0; data_character_counters.len() / 2];
- }
-
- pub fn get_decode_finder_counters(&self) -> Vec {
- return self.decode_finder_counters;
- }
-
- pub fn get_data_character_counters(&self) -> Vec {
- return self.data_character_counters;
- }
-
- pub fn get_odd_rounding_errors(&self) -> Vec {
- return self.odd_rounding_errors;
- }
-
- pub fn get_even_rounding_errors(&self) -> Vec {
- return self.even_rounding_errors;
- }
-
- pub fn get_odd_counts(&self) -> Vec {
- return self.odd_counts;
- }
-
- pub fn get_even_counts(&self) -> Vec {
- return self.even_counts;
- }
-
- pub fn parse_finder_value( counters: &Vec, finder_patterns: &Vec>) -> /* throws NotFoundException */Result> {
- {
- let mut value: i32 = 0;
- while value < finder_patterns.len() {
- {
- if pattern_match_variance(&counters, finder_patterns[value], MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE {
- return Ok(value);
- }
- }
- value += 1;
- }
- }
-
- throw NotFoundException::get_not_found_instance();
- }
-
- /**
- * @param array values to sum
- * @return sum of values
- * @deprecated call {@link MathUtils#sum(int[])}
- */
- pub fn count( array: &Vec) -> i32 {
- return MathUtils::sum(&array);
- }
-
- pub fn increment( array: &Vec, errors: &Vec) {
- let mut index: i32 = 0;
- let biggest_error: f32 = errors[0];
- {
- let mut i: i32 = 1;
- while i < array.len() {
- {
- if errors[i] > biggest_error {
- biggest_error = errors[i];
- index = i;
- }
- }
- i += 1;
- }
- }
-
- array[index] += 1;
- }
-
- pub fn decrement( array: &Vec, errors: &Vec) {
- let mut index: i32 = 0;
- let biggest_error: f32 = errors[0];
- {
- let mut i: i32 = 1;
- while i < array.len() {
- {
- if errors[i] < biggest_error {
- biggest_error = errors[i];
- index = i;
- }
- }
- i += 1;
- }
- }
-
- array[index] -= 1;
- }
-
- pub fn is_finder_pattern( counters: &Vec) -> bool {
- let first_two_sum: i32 = counters[0] + counters[1];
- let sum: i32 = first_two_sum + counters[2] + counters[3];
- let ratio: f32 = first_two_sum / sum as f32;
- if ratio >= MIN_FINDER_PATTERN_RATIO && ratio <= MAX_FINDER_PATTERN_RATIO {
- // passes ratio test in spec, but see if the counts are unreasonable
- let min_counter: i32 = Integer::MAX_VALUE;
- let max_counter: i32 = Integer::MIN_VALUE;
- for let counter: i32 in counters {
- if counter > max_counter {
- max_counter = counter;
- }
- if counter < min_counter {
- min_counter = counter;
- }
- }
- return max_counter < 10 * min_counter;
- }
- return false;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/data_character.rs b/port_src/output/zxing/oned/rss/data_character.rs
deleted file mode 100644
index d39f939..0000000
--- a/port_src/output/zxing/oned/rss/data_character.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2009 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.
- */
-// package com::google::zxing::oned::rss;
-
-/**
- * Encapsulates a since character value in an RSS barcode, including its checksum information.
- */
-pub struct DataCharacter {
-
- let value: i32;
-
- let checksum_portion: i32;
-}
-
-impl DataCharacter {
-
- pub fn new( value: i32, checksum_portion: i32) -> DataCharacter {
- let .value = value;
- let .checksumPortion = checksum_portion;
- }
-
- pub fn get_value(&self) -> i32 {
- return self.value;
- }
-
- pub fn get_checksum_portion(&self) -> i32 {
- return self.checksum_portion;
- }
-
- pub fn to_string(&self) -> String {
- return format!("{}({})", self.value, self.checksum_portion);
- }
-
- pub fn equals(&self, o: &Object) -> bool {
- if !(o instanceof DataCharacter) {
- return false;
- }
- let that: DataCharacter = o as DataCharacter;
- return self.value == that.value && self.checksum_portion == that.checksumPortion;
- }
-
- pub fn hash_code(&self) -> i32 {
- return self.value ^ self.checksum_portion;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/bit_array_builder.rs b/port_src/output/zxing/oned/rss/expanded/bit_array_builder.rs
deleted file mode 100644
index 5f5b12f..0000000
--- a/port_src/output/zxing/oned/rss/expanded/bit_array_builder.rs
+++ /dev/null
@@ -1,96 +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.
- */
-// package com::google::zxing::oned::rss::expanded;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-struct BitArrayBuilder {
-}
-
-impl BitArrayBuilder {
-
- fn new() -> BitArrayBuilder {
- }
-
- fn build_bit_array( pairs: &List) -> BitArray {
- let char_number: i32 = (pairs.size() * 2) - 1;
- if pairs.get(pairs.size() - 1).get_right_char() == null {
- char_number -= 1;
- }
- let size: i32 = 12 * char_number;
- let binary: BitArray = BitArray::new(size);
- let acc_pos: i32 = 0;
- let first_pair: ExpandedPair = pairs.get(0);
- let first_value: i32 = first_pair.get_right_char().get_value();
- {
- let mut i: i32 = 11;
- while i >= 0 {
- {
- if (first_value & (1 << i)) != 0 {
- binary.set(acc_pos);
- }
- acc_pos += 1;
- }
- i -= 1;
- }
- }
-
- {
- let mut i: i32 = 1;
- while i < pairs.size() {
- {
- let current_pair: ExpandedPair = pairs.get(i);
- let left_value: i32 = current_pair.get_left_char().get_value();
- {
- let mut j: i32 = 11;
- while j >= 0 {
- {
- if (left_value & (1 << j)) != 0 {
- binary.set(acc_pos);
- }
- acc_pos += 1;
- }
- j -= 1;
- }
- }
-
- if current_pair.get_right_char() != null {
- let right_value: i32 = current_pair.get_right_char().get_value();
- {
- let mut j: i32 = 11;
- while j >= 0 {
- {
- if (right_value & (1 << j)) != 0 {
- binary.set(acc_pos);
- }
- acc_pos += 1;
- }
- j -= 1;
- }
- }
-
- }
- }
- i += 1;
- }
- }
-
- return binary;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/a_i013103decoder.rs b/port_src/output/zxing/oned/rss/expanded/decoders/a_i013103decoder.rs
deleted file mode 100644
index 5e96dfd..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/a_i013103decoder.rs
+++ /dev/null
@@ -1,39 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- */
-struct AI013103decoder {
- super: AI013x0xDecoder;
-}
-
-impl AI013103decoder {
-
- fn new( information: &BitArray) -> AI013103decoder {
- super(information);
- }
-
- pub fn add_weight_code(&self, buf: &StringBuilder, weight: i32) {
- buf.append("(3103)");
- }
-
- pub fn check_weight(&self, weight: i32) -> i32 {
- return weight;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/a_i01320x_decoder.rs b/port_src/output/zxing/oned/rss/expanded/decoders/a_i01320x_decoder.rs
deleted file mode 100644
index fdc1c8e..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/a_i01320x_decoder.rs
+++ /dev/null
@@ -1,46 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- */
-struct AI01320xDecoder {
- super: AI013x0xDecoder;
-}
-
-impl AI01320xDecoder {
-
- fn new( information: &BitArray) -> AI01320xDecoder {
- super(information);
- }
-
- pub fn add_weight_code(&self, buf: &StringBuilder, weight: i32) {
- if weight < 10000 {
- buf.append("(3202)");
- } else {
- buf.append("(3203)");
- }
- }
-
- pub fn check_weight(&self, weight: i32) -> i32 {
- if weight < 10000 {
- return weight;
- }
- return weight - 10000;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/a_i01392x_decoder.rs b/port_src/output/zxing/oned/rss/expanded/decoders/a_i01392x_decoder.rs
deleted file mode 100644
index ea5fd97..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/a_i01392x_decoder.rs
+++ /dev/null
@@ -1,50 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- */
-
- const HEADER_SIZE: i32 = 5 + 1 + 2;
-
- const LAST_DIGIT_SIZE: i32 = 2;
-struct AI01392xDecoder {
- super: AI01decoder;
-}
-
-impl AI01392xDecoder {
-
- fn new( information: &BitArray) -> AI01392xDecoder {
- super(information);
- }
-
- pub fn parse_information(&self) -> /* throws NotFoundException, FormatException */Result> {
- if self.get_information().get_size() < HEADER_SIZE + GTIN_SIZE {
- throw NotFoundException::get_not_found_instance();
- }
- let buf: StringBuilder = StringBuilder::new();
- encode_compressed_gtin(&buf, HEADER_SIZE);
- let last_a_idigit: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE);
- buf.append("(392");
- buf.append(last_a_idigit);
- buf.append(')');
- let decoded_information: DecodedInformation = self.get_general_decoder().decode_general_purpose_field(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, null);
- buf.append(&decoded_information.get_new_string());
- return Ok(buf.to_string());
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/a_i01393x_decoder.rs b/port_src/output/zxing/oned/rss/expanded/decoders/a_i01393x_decoder.rs
deleted file mode 100644
index 2f13441..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/a_i01393x_decoder.rs
+++ /dev/null
@@ -1,69 +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;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- */
-
- const HEADER_SIZE: i32 = 5 + 1 + 2;
-
- const LAST_DIGIT_SIZE: i32 = 2;
-
- const FIRST_THREE_DIGITS_SIZE: i32 = 10;
-struct AI01393xDecoder {
- super: AI01decoder;
-}
-
-impl AI01393xDecoder {
-
- fn new( information: &BitArray) -> AI01393xDecoder {
- super(information);
- }
-
- pub fn parse_information(&self) -> /* throws NotFoundException, FormatException */Result> {
- if self.get_information().get_size() < HEADER_SIZE + GTIN_SIZE {
- throw NotFoundException::get_not_found_instance();
- }
- let buf: StringBuilder = StringBuilder::new();
- encode_compressed_gtin(&buf, HEADER_SIZE);
- let last_a_idigit: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(HEADER_SIZE + GTIN_SIZE, LAST_DIGIT_SIZE);
- buf.append("(393");
- buf.append(last_a_idigit);
- buf.append(')');
- let first_three_digits: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE, FIRST_THREE_DIGITS_SIZE);
- if first_three_digits / 100 == 0 {
- buf.append('0');
- }
- if first_three_digits / 10 == 0 {
- buf.append('0');
- }
- buf.append(first_three_digits);
- let general_information: DecodedInformation = self.get_general_decoder().decode_general_purpose_field(HEADER_SIZE + GTIN_SIZE + LAST_DIGIT_SIZE + FIRST_THREE_DIGITS_SIZE, null);
- buf.append(&general_information.get_new_string());
- return Ok(buf.to_string());
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/a_i013x0x1x_decoder.rs b/port_src/output/zxing/oned/rss/expanded/decoders/a_i013x0x1x_decoder.rs
deleted file mode 100644
index 7dd43d0..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/a_i013x0x1x_decoder.rs
+++ /dev/null
@@ -1,93 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-
- const HEADER_SIZE: i32 = 7 + 1;
-
- const WEIGHT_SIZE: i32 = 20;
-
- const DATE_SIZE: i32 = 16;
-struct AI013x0x1xDecoder {
- super: AI01weightDecoder;
-
- let date_code: String;
-
- let first_a_idigits: String;
-}
-
-impl AI013x0x1xDecoder {
-
- fn new( information: &BitArray, first_a_idigits: &String, date_code: &String) -> AI013x0x1xDecoder {
- super(information);
- let .dateCode = date_code;
- let .firstAIdigits = first_a_idigits;
- }
-
- pub fn parse_information(&self) -> /* throws NotFoundException */Result> {
- if self.get_information().get_size() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE + DATE_SIZE {
- throw NotFoundException::get_not_found_instance();
- }
- let buf: StringBuilder = StringBuilder::new();
- encode_compressed_gtin(&buf, HEADER_SIZE);
- encode_compressed_weight(&buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE);
- self.encode_compressed_date(&buf, HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE);
- return Ok(buf.to_string());
- }
-
- fn encode_compressed_date(&self, buf: &StringBuilder, current_pos: i32) {
- let numeric_date: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(current_pos, DATE_SIZE);
- if numeric_date == 38400 {
- return;
- }
- buf.append('(');
- buf.append(self.dateCode);
- buf.append(')');
- let day: i32 = numeric_date % 32;
- numeric_date /= 32;
- let month: i32 = numeric_date % 12 + 1;
- numeric_date /= 12;
- let year: i32 = numeric_date;
- 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);
- }
-
- pub fn add_weight_code(&self, buf: &StringBuilder, weight: i32) {
- buf.append('(');
- buf.append(self.firstAIdigits);
- buf.append(weight / 100000);
- buf.append(')');
- }
-
- pub fn check_weight(&self, weight: i32) -> i32 {
- return weight % 100000;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/a_i013x0x_decoder.rs b/port_src/output/zxing/oned/rss/expanded/decoders/a_i013x0x_decoder.rs
deleted file mode 100644
index a136c55..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/a_i013x0x_decoder.rs
+++ /dev/null
@@ -1,45 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- */
-
- const HEADER_SIZE: i32 = 4 + 1;
-
- const WEIGHT_SIZE: i32 = 15;
-struct AI013x0xDecoder {
- super: AI01weightDecoder;
-}
-
-impl AI013x0xDecoder {
-
- fn new( information: &BitArray) -> AI013x0xDecoder {
- super(information);
- }
-
- pub fn parse_information(&self) -> /* throws NotFoundException */Result> {
- if self.get_information().get_size() != HEADER_SIZE + GTIN_SIZE + WEIGHT_SIZE {
- throw NotFoundException::get_not_found_instance();
- }
- let buf: StringBuilder = StringBuilder::new();
- encode_compressed_gtin(&buf, HEADER_SIZE);
- encode_compressed_weight(&buf, HEADER_SIZE + GTIN_SIZE, WEIGHT_SIZE);
- return Ok(buf.to_string());
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/a_i01_and_other_a_is.rs b/port_src/output/zxing/oned/rss/expanded/decoders/a_i01_and_other_a_is.rs
deleted file mode 100644
index 0a1dd02..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/a_i01_and_other_a_is.rs
+++ /dev/null
@@ -1,46 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-
-//first bit encodes the linkage flag,
- const HEADER_SIZE: i32 = 1 + 1 + 2;
-struct AI01AndOtherAIs {
- super: AI01decoder;
-}
-
-impl AI01AndOtherAIs {
-
- //the second one is the encodation method, and the other two are for the variable length
- fn new( information: &BitArray) -> AI01AndOtherAIs {
- super(information);
- }
-
- pub fn parse_information(&self) -> /* throws NotFoundException, FormatException */Result> {
- let buff: StringBuilder = StringBuilder::new();
- buff.append("(01)");
- let initial_gtin_position: i32 = buff.length();
- let first_gtin_digit: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(HEADER_SIZE, 4);
- buff.append(first_gtin_digit);
- self.encode_compressed_gtin_without_a_i(&buff, HEADER_SIZE + 4, initial_gtin_position);
- return Ok(self.get_general_decoder().decode_all_codes(&buff, HEADER_SIZE + 44));
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/a_i01decoder.rs b/port_src/output/zxing/oned/rss/expanded/decoders/a_i01decoder.rs
deleted file mode 100644
index 88bdbf0..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/a_i01decoder.rs
+++ /dev/null
@@ -1,82 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-
- const GTIN_SIZE: i32 = 40;
-struct AI01decoder {
- super: AbstractExpandedDecoder;
-}
-
-impl AI01decoder {
-
- fn new( information: &BitArray) -> AI01decoder {
- super(information);
- }
-
- fn encode_compressed_gtin(&self, buf: &StringBuilder, current_pos: i32) {
- buf.append("(01)");
- let initial_position: i32 = buf.length();
- buf.append('9');
- self.encode_compressed_gtin_without_a_i(&buf, current_pos, initial_position);
- }
-
- fn encode_compressed_gtin_without_a_i(&self, buf: &StringBuilder, current_pos: i32, initial_buffer_position: i32) {
- {
- let mut i: i32 = 0;
- while i < 4 {
- {
- let current_block: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(current_pos + 10 * i, 10);
- if current_block / 100 == 0 {
- buf.append('0');
- }
- if current_block / 10 == 0 {
- buf.append('0');
- }
- buf.append(current_block);
- }
- i += 1;
- }
- }
-
- ::append_check_digit(&buf, initial_buffer_position);
- }
-
- fn append_check_digit( buf: &StringBuilder, current_pos: i32) {
- let check_digit: i32 = 0;
- {
- let mut i: i32 = 0;
- while i < 13 {
- {
- let digit: i32 = buf.char_at(i + current_pos) - '0';
- check_digit += if (i & 0x01) == 0 { 3 * digit } else { digit };
- }
- i += 1;
- }
- }
-
- check_digit = 10 - (check_digit % 10);
- if check_digit == 10 {
- check_digit = 0;
- }
- buf.append(check_digit);
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/a_i01weight_decoder.rs b/port_src/output/zxing/oned/rss/expanded/decoders/a_i01weight_decoder.rs
deleted file mode 100644
index ea18c8d..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/a_i01weight_decoder.rs
+++ /dev/null
@@ -1,56 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- */
-struct AI01weightDecoder {
- super: AI01decoder;
-}
-
-impl AI01weightDecoder {
-
- fn new( information: &BitArray) -> AI01weightDecoder {
- super(information);
- }
-
- fn encode_compressed_weight(&self, buf: &StringBuilder, current_pos: i32, weight_size: i32) {
- let original_weight_numeric: i32 = self.get_general_decoder().extract_numeric_value_from_bit_array(current_pos, weight_size);
- self.add_weight_code(&buf, original_weight_numeric);
- let weight_numeric: i32 = self.check_weight(original_weight_numeric);
- let current_divisor: i32 = 100000;
- {
- let mut i: i32 = 0;
- while i < 5 {
- {
- if weight_numeric / current_divisor == 0 {
- buf.append('0');
- }
- current_divisor /= 10;
- }
- i += 1;
- }
- }
-
- buf.append(weight_numeric);
- }
-
- pub fn add_weight_code(&self, buf: &StringBuilder, weight: i32) ;
-
- pub fn check_weight(&self, weight: i32) -> i32 ;
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/abstract_expanded_decoder.rs b/port_src/output/zxing/oned/rss/expanded/decoders/abstract_expanded_decoder.rs
deleted file mode 100644
index d84d869..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/abstract_expanded_decoder.rs
+++ /dev/null
@@ -1,113 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-pub struct AbstractExpandedDecoder {
-
- let information: BitArray;
-
- let general_decoder: GeneralAppIdDecoder;
-}
-
-impl AbstractExpandedDecoder {
-
- fn new( information: &BitArray) -> AbstractExpandedDecoder {
- let .information = information;
- let .generalDecoder = GeneralAppIdDecoder::new(information);
- }
-
- pub fn get_information(&self) -> BitArray {
- return self.information;
- }
-
- pub fn get_general_decoder(&self) -> GeneralAppIdDecoder {
- return self.general_decoder;
- }
-
- pub fn parse_information(&self) -> /* throws NotFoundException, FormatException */Result> ;
-
- pub fn create_decoder( information: &BitArray) -> AbstractExpandedDecoder {
- if information.get(1) {
- return AI01AndOtherAIs::new(information);
- }
- if !information.get(2) {
- return AnyAIDecoder::new(information);
- }
- let four_bit_encodation_method: i32 = GeneralAppIdDecoder::extract_numeric_value_from_bit_array(information, 1, 4);
- match four_bit_encodation_method {
- 4 =>
- {
- return AI013103decoder::new(information);
- }
- 5 =>
- {
- return AI01320xDecoder::new(information);
- }
- }
- let five_bit_encodation_method: i32 = GeneralAppIdDecoder::extract_numeric_value_from_bit_array(information, 1, 5);
- match five_bit_encodation_method {
- 12 =>
- {
- return AI01392xDecoder::new(information);
- }
- 13 =>
- {
- return AI01393xDecoder::new(information);
- }
- }
- let seven_bit_encodation_method: i32 = GeneralAppIdDecoder::extract_numeric_value_from_bit_array(information, 1, 7);
- match seven_bit_encodation_method {
- 56 =>
- {
- return AI013x0x1xDecoder::new(information, "310", "11");
- }
- 57 =>
- {
- return AI013x0x1xDecoder::new(information, "320", "11");
- }
- 58 =>
- {
- return AI013x0x1xDecoder::new(information, "310", "13");
- }
- 59 =>
- {
- return AI013x0x1xDecoder::new(information, "320", "13");
- }
- 60 =>
- {
- return AI013x0x1xDecoder::new(information, "310", "15");
- }
- 61 =>
- {
- return AI013x0x1xDecoder::new(information, "320", "15");
- }
- 62 =>
- {
- return AI013x0x1xDecoder::new(information, "310", "17");
- }
- 63 =>
- {
- return AI013x0x1xDecoder::new(information, "320", "17");
- }
- }
- throw IllegalStateException::new(format!("unknown decoder: {}", information));
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/any_a_i_decoder.rs b/port_src/output/zxing/oned/rss/expanded/decoders/any_a_i_decoder.rs
deleted file mode 100644
index 077cc5d..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/any_a_i_decoder.rs
+++ /dev/null
@@ -1,39 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-
- const HEADER_SIZE: i32 = 2 + 1 + 2;
-struct AnyAIDecoder {
- super: AbstractExpandedDecoder;
-}
-
-impl AnyAIDecoder {
-
- fn new( information: &BitArray) -> AnyAIDecoder {
- super(information);
- }
-
- pub fn parse_information(&self) -> /* throws NotFoundException, FormatException */Result> {
- let buf: StringBuilder = StringBuilder::new();
- return Ok(self.get_general_decoder().decode_all_codes(&buf, HEADER_SIZE));
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/block_parsed_result.rs b/port_src/output/zxing/oned/rss/expanded/decoders/block_parsed_result.rs
deleted file mode 100644
index a82f356..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/block_parsed_result.rs
+++ /dev/null
@@ -1,48 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-struct BlockParsedResult {
-
- let decoded_information: DecodedInformation;
-
- let finished: bool;
-}
-
-impl BlockParsedResult {
-
- fn new() -> BlockParsedResult {
- this(null, false);
- }
-
- fn new( information: &DecodedInformation, finished: bool) -> BlockParsedResult {
- let .finished = finished;
- let .decodedInformation = information;
- }
-
- fn get_decoded_information(&self) -> DecodedInformation {
- return self.decodedInformation;
- }
-
- fn is_finished(&self) -> bool {
- return self.finished;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/current_parsing_state.rs b/port_src/output/zxing/oned/rss/expanded/decoders/current_parsing_state.rs
deleted file mode 100644
index cfda228..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/current_parsing_state.rs
+++ /dev/null
@@ -1,76 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- */
-struct CurrentParsingState {
-
- let mut position: i32;
-
- let mut encoding: State;
-}
-
-impl CurrentParsingState {
-
- enum State {
-
- NUMERIC(), ALPHA(), ISO_IEC_646()
- }
-
- fn new() -> CurrentParsingState {
- let .position = 0;
- let .encoding = State::NUMERIC;
- }
-
- fn get_position(&self) -> i32 {
- return self.position;
- }
-
- fn set_position(&self, position: i32) {
- self.position = position;
- }
-
- fn increment_position(&self, delta: i32) {
- self.position += delta;
- }
-
- fn is_alpha(&self) -> bool {
- return self.encoding == State::ALPHA;
- }
-
- fn is_numeric(&self) -> bool {
- return self.encoding == State::NUMERIC;
- }
-
- fn is_iso_iec646(&self) -> bool {
- return self.encoding == State::ISO_IEC_646;
- }
-
- fn set_numeric(&self) {
- self.encoding = State::NUMERIC;
- }
-
- fn set_alpha(&self) {
- self.encoding = State::ALPHA;
- }
-
- fn set_iso_iec646(&self) {
- self.encoding = State::ISO_IEC_646;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/decoded_char.rs b/port_src/output/zxing/oned/rss/expanded/decoders/decoded_char.rs
deleted file mode 100644
index 95e64e9..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/decoded_char.rs
+++ /dev/null
@@ -1,46 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-
-// It's not in Alphanumeric neither in ISO/IEC 646 charset
- const FNC1: char = '$';
-struct DecodedChar {
- super: DecodedObject;
-
- let value: char;
-}
-
-impl DecodedChar {
-
- fn new( new_position: i32, value: char) -> DecodedChar {
- super(new_position);
- let .value = value;
- }
-
- fn get_value(&self) -> char {
- return self.value;
- }
-
- fn is_f_n_c1(&self) -> bool {
- return self.value == FNC1;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/decoded_information.rs b/port_src/output/zxing/oned/rss/expanded/decoders/decoded_information.rs
deleted file mode 100644
index 90d02de..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/decoded_information.rs
+++ /dev/null
@@ -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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-struct DecodedInformation {
- super: DecodedObject;
-
- let new_string: String;
-
- let remaining_value: i32;
-
- let mut remaining: bool;
-}
-
-impl DecodedInformation {
-
- fn new( new_position: i32, new_string: &String) -> DecodedInformation {
- super(new_position);
- let .newString = new_string;
- let .remaining = false;
- let .remainingValue = 0;
- }
-
- fn new( new_position: i32, new_string: &String, remaining_value: i32) -> DecodedInformation {
- super(new_position);
- let .remaining = true;
- let .remainingValue = remaining_value;
- let .newString = new_string;
- }
-
- fn get_new_string(&self) -> String {
- return self.newString;
- }
-
- fn is_remaining(&self) -> bool {
- return self.remaining;
- }
-
- fn get_remaining_value(&self) -> i32 {
- return self.remainingValue;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/decoded_numeric.rs b/port_src/output/zxing/oned/rss/expanded/decoders/decoded_numeric.rs
deleted file mode 100644
index 37bea05..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/decoded_numeric.rs
+++ /dev/null
@@ -1,63 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-
- const FNC1: i32 = 10;
-struct DecodedNumeric {
- super: DecodedObject;
-
- let first_digit: i32;
-
- let second_digit: i32;
-}
-
-impl DecodedNumeric {
-
- fn new( new_position: i32, first_digit: i32, second_digit: i32) -> DecodedNumeric throws FormatException {
- super(new_position);
- if first_digit < 0 || first_digit > 10 || second_digit < 0 || second_digit > 10 {
- throw FormatException::get_format_instance();
- }
- let .firstDigit = first_digit;
- let .secondDigit = second_digit;
- }
-
- fn get_first_digit(&self) -> i32 {
- return self.firstDigit;
- }
-
- fn get_second_digit(&self) -> i32 {
- return self.secondDigit;
- }
-
- fn get_value(&self) -> i32 {
- return self.firstDigit * 10 + self.secondDigit;
- }
-
- fn is_first_digit_f_n_c1(&self) -> bool {
- return self.firstDigit == FNC1;
- }
-
- fn is_second_digit_f_n_c1(&self) -> bool {
- return self.secondDigit == FNC1;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/decoded_object.rs b/port_src/output/zxing/oned/rss/expanded/decoders/decoded_object.rs
deleted file mode 100644
index ed28cfd..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/decoded_object.rs
+++ /dev/null
@@ -1,36 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- */
-struct DecodedObject {
-
- let new_position: i32;
-}
-
-impl DecodedObject {
-
- fn new( new_position: i32) -> DecodedObject {
- let .newPosition = new_position;
- }
-
- fn get_new_position(&self) -> i32 {
- return self.newPosition;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/field_parser.rs b/port_src/output/zxing/oned/rss/expanded/decoders/field_parser.rs
deleted file mode 100644
index 12df4e8..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/field_parser.rs
+++ /dev/null
@@ -1,255 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-
- const TWO_DIGIT_DATA_LENGTH: Map = HashMap<>::new();
-
- const THREE_DIGIT_DATA_LENGTH: Map = HashMap<>::new();
-
- const THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH: Map = HashMap<>::new();
-
- const FOUR_DIGIT_DATA_LENGTH: Map = HashMap<>::new();
-struct FieldParser {
-}
-
-impl FieldParser {
-
- static {
- TWO_DIGIT_DATA_LENGTH::put("00", &DataLength::fixed(18));
- TWO_DIGIT_DATA_LENGTH::put("01", &DataLength::fixed(14));
- TWO_DIGIT_DATA_LENGTH::put("02", &DataLength::fixed(14));
- TWO_DIGIT_DATA_LENGTH::put("10", &DataLength::variable(20));
- TWO_DIGIT_DATA_LENGTH::put("11", &DataLength::fixed(6));
- TWO_DIGIT_DATA_LENGTH::put("12", &DataLength::fixed(6));
- TWO_DIGIT_DATA_LENGTH::put("13", &DataLength::fixed(6));
- TWO_DIGIT_DATA_LENGTH::put("15", &DataLength::fixed(6));
- TWO_DIGIT_DATA_LENGTH::put("17", &DataLength::fixed(6));
- TWO_DIGIT_DATA_LENGTH::put("20", &DataLength::fixed(2));
- TWO_DIGIT_DATA_LENGTH::put("21", &DataLength::variable(20));
- TWO_DIGIT_DATA_LENGTH::put("22", &DataLength::variable(29));
- TWO_DIGIT_DATA_LENGTH::put("30", &DataLength::variable(8));
- TWO_DIGIT_DATA_LENGTH::put("37", &DataLength::variable(8));
- //internal company codes
- {
- let mut i: i32 = 90;
- while i <= 99 {
- {
- TWO_DIGIT_DATA_LENGTH::put(&String::value_of(i), &DataLength::variable(30));
- }
- i += 1;
- }
- }
-
- }
-
- static {
- THREE_DIGIT_DATA_LENGTH::put("240", &DataLength::variable(30));
- THREE_DIGIT_DATA_LENGTH::put("241", &DataLength::variable(30));
- THREE_DIGIT_DATA_LENGTH::put("242", &DataLength::variable(6));
- THREE_DIGIT_DATA_LENGTH::put("250", &DataLength::variable(30));
- THREE_DIGIT_DATA_LENGTH::put("251", &DataLength::variable(30));
- THREE_DIGIT_DATA_LENGTH::put("253", &DataLength::variable(17));
- THREE_DIGIT_DATA_LENGTH::put("254", &DataLength::variable(20));
- THREE_DIGIT_DATA_LENGTH::put("400", &DataLength::variable(30));
- THREE_DIGIT_DATA_LENGTH::put("401", &DataLength::variable(30));
- THREE_DIGIT_DATA_LENGTH::put("402", &DataLength::fixed(17));
- THREE_DIGIT_DATA_LENGTH::put("403", &DataLength::variable(30));
- THREE_DIGIT_DATA_LENGTH::put("410", &DataLength::fixed(13));
- THREE_DIGIT_DATA_LENGTH::put("411", &DataLength::fixed(13));
- THREE_DIGIT_DATA_LENGTH::put("412", &DataLength::fixed(13));
- THREE_DIGIT_DATA_LENGTH::put("413", &DataLength::fixed(13));
- THREE_DIGIT_DATA_LENGTH::put("414", &DataLength::fixed(13));
- THREE_DIGIT_DATA_LENGTH::put("420", &DataLength::variable(20));
- THREE_DIGIT_DATA_LENGTH::put("421", &DataLength::variable(15));
- THREE_DIGIT_DATA_LENGTH::put("422", &DataLength::fixed(3));
- THREE_DIGIT_DATA_LENGTH::put("423", &DataLength::variable(15));
- THREE_DIGIT_DATA_LENGTH::put("424", &DataLength::fixed(3));
- THREE_DIGIT_DATA_LENGTH::put("425", &DataLength::fixed(3));
- THREE_DIGIT_DATA_LENGTH::put("426", &DataLength::fixed(3));
- }
-
- static {
- {
- let mut i: i32 = 310;
- while i <= 316 {
- {
- THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put(&String::value_of(i), &DataLength::fixed(6));
- }
- i += 1;
- }
- }
-
- {
- let mut i: i32 = 320;
- while i <= 336 {
- {
- THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put(&String::value_of(i), &DataLength::fixed(6));
- }
- i += 1;
- }
- }
-
- {
- let mut i: i32 = 340;
- while i <= 357 {
- {
- THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put(&String::value_of(i), &DataLength::fixed(6));
- }
- i += 1;
- }
- }
-
- {
- let mut i: i32 = 360;
- while i <= 369 {
- {
- THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put(&String::value_of(i), &DataLength::fixed(6));
- }
- i += 1;
- }
- }
-
- THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put("390", &DataLength::variable(15));
- THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put("391", &DataLength::variable(18));
- THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put("392", &DataLength::variable(15));
- THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put("393", &DataLength::variable(18));
- THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::put("703", &DataLength::variable(30));
- }
-
- static {
- FOUR_DIGIT_DATA_LENGTH::put("7001", &DataLength::fixed(13));
- FOUR_DIGIT_DATA_LENGTH::put("7002", &DataLength::variable(30));
- FOUR_DIGIT_DATA_LENGTH::put("7003", &DataLength::fixed(10));
- FOUR_DIGIT_DATA_LENGTH::put("8001", &DataLength::fixed(14));
- FOUR_DIGIT_DATA_LENGTH::put("8002", &DataLength::variable(20));
- FOUR_DIGIT_DATA_LENGTH::put("8003", &DataLength::variable(30));
- FOUR_DIGIT_DATA_LENGTH::put("8004", &DataLength::variable(30));
- FOUR_DIGIT_DATA_LENGTH::put("8005", &DataLength::fixed(6));
- FOUR_DIGIT_DATA_LENGTH::put("8006", &DataLength::fixed(18));
- FOUR_DIGIT_DATA_LENGTH::put("8007", &DataLength::variable(30));
- FOUR_DIGIT_DATA_LENGTH::put("8008", &DataLength::variable(12));
- FOUR_DIGIT_DATA_LENGTH::put("8018", &DataLength::fixed(18));
- FOUR_DIGIT_DATA_LENGTH::put("8020", &DataLength::variable(25));
- FOUR_DIGIT_DATA_LENGTH::put("8100", &DataLength::fixed(6));
- FOUR_DIGIT_DATA_LENGTH::put("8101", &DataLength::fixed(10));
- FOUR_DIGIT_DATA_LENGTH::put("8102", &DataLength::fixed(2));
- FOUR_DIGIT_DATA_LENGTH::put("8110", &DataLength::variable(70));
- FOUR_DIGIT_DATA_LENGTH::put("8200", &DataLength::variable(70));
- }
-
- fn new() -> FieldParser {
- }
-
- fn parse_fields_in_general_purpose( raw_information: &String) -> /* throws NotFoundException */Result> {
- if raw_information.is_empty() {
- return Ok(null);
- }
- if raw_information.length() < 2 {
- throw NotFoundException::get_not_found_instance();
- }
- let two_digit_data_length: DataLength = TWO_DIGIT_DATA_LENGTH::get(&raw_information.substring(0, 2));
- if two_digit_data_length != null {
- if two_digit_data_length.variable {
- return Ok(::process_variable_a_i(2, two_digit_data_length.len(), &raw_information));
- }
- return Ok(::process_fixed_a_i(2, two_digit_data_length.len(), &raw_information));
- }
- if raw_information.length() < 3 {
- throw NotFoundException::get_not_found_instance();
- }
- let first_three_digits: String = raw_information.substring(0, 3);
- let three_digit_data_length: DataLength = THREE_DIGIT_DATA_LENGTH::get(&first_three_digits);
- if three_digit_data_length != null {
- if three_digit_data_length.variable {
- return Ok(::process_variable_a_i(3, three_digit_data_length.len(), &raw_information));
- }
- return Ok(::process_fixed_a_i(3, three_digit_data_length.len(), &raw_information));
- }
- if raw_information.length() < 4 {
- throw NotFoundException::get_not_found_instance();
- }
- let three_digit_plus_digit_data_length: DataLength = THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH::get(&first_three_digits);
- if three_digit_plus_digit_data_length != null {
- if three_digit_plus_digit_data_length.variable {
- return Ok(::process_variable_a_i(4, three_digit_plus_digit_data_length.len(), &raw_information));
- }
- return Ok(::process_fixed_a_i(4, three_digit_plus_digit_data_length.len(), &raw_information));
- }
- let first_four_digit_length: DataLength = FOUR_DIGIT_DATA_LENGTH::get(&raw_information.substring(0, 4));
- if first_four_digit_length != null {
- if first_four_digit_length.variable {
- return Ok(::process_variable_a_i(4, first_four_digit_length.len(), &raw_information));
- }
- return Ok(::process_fixed_a_i(4, first_four_digit_length.len(), &raw_information));
- }
- throw NotFoundException::get_not_found_instance();
- }
-
- fn process_fixed_a_i( ai_size: i32, field_size: i32, raw_information: &String) -> /* throws NotFoundException */Result> {
- if raw_information.length() < ai_size {
- throw NotFoundException::get_not_found_instance();
- }
- let ai: String = raw_information.substring(0, ai_size);
- if raw_information.length() < ai_size + field_size {
- throw NotFoundException::get_not_found_instance();
- }
- let field: String = raw_information.substring(ai_size, ai_size + field_size);
- let remaining: String = raw_information.substring(ai_size + field_size);
- let result: String = format!("({}){}", ai, field);
- let parsed_a_i: String = ::parse_fields_in_general_purpose(&remaining);
- return Ok( if parsed_a_i == null { result } else { format!("{}{}", result, parsed_a_i) });
- }
-
- fn process_variable_a_i( ai_size: i32, variable_field_size: i32, raw_information: &String) -> /* throws NotFoundException */Result> {
- let ai: String = raw_information.substring(0, ai_size);
- let max_size: i32 = Math::min(&raw_information.length(), ai_size + variable_field_size);
- let field: String = raw_information.substring(ai_size, max_size);
- let remaining: String = raw_information.substring(max_size);
- let result: String = format!("({}){}", ai, field);
- let parsed_a_i: String = ::parse_fields_in_general_purpose(&remaining);
- return Ok( if parsed_a_i == null { result } else { format!("{}{}", result, parsed_a_i) });
- }
-
- struct DataLength {
-
- let variable: bool;
-
- let length: i32;
- }
-
- impl DataLength {
-
- fn new( variable: bool, length: i32) -> DataLength {
- let .variable = variable;
- let .len() = length;
- }
-
- fn fixed( length: i32) -> DataLength {
- return DataLength::new(false, length);
- }
-
- fn variable( length: i32) -> DataLength {
- return DataLength::new(true, length);
- }
- }
-
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/decoders/general_app_id_decoder.rs b/port_src/output/zxing/oned/rss/expanded/decoders/general_app_id_decoder.rs
deleted file mode 100644
index cb5cce9..0000000
--- a/port_src/output/zxing/oned/rss/expanded/decoders/general_app_id_decoder.rs
+++ /dev/null
@@ -1,508 +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.
- */
-// package com::google::zxing::oned::rss::expanded::decoders;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-struct GeneralAppIdDecoder {
-
- let information: BitArray;
-
- let current: CurrentParsingState = CurrentParsingState::new();
-
- let buffer: StringBuilder = StringBuilder::new();
-}
-
-impl GeneralAppIdDecoder {
-
- fn new( information: &BitArray) -> GeneralAppIdDecoder {
- let .information = information;
- }
-
- fn decode_all_codes(&self, buff: &StringBuilder, initial_position: i32) -> /* throws NotFoundException, FormatException */Result> {
- let current_position: i32 = initial_position;
- let mut remaining: String = null;
- loop { {
- let info: DecodedInformation = self.decode_general_purpose_field(current_position, &remaining);
- let parsed_fields: String = FieldParser::parse_fields_in_general_purpose(&info.get_new_string());
- if parsed_fields != null {
- buff.append(&parsed_fields);
- }
- if info.is_remaining() {
- remaining = String::value_of(&info.get_remaining_value());
- } else {
- remaining = null;
- }
- if current_position == info.get_new_position() {
- // No step forward!
- break;
- }
- current_position = info.get_new_position();
- }if !(true) break;}
- return Ok(buff.to_string());
- }
-
- fn is_still_numeric(&self, pos: i32) -> bool {
- // and one of the first 4 bits is "1".
- if pos + 7 > self.information.get_size() {
- return pos + 4 <= self.information.get_size();
- }
- {
- let mut i: i32 = pos;
- while i < pos + 3 {
- {
- if self.information.get(i) {
- return true;
- }
- }
- i += 1;
- }
- }
-
- return self.information.get(pos + 3);
- }
-
- fn decode_numeric(&self, pos: i32) -> /* throws FormatException */Result> {
- if pos + 7 > self.information.get_size() {
- let numeric: i32 = ::extract_numeric_value_from_bit_array(pos, 4);
- if numeric == 0 {
- return Ok(DecodedNumeric::new(&self.information.get_size(), DecodedNumeric::FNC1, DecodedNumeric::FNC1));
- }
- return Ok(DecodedNumeric::new(&self.information.get_size(), numeric - 1, DecodedNumeric::FNC1));
- }
- let numeric: i32 = ::extract_numeric_value_from_bit_array(pos, 7);
- let digit1: i32 = (numeric - 8) / 11;
- let digit2: i32 = (numeric - 8) % 11;
- return Ok(DecodedNumeric::new(pos + 7, digit1, digit2));
- }
-
- fn extract_numeric_value_from_bit_array(&self, pos: i32, bits: i32) -> i32 {
- return ::extract_numeric_value_from_bit_array(self.information, pos, bits);
- }
-
- fn extract_numeric_value_from_bit_array( information: &BitArray, pos: i32, bits: i32) -> i32 {
- let mut value: i32 = 0;
- {
- let mut i: i32 = 0;
- while i < bits {
- {
- if information.get(pos + i) {
- value |= 1 << (bits - i - 1);
- }
- }
- i += 1;
- }
- }
-
- return value;
- }
-
- fn decode_general_purpose_field(&self, pos: i32, remaining: &String) -> /* throws FormatException */Result> {
- self.buffer.set_length(0);
- if remaining != null {
- self.buffer.append(&remaining);
- }
- self.current.set_position(pos);
- let last_decoded: DecodedInformation = self.parse_blocks();
- if last_decoded != null && last_decoded.is_remaining() {
- return Ok(DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string(), &last_decoded.get_remaining_value()));
- }
- return Ok(DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string()));
- }
-
- fn parse_blocks(&self) -> /* throws FormatException */Result> {
- let is_finished: bool;
- let mut result: BlockParsedResult;
- loop { {
- let initial_position: i32 = self.current.get_position();
- if self.current.is_alpha() {
- result = self.parse_alpha_block();
- is_finished = result.is_finished();
- } else if self.current.is_iso_iec646() {
- result = self.parse_iso_iec646_block();
- is_finished = result.is_finished();
- } else {
- // it must be numeric
- result = self.parse_numeric_block();
- is_finished = result.is_finished();
- }
- let position_changed: bool = initial_position != self.current.get_position();
- if !position_changed && !is_finished {
- break;
- }
- }if !(!is_finished) break;}
- return Ok(result.get_decoded_information());
- }
-
- fn parse_numeric_block(&self) -> /* throws FormatException */Result> {
- while self.is_still_numeric(&self.current.get_position()) {
- let numeric: DecodedNumeric = self.decode_numeric(&self.current.get_position());
- self.current.set_position(&numeric.get_new_position());
- if numeric.is_first_digit_f_n_c1() {
- let mut information: DecodedInformation;
- if numeric.is_second_digit_f_n_c1() {
- information = DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string());
- } else {
- information = DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string(), &numeric.get_second_digit());
- }
- return Ok(BlockParsedResult::new(information, true));
- }
- self.buffer.append(&numeric.get_first_digit());
- if numeric.is_second_digit_f_n_c1() {
- let information: DecodedInformation = DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string());
- return Ok(BlockParsedResult::new(information, true));
- }
- self.buffer.append(&numeric.get_second_digit());
- }
- if self.is_numeric_to_alpha_numeric_latch(&self.current.get_position()) {
- self.current.set_alpha();
- self.current.increment_position(4);
- }
- return Ok(BlockParsedResult::new());
- }
-
- fn parse_iso_iec646_block(&self) -> /* throws FormatException */Result> {
- while self.is_still_iso_iec646(&self.current.get_position()) {
- let iso: DecodedChar = self.decode_iso_iec646(&self.current.get_position());
- self.current.set_position(&iso.get_new_position());
- if iso.is_f_n_c1() {
- let information: DecodedInformation = DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string());
- return Ok(BlockParsedResult::new(information, true));
- }
- self.buffer.append(&iso.get_value());
- }
- if self.is_alpha_or646_to_numeric_latch(&self.current.get_position()) {
- self.current.increment_position(3);
- self.current.set_numeric();
- } else if self.is_alpha_to646_to_alpha_latch(&self.current.get_position()) {
- if self.current.get_position() + 5 < self.information.get_size() {
- self.current.increment_position(5);
- } else {
- self.current.set_position(&self.information.get_size());
- }
- self.current.set_alpha();
- }
- return Ok(BlockParsedResult::new());
- }
-
- fn parse_alpha_block(&self) -> BlockParsedResult {
- while self.is_still_alpha(&self.current.get_position()) {
- let alpha: DecodedChar = self.decode_alphanumeric(&self.current.get_position());
- self.current.set_position(&alpha.get_new_position());
- if alpha.is_f_n_c1() {
- let information: DecodedInformation = DecodedInformation::new(&self.current.get_position(), &self.buffer.to_string());
- //end of the char block
- return BlockParsedResult::new(information, true);
- }
- self.buffer.append(&alpha.get_value());
- }
- if self.is_alpha_or646_to_numeric_latch(&self.current.get_position()) {
- self.current.increment_position(3);
- self.current.set_numeric();
- } else if self.is_alpha_to646_to_alpha_latch(&self.current.get_position()) {
- if self.current.get_position() + 5 < self.information.get_size() {
- self.current.increment_position(5);
- } else {
- self.current.set_position(&self.information.get_size());
- }
- self.current.set_iso_iec646();
- }
- return BlockParsedResult::new();
- }
-
- fn is_still_iso_iec646(&self, pos: i32) -> bool {
- if pos + 5 > self.information.get_size() {
- return false;
- }
- let five_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 5);
- if five_bit_value >= 5 && five_bit_value < 16 {
- return true;
- }
- if pos + 7 > self.information.get_size() {
- return false;
- }
- let seven_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 7);
- if seven_bit_value >= 64 && seven_bit_value < 116 {
- return true;
- }
- if pos + 8 > self.information.get_size() {
- return false;
- }
- let eight_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 8);
- return eight_bit_value >= 232 && eight_bit_value < 253;
- }
-
- fn decode_iso_iec646(&self, pos: i32) -> /* throws FormatException */Result> {
- let five_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 5);
- if five_bit_value == 15 {
- return Ok(DecodedChar::new(pos + 5, DecodedChar::FNC1));
- }
- if five_bit_value >= 5 && five_bit_value < 15 {
- return Ok(DecodedChar::new(pos + 5, ('0' + five_bit_value - 5) as char));
- }
- let seven_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 7);
- if seven_bit_value >= 64 && seven_bit_value < 90 {
- return Ok(DecodedChar::new(pos + 7, (seven_bit_value + 1) as char));
- }
- if seven_bit_value >= 90 && seven_bit_value < 116 {
- return Ok(DecodedChar::new(pos + 7, (seven_bit_value + 7) as char));
- }
- let eight_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 8);
- let mut c: char;
- match eight_bit_value {
- 232 =>
- {
- c = '!';
- break;
- }
- 233 =>
- {
- c = '"';
- break;
- }
- 234 =>
- {
- c = '%';
- break;
- }
- 235 =>
- {
- c = '&';
- break;
- }
- 236 =>
- {
- c = '\'';
- break;
- }
- 237 =>
- {
- c = '(';
- break;
- }
- 238 =>
- {
- c = ')';
- break;
- }
- 239 =>
- {
- c = '*';
- break;
- }
- 240 =>
- {
- c = '+';
- break;
- }
- 241 =>
- {
- c = ',';
- break;
- }
- 242 =>
- {
- c = '-';
- break;
- }
- 243 =>
- {
- c = '.';
- break;
- }
- 244 =>
- {
- c = '/';
- break;
- }
- 245 =>
- {
- c = ':';
- break;
- }
- 246 =>
- {
- c = ';';
- break;
- }
- 247 =>
- {
- c = '<';
- break;
- }
- 248 =>
- {
- c = '=';
- break;
- }
- 249 =>
- {
- c = '>';
- break;
- }
- 250 =>
- {
- c = '?';
- break;
- }
- 251 =>
- {
- c = '_';
- break;
- }
- 252 =>
- {
- c = ' ';
- break;
- }
- _ =>
- {
- throw FormatException::get_format_instance();
- }
- }
- return Ok(DecodedChar::new(pos + 8, c));
- }
-
- fn is_still_alpha(&self, pos: i32) -> bool {
- if pos + 5 > self.information.get_size() {
- return false;
- }
- // We now check if it's a valid 5-bit value (0..9 and FNC1)
- let five_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 5);
- if five_bit_value >= 5 && five_bit_value < 16 {
- return true;
- }
- if pos + 6 > self.information.get_size() {
- return false;
- }
- let six_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 6);
- // 63 not included
- return six_bit_value >= 16 && six_bit_value < 63;
- }
-
- fn decode_alphanumeric(&self, pos: i32) -> DecodedChar {
- let five_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 5);
- if five_bit_value == 15 {
- return DecodedChar::new(pos + 5, DecodedChar::FNC1);
- }
- if five_bit_value >= 5 && five_bit_value < 15 {
- return DecodedChar::new(pos + 5, ('0' + five_bit_value - 5) as char);
- }
- let six_bit_value: i32 = ::extract_numeric_value_from_bit_array(pos, 6);
- if six_bit_value >= 32 && six_bit_value < 58 {
- return DecodedChar::new(pos + 6, (six_bit_value + 33) as char);
- }
- let mut c: char;
- match six_bit_value {
- 58 =>
- {
- c = '*';
- break;
- }
- 59 =>
- {
- c = ',';
- break;
- }
- 60 =>
- {
- c = '-';
- break;
- }
- 61 =>
- {
- c = '.';
- break;
- }
- 62 =>
- {
- c = '/';
- break;
- }
- _ =>
- {
- throw IllegalStateException::new(format!("Decoding invalid alphanumeric value: {}", six_bit_value));
- }
- }
- return DecodedChar::new(pos + 6, c);
- }
-
- fn is_alpha_to646_to_alpha_latch(&self, pos: i32) -> bool {
- if pos + 1 > self.information.get_size() {
- return false;
- }
- {
- let mut i: i32 = 0;
- while i < 5 && i + pos < self.information.get_size() {
- {
- if i == 2 {
- if !self.information.get(pos + 2) {
- return false;
- }
- } else if self.information.get(pos + i) {
- return false;
- }
- }
- i += 1;
- }
- }
-
- return true;
- }
-
- fn is_alpha_or646_to_numeric_latch(&self, pos: i32) -> bool {
- // Next is alphanumeric if there are 3 positions and they are all zeros
- if pos + 3 > self.information.get_size() {
- return false;
- }
- {
- let mut i: i32 = pos;
- while i < pos + 3 {
- {
- if self.information.get(i) {
- return false;
- }
- }
- i += 1;
- }
- }
-
- return true;
- }
-
- fn is_numeric_to_alpha_numeric_latch(&self, pos: i32) -> bool {
- // if there is a subset of this just before the end of the symbol
- if pos + 1 > self.information.get_size() {
- return false;
- }
- {
- let mut i: i32 = 0;
- while i < 4 && i + pos < self.information.get_size() {
- {
- if self.information.get(pos + i) {
- return false;
- }
- }
- i += 1;
- }
- }
-
- return true;
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/expanded_pair.rs b/port_src/output/zxing/oned/rss/expanded/expanded_pair.rs
deleted file mode 100644
index e730d6b..0000000
--- a/port_src/output/zxing/oned/rss/expanded/expanded_pair.rs
+++ /dev/null
@@ -1,70 +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.
- */
-// package com::google::zxing::oned::rss::expanded;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- */
-struct ExpandedPair {
-
- let left_char: DataCharacter;
-
- let right_char: DataCharacter;
-
- let finder_pattern: FinderPattern;
-}
-
-impl ExpandedPair {
-
- fn new( left_char: &DataCharacter, right_char: &DataCharacter, finder_pattern: &FinderPattern) -> ExpandedPair {
- let .leftChar = left_char;
- let .rightChar = right_char;
- let .finderPattern = finder_pattern;
- }
-
- fn get_left_char(&self) -> DataCharacter {
- return self.leftChar;
- }
-
- fn get_right_char(&self) -> DataCharacter {
- return self.rightChar;
- }
-
- fn get_finder_pattern(&self) -> FinderPattern {
- return self.finderPattern;
- }
-
- fn must_be_last(&self) -> bool {
- return self.rightChar == null;
- }
-
- pub fn to_string(&self) -> String {
- return format!("[ {} , {} : {} ]", self.left_char, self.right_char, ( if self.finder_pattern == null { "null" } else { self.finder_pattern.get_value() }));
- }
-
- pub fn equals(&self, o: &Object) -> bool {
- if !(o instanceof ExpandedPair) {
- return false;
- }
- let that: ExpandedPair = o as ExpandedPair;
- return Objects::equals(self.left_char, that.leftChar) && Objects::equals(self.right_char, that.rightChar) && Objects::equals(self.finder_pattern, that.finderPattern);
- }
-
- pub fn hash_code(&self) -> i32 {
- return Objects::hash_code(self.left_char) ^ Objects::hash_code(self.right_char) ^ Objects::hash_code(self.finder_pattern);
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/expanded_row.rs b/port_src/output/zxing/oned/rss/expanded/expanded_row.rs
deleted file mode 100644
index f0c03bf..0000000
--- a/port_src/output/zxing/oned/rss/expanded/expanded_row.rs
+++ /dev/null
@@ -1,66 +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.
- */
-// package com::google::zxing::oned::rss::expanded;
-
-/**
- * One row of an RSS Expanded Stacked symbol, consisting of 1+ expanded pairs.
- */
-struct ExpandedRow {
-
- let pairs: List;
-
- let row_number: i32;
-}
-
-impl ExpandedRow {
-
- fn new( pairs: &List, row_number: i32) -> ExpandedRow {
- let .pairs = ArrayList<>::new(&pairs);
- let .rowNumber = row_number;
- }
-
- fn get_pairs(&self) -> List {
- return self.pairs;
- }
-
- fn get_row_number(&self) -> i32 {
- return self.rowNumber;
- }
-
- fn is_equivalent(&self, other_pairs: &List) -> bool {
- return self.pairs.equals(&other_pairs);
- }
-
- pub fn to_string(&self) -> String {
- return format!("{ {} }", self.pairs);
- }
-
- /**
- * Two rows are equal if they contain the same pairs in the same order.
- */
- pub fn equals(&self, o: &Object) -> bool {
- if !(o instanceof ExpandedRow) {
- return false;
- }
- let that: ExpandedRow = o as ExpandedRow;
- return self.pairs.equals(that.pairs);
- }
-
- pub fn hash_code(&self) -> i32 {
- return self.pairs.hash_code();
- }
-}
-
diff --git a/port_src/output/zxing/oned/rss/expanded/r_s_s_expanded_reader.rs b/port_src/output/zxing/oned/rss/expanded/r_s_s_expanded_reader.rs
deleted file mode 100644
index e67e071..0000000
--- a/port_src/output/zxing/oned/rss/expanded/r_s_s_expanded_reader.rs
+++ /dev/null
@@ -1,802 +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.
- */
-// package com::google::zxing::oned::rss::expanded;
-
-/**
- * @author Pablo Orduña, University of Deusto (pablo.orduna@deusto.es)
- * @author Eduardo Castillejo, University of Deusto (eduardo.castillejo@deusto.es)
- */
-
- const SYMBOL_WIDEST: vec![Vec; 5] = vec![7, 5, 4, 3, 1, ]
-;
-
- const EVEN_TOTAL_SUBSET: vec![Vec; 5] = vec![4, 20, 52, 104, 204, ]
-;
-
- const GSUM: vec![Vec; 5] = vec![0, 348, 1388, 2948, 3988, ]
-;
-
- const FINDER_PATTERNS: vec![vec![Vec>; 4]; 6] = vec![// A
-vec![1, 8, 4, 1, ]
-, // B
-vec![3, 6, 4, 1, ]
-, // C
-vec![3, 4, 6, 1, ]
-, // D
-vec![3, 2, 8, 1, ]
-, // E
-vec![2, 6, 5, 1, ]
-, // F
-vec![2, 2, 9, 1, ]
-, ]
-;
-
- const WEIGHTS: vec![vec![Vec>; 8]; 23] = vec![vec![1, 3, 9, 27, 81, 32, 96, 77, ]
-, vec![20, 60, 180, 118, 143, 7, 21, 63, ]
-, vec![189, 145, 13, 39, 117, 140, 209, 205, ]
-, vec![193, 157, 49, 147, 19, 57, 171, 91, ]
-, vec![62, 186, 136, 197, 169, 85, 44, 132, ]
-, vec![185, 133, 188, 142, 4, 12, 36, 108, ]
-, vec![113, 128, 173, 97, 80, 29, 87, 50, ]
-, vec![150, 28, 84, 41, 123, 158, 52, 156, ]
-, vec![46, 138, 203, 187, 139, 206, 196, 166, ]
-, vec![76, 17, 51, 153, 37, 111, 122, 155, ]
-, vec![43, 129, 176, 106, 107, 110, 119, 146, ]
-, vec![16, 48, 144, 10, 30, 90, 59, 177, ]
-, vec![109, 116, 137, 200, 178, 112, 125, 164, ]
-, vec![70, 210, 208, 202, 184, 130, 179, 115, ]
-, vec![134, 191, 151, 31, 93, 68, 204, 190, ]
-, vec![148, 22, 66, 198, 172, 94, 71, 2, ]
-, vec![6, 18, 54, 162, 64, 192, 154, 40, ]
-, vec![120, 149, 25, 75, 14, 42, 126, 167, ]
-, vec![79, 26, 78, 23, 69, 207, 199, 175, ]
-, vec![103, 98, 83, 38, 114, 131, 182, 124, ]
-, vec![161, 61, 183, 127, 170, 88, 53, 159, ]
-, vec![55, 165, 73, 8, 24, 72, 5, 15, ]
-, vec![45, 135, 194, 160, 58, 174, 100, 89, ]
-, ]
-;
-
- const FINDER_PAT_A: i32 = 0;
-
- const FINDER_PAT_B: i32 = 1;
-
- const FINDER_PAT_C: i32 = 2;
-
- const FINDER_PAT_D: i32 = 3;
-
- const FINDER_PAT_E: i32 = 4;
-
- const FINDER_PAT_F: i32 = 5;
-
- const FINDER_PATTERN_SEQUENCES: vec![vec![Vec>; 11]; 10] = vec![vec![FINDER_PAT_A, FINDER_PAT_A, ]
-, vec![FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, ]
-, vec![FINDER_PAT_A, FINDER_PAT_C, FINDER_PAT_B, FINDER_PAT_D, ]
-, vec![FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_C, ]
-, vec![FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_D, FINDER_PAT_F, ]
-, vec![FINDER_PAT_A, FINDER_PAT_E, FINDER_PAT_B, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F, ]
-, vec![FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_D, ]
-, vec![FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_E, ]
-, vec![FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F, ]
-, vec![FINDER_PAT_A, FINDER_PAT_A, FINDER_PAT_B, FINDER_PAT_B, FINDER_PAT_C, FINDER_PAT_D, FINDER_PAT_D, FINDER_PAT_E, FINDER_PAT_E, FINDER_PAT_F, FINDER_PAT_F, ]
-, ]
-;
-
- const MAX_PAIRS: i32 = 11;
-pub struct RSSExpandedReader {
- super: AbstractRSSReader;
-
- let pairs: List = ArrayList<>::new(MAX_PAIRS);
-
- let rows: List = ArrayList<>::new();
-
- let start_end: [i32; 2] = [0; 2];
-
- let start_from_even: bool;
-}
-
-impl RSSExpandedReader {
-
- pub fn decode_row(&self, row_number: i32, row: &BitArray, hints: &Map) -> /* throws NotFoundException, FormatException */Result> {
- // Rows can start with even pattern in case in prev rows there where odd number of patters.
- // So lets try twice
- self.pairs.clear();
- self.startFromEven = false;
- let tryResult1 = 0;
- 'try1: loop {
- {
- return Ok(::construct_result(&self.decode_row2pairs(row_number, row)));
- }
- break 'try1
- }
- match tryResult1 {
- catch ( e: &NotFoundException) {
- } 0 => break
- }
-
- self.pairs.clear();
- self.startFromEven = true;
- return Ok(::construct_result(&self.decode_row2pairs(row_number, row)));
- }
-
- pub fn reset(&self) {
- self.pairs.clear();
- self.rows.clear();
- }
-
- // Not private for testing
- fn decode_row2pairs(&self, row_number: i32, row: &BitArray) -> /* throws NotFoundException */Result, Rc> {
- let mut done: bool = false;
- while !done {
- let tryResult1 = 0;
- 'try1: loop {
- {
- self.pairs.add(&self.retrieve_next_pair(row, self.pairs, row_number));
- }
- break 'try1
- }
- match tryResult1 {
- catch ( nfe: &NotFoundException) {
- if self.pairs.is_empty() {
- throw nfe;
- }
- done = true;
- } 0 => break
- }
-
- }
- // TODO: verify sequence of finder patterns as in checkPairSequence()
- if self.check_checksum() {
- return Ok(self.pairs);
- }
- let try_stacked_decode: bool = !self.rows.is_empty();
- // TODO: deal with reversed rows
- self.store_row(row_number);
- if try_stacked_decode {
- // When the image is 180-rotated, then rows are sorted in wrong direction.
- // Try twice with both the directions.
- let mut ps: List = self.check_rows(false);
- if ps != null {
- return Ok(ps);
- }
- ps = self.check_rows(true);
- if ps != null {
- return Ok(ps);
- }
- }
- throw NotFoundException::get_not_found_instance();
- }
-
- fn check_rows(&self, reverse: bool) -> List {
- // Stacked barcode can have up to 11 rows, so 25 seems reasonable enough
- if self.rows.size() > 25 {
- // We will never have a chance to get result, so clear it
- self.rows.clear();
- return Ok(null);
- }
- self.pairs.clear();
- if reverse {
- Collections::reverse(self.rows);
- }
- let mut ps: List = null;
- let tryResult1 = 0;
- 'try1: loop {
- {
- ps = self.check_rows(ArrayList<>::new(), 0);
- }
- break 'try1
- }
- match tryResult1 {
- catch ( e: &NotFoundException) {
- } 0 => break
- }
-
- if reverse {
- Collections::reverse(self.rows);
- }
- return Ok(ps);
- }
-
- // Try to construct a valid rows sequence
- // Recursion is used to implement backtracking
- fn check_rows(&self, collected_rows: &List, current_row: i32) -> /* throws NotFoundException */Result, Rc> {
- {
- let mut i: i32 = current_row;
- while i < self.rows.size() {
- {
- let row: ExpandedRow = self.rows.get(i);
- self.pairs.clear();
- for let collected_row: ExpandedRow in collected_rows {
- self.pairs.add_all(&collected_row.get_pairs());
- }
- self.pairs.add_all(&row.get_pairs());
- if ::is_valid_sequence(self.pairs) {
- if self.check_checksum() {
- return Ok(self.pairs);
- }
- let rs: List = ArrayList<>::new(&collected_rows);
- rs.add(row);
- let tryResult1 = 0;
- 'try1: loop {
- {
- // Recursion: try to add more rows
- return Ok(self.check_rows(&rs, i + 1));
- }
- break 'try1
- }
- match tryResult1 {
- catch ( e: &NotFoundException) {
- } 0 => break
- }
-
- }
- }
- i += 1;
- }
- }
-
- throw NotFoundException::get_not_found_instance();
- }
-
- // Whether the pairs form a valid find pattern sequence,
- // either complete or a prefix
- fn is_valid_sequence( pairs: &List) -> bool {
- for let sequence: Vec in FINDER_PATTERN_SEQUENCES {
- if pairs.size() <= sequence.len() {
- let mut stop: bool = true;
- {
- let mut j: i32 = 0;
- while j < pairs.size() {
- {
- if pairs.get(j).get_finder_pattern().get_value() != sequence[j] {
- stop = false;
- break;
- }
- }
- j += 1;
- }
- }
-
- if stop {
- return true;
- }
- }
- }
- return false;
- }
-
- fn store_row(&self, row_number: i32) {
- // Discard if duplicate above or below; otherwise insert in order by row number.
- let insert_pos: i32 = 0;
- let prev_is_same: bool = false;
- let next_is_same: bool = false;
- while insert_pos < self.rows.size() {
- let erow: ExpandedRow = self.rows.get(insert_pos);
- if erow.get_row_number() > row_number {
- next_is_same = erow.is_equivalent(self.pairs);
- break;
- }
- prev_is_same = erow.is_equivalent(self.pairs);
- insert_pos += 1;
- }
- if next_is_same || prev_is_same {
- return;
- }
- // Check whether the row is part of an already detected row
- if ::is_partial_row(self.pairs, self.rows) {
- return;
- }
- self.rows.add(insert_pos, ExpandedRow::new(self.pairs, row_number));
- ::remove_partial_rows(self.pairs, self.rows);
- }
-
- // Remove all the rows that contains only specified pairs
- fn remove_partial_rows( pairs: &Collection, rows: &Collection) {
- {
- let iterator: Iterator = rows.iterator();
- while iterator.has_next(){
- let r: ExpandedRow = iterator.next();
- if r.get_pairs().size() != pairs.size() {
- let all_found: bool = true;
- for let p: ExpandedPair in r.get_pairs() {
- if !pairs.contains(p) {
- all_found = false;
- break;
- }
- }
- if all_found {
- // 'pairs' contains all the pairs from the row 'r'
- iterator.remove();
- }
- }
- }
- }
-
- }
-
- // Returns true when one of the rows already contains all the pairs
- fn is_partial_row( pairs: &Iterable, rows: &Iterable) -> bool {
- for let r: ExpandedRow in rows {
- let all_found: bool = true;
- for let p: ExpandedPair in pairs {
- let mut found: bool = false;
- for let pp: ExpandedPair in r.get_pairs() {
- if p.equals(pp) {
- found = true;
- break;
- }
- }
- if !found {
- all_found = false;
- break;
- }
- }
- if all_found {
- // the row 'r' contain all the pairs from 'pairs'
- return true;
- }
- }
- return false;
- }
-
- // Only used for unit testing
- fn get_rows(&self) -> List {
- return self.rows;
- }
-
- // Not private for unit testing
- fn construct_result( pairs: &List) -> /* throws NotFoundException, FormatException */Result> {
- let binary: BitArray = BitArrayBuilder::build_bit_array(&pairs);
- let decoder: AbstractExpandedDecoder = AbstractExpandedDecoder::create_decoder(binary);
- let resulting_string: String = decoder.parse_information();
- let first_points: Vec = pairs.get(0).get_finder_pattern().get_result_points();
- let last_points: Vec = pairs.get(pairs.size() - 1).get_finder_pattern().get_result_points();
- let result: Result = Result::new(&resulting_string, null, : vec![ResultPoint; 4] = vec![first_points[0], first_points[1], last_points[0], last_points[1], ]
- , BarcodeFormat::RSS_EXPANDED);
- result.put_metadata(ResultMetadataType::SYMBOLOGY_IDENTIFIER, "]e0");
- return Ok(result);
- }
-
- fn check_checksum(&self) -> bool {
- let first_pair: ExpandedPair = self.pairs.get(0);
- let check_character: DataCharacter = first_pair.get_left_char();
- let first_character: DataCharacter = first_pair.get_right_char();
- if first_character == null {
- return false;
- }
- let mut checksum: i32 = first_character.get_checksum_portion();
- let mut s: i32 = 2;
- {
- let mut i: i32 = 1;
- while i < self.pairs.size() {
- {
- let current_pair: ExpandedPair = self.pairs.get(i);
- checksum += current_pair.get_left_char().get_checksum_portion();
- s += 1;
- let current_right_char: DataCharacter = current_pair.get_right_char();
- if current_right_char != null {
- checksum += current_right_char.get_checksum_portion();
- s += 1;
- }
- }
- i += 1;
- }
- }
-
- checksum %= 211;
- let check_character_value: i32 = 211 * (s - 4) + checksum;
- return check_character_value == check_character.get_value();
- }
-
- fn get_next_second_bar( row: &BitArray, initial_pos: i32) -> i32 {
- let current_pos: i32;
- if row.get(initial_pos) {
- current_pos = row.get_next_unset(initial_pos);
- current_pos = row.get_next_set(current_pos);
- } else {
- current_pos = row.get_next_set(initial_pos);
- current_pos = row.get_next_unset(current_pos);
- }
- return current_pos;
- }
-
- // not private for testing
- fn retrieve_next_pair(&self, row: &BitArray, previous_pairs: &List, row_number: i32) -> /* throws NotFoundException */Result> {
- let is_odd_pattern: bool = previous_pairs.size() % 2 == 0;
- if self.start_from_even {
- is_odd_pattern = !is_odd_pattern;
- }
- let mut pattern: FinderPattern;
- let keep_finding: bool = true;
- let forced_offset: i32 = -1;
- loop { {
- self.find_next_pair(row, &previous_pairs, forced_offset);
- pattern = self.parse_found_finder_pattern(row, row_number, is_odd_pattern);
- if pattern == null {
- forced_offset = ::get_next_second_bar(row, self.startEnd[0]);
- } else {
- keep_finding = false;
- }
- }if !(keep_finding) break;}
- // When stacked symbol is split over multiple rows, there's no way to guess if this pair can be last or not.
- // boolean mayBeLast = checkPairSequence(previousPairs, pattern);
- let left_char: DataCharacter = self.decode_data_character(row, pattern, is_odd_pattern, true);
- if !previous_pairs.is_empty() && previous_pairs.get(previous_pairs.size() - 1).must_be_last() {
- throw NotFoundException::get_not_found_instance();
- }
- let right_char: DataCharacter;
- let tryResult1 = 0;
- 'try1: loop {
- {
- right_char = self.decode_data_character(row, pattern, is_odd_pattern, false);
- }
- break 'try1
- }
- match tryResult1 {
- catch ( ignored: &NotFoundException) {
- right_char = null;
- } 0 => break
- }
-
- return Ok(ExpandedPair::new(left_char, right_char, pattern));
- }
-
- fn find_next_pair(&self, row: &BitArray, previous_pairs: &List