mirror of
https://github.com/zxing/zxing.git
synced 2025-02-21 02:55:27 -08:00
Issue #61 : touch up style in test and simplify new logic
This commit is contained in:
parent
525774a953
commit
9d4b8b9565
1
AUTHORS
1
AUTHORS
|
@ -77,6 +77,7 @@ Matthew Schulkind (Google)
|
||||||
Matt York (LifeMarks)
|
Matt York (LifeMarks)
|
||||||
mike32767
|
mike32767
|
||||||
mikej06
|
mikej06
|
||||||
|
Mike Kicinski
|
||||||
Mohamad Fairol
|
Mohamad Fairol
|
||||||
Morgan Courbet
|
Morgan Courbet
|
||||||
Nikolaos Ftylitakis
|
Nikolaos Ftylitakis
|
||||||
|
|
|
@ -105,52 +105,30 @@ public final class Code128Writer extends OneDimensionalCodeWriter {
|
||||||
int patternIndex;
|
int patternIndex;
|
||||||
if (newCodeSet == codeSet) {
|
if (newCodeSet == codeSet) {
|
||||||
// Encode the current character
|
// Encode the current character
|
||||||
|
// First handle escapes
|
||||||
|
switch (contents.charAt(position)) {
|
||||||
|
case ESCAPE_FNC_1:
|
||||||
|
patternIndex = CODE_FNC_1;
|
||||||
|
break;
|
||||||
|
case ESCAPE_FNC_2:
|
||||||
|
patternIndex = CODE_FNC_2;
|
||||||
|
break;
|
||||||
|
case ESCAPE_FNC_3:
|
||||||
|
patternIndex = CODE_FNC_3;
|
||||||
|
break;
|
||||||
|
case ESCAPE_FNC_4:
|
||||||
|
patternIndex = CODE_FNC_4_B; // FIXME if this ever outputs Code A
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Then handle normal characters otherwise
|
||||||
if (codeSet == CODE_CODE_B) {
|
if (codeSet == CODE_CODE_B) {
|
||||||
switch (contents.charAt(position)) {
|
|
||||||
case ESCAPE_FNC_1:
|
|
||||||
patternIndex = CODE_FNC_1;
|
|
||||||
position++;
|
|
||||||
break;
|
|
||||||
case ESCAPE_FNC_2:
|
|
||||||
patternIndex = CODE_FNC_2;
|
|
||||||
position++;
|
|
||||||
break;
|
|
||||||
case ESCAPE_FNC_3:
|
|
||||||
patternIndex = CODE_FNC_3;
|
|
||||||
position++;
|
|
||||||
break;
|
|
||||||
case ESCAPE_FNC_4:
|
|
||||||
patternIndex = CODE_FNC_4_B; // FIXME if this ever outputs Code A
|
|
||||||
position++;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
patternIndex = contents.charAt(position) - ' ';
|
patternIndex = contents.charAt(position) - ' ';
|
||||||
position++;
|
|
||||||
}
|
|
||||||
} else { // CODE_CODE_C
|
} else { // CODE_CODE_C
|
||||||
switch (contents.charAt(position)) {
|
|
||||||
case ESCAPE_FNC_1:
|
|
||||||
patternIndex = CODE_FNC_1;
|
|
||||||
position++;
|
|
||||||
break;
|
|
||||||
case ESCAPE_FNC_2:
|
|
||||||
patternIndex = CODE_FNC_2;
|
|
||||||
position++;
|
|
||||||
break;
|
|
||||||
case ESCAPE_FNC_3:
|
|
||||||
patternIndex = CODE_FNC_3;
|
|
||||||
position++;
|
|
||||||
break;
|
|
||||||
case ESCAPE_FNC_4:
|
|
||||||
patternIndex = CODE_FNC_4_B; // FIXME if this ever outputs Code A
|
|
||||||
position++;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
patternIndex = Integer.parseInt(contents.substring(position, position + 2));
|
patternIndex = Integer.parseInt(contents.substring(position, position + 2));
|
||||||
position += 2;
|
position++; // Also incremented below
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
position++;
|
||||||
} else {
|
} else {
|
||||||
// Should we change the current code?
|
// Should we change the current code?
|
||||||
// Do we have a code set?
|
// Do we have a code set?
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2014 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;
|
package com.google.zxing.oned;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
@ -11,6 +27,7 @@ import com.google.zxing.WriterException;
|
||||||
import com.google.zxing.common.BitMatrix;
|
import com.google.zxing.common.BitMatrix;
|
||||||
|
|
||||||
public class Code128WriterTestCase {
|
public class Code128WriterTestCase {
|
||||||
|
|
||||||
private static final String FNC1 = "11110101110";
|
private static final String FNC1 = "11110101110";
|
||||||
private static final String FNC2 = "11110101000";
|
private static final String FNC2 = "11110101000";
|
||||||
private static final String FNC3 = "10111100010";
|
private static final String FNC3 = "10111100010";
|
||||||
|
@ -19,7 +36,7 @@ public class Code128WriterTestCase {
|
||||||
public static final String QUIET_SPACE = "00000";
|
public static final String QUIET_SPACE = "00000";
|
||||||
public static final String STOP = "1100011101011";
|
public static final String STOP = "1100011101011";
|
||||||
|
|
||||||
Writer writer;
|
private Writer writer;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
|
|
Loading…
Reference in a new issue