Update zxing-core to 3.2.1
This commit is contained in:
		
							parent
							
								
									3213fd2ba1
								
							
						
					
					
						commit
						45782355db
					
				@ -22,7 +22,7 @@ if ( !hasProperty( 'sourceDeps' ) ) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        compile 'org.thoughtcrime.ssl.pinning:AndroidPinning:1.0.0'
 | 
					        compile 'org.thoughtcrime.ssl.pinning:AndroidPinning:1.0.0'
 | 
				
			||||||
        compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
 | 
					        compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
 | 
				
			||||||
        compile 'com.google.zxing:core:3.2.0'
 | 
					        compile 'com.google.zxing:core:3.2.1'
 | 
				
			||||||
        compile 'eu.chainfire:libsuperuser:1.0.0.201504231659'
 | 
					        compile 'eu.chainfire:libsuperuser:1.0.0.201504231659'
 | 
				
			||||||
        compile 'cc.mvdan.accesspoint:library:0.1.1'
 | 
					        compile 'cc.mvdan.accesspoint:library:0.1.1'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										9
									
								
								extern/zxing-core/.classpath
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								extern/zxing-core/.classpath
									
									
									
									
										vendored
									
									
								
							@ -1,9 +0,0 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
					 | 
				
			||||||
<classpath>
 | 
					 | 
				
			||||||
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
 | 
					 | 
				
			||||||
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
 | 
					 | 
				
			||||||
	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
 | 
					 | 
				
			||||||
	<classpathentry kind="src" path="src/main/java"/>
 | 
					 | 
				
			||||||
	<classpathentry kind="src" path="gen"/>
 | 
					 | 
				
			||||||
	<classpathentry kind="output" path="bin/classes"/>
 | 
					 | 
				
			||||||
</classpath>
 | 
					 | 
				
			||||||
							
								
								
									
										33
									
								
								extern/zxing-core/.project
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										33
									
								
								extern/zxing-core/.project
									
									
									
									
										vendored
									
									
								
							@ -1,33 +0,0 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
					 | 
				
			||||||
<projectDescription>
 | 
					 | 
				
			||||||
	<name>zxing-core</name>
 | 
					 | 
				
			||||||
	<comment></comment>
 | 
					 | 
				
			||||||
	<projects>
 | 
					 | 
				
			||||||
	</projects>
 | 
					 | 
				
			||||||
	<buildSpec>
 | 
					 | 
				
			||||||
		<buildCommand>
 | 
					 | 
				
			||||||
			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
 | 
					 | 
				
			||||||
			<arguments>
 | 
					 | 
				
			||||||
			</arguments>
 | 
					 | 
				
			||||||
		</buildCommand>
 | 
					 | 
				
			||||||
		<buildCommand>
 | 
					 | 
				
			||||||
			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
 | 
					 | 
				
			||||||
			<arguments>
 | 
					 | 
				
			||||||
			</arguments>
 | 
					 | 
				
			||||||
		</buildCommand>
 | 
					 | 
				
			||||||
		<buildCommand>
 | 
					 | 
				
			||||||
			<name>org.eclipse.jdt.core.javabuilder</name>
 | 
					 | 
				
			||||||
			<arguments>
 | 
					 | 
				
			||||||
			</arguments>
 | 
					 | 
				
			||||||
		</buildCommand>
 | 
					 | 
				
			||||||
		<buildCommand>
 | 
					 | 
				
			||||||
			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
 | 
					 | 
				
			||||||
			<arguments>
 | 
					 | 
				
			||||||
			</arguments>
 | 
					 | 
				
			||||||
		</buildCommand>
 | 
					 | 
				
			||||||
	</buildSpec>
 | 
					 | 
				
			||||||
	<natures>
 | 
					 | 
				
			||||||
		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
 | 
					 | 
				
			||||||
		<nature>org.eclipse.jdt.core.javanature</nature>
 | 
					 | 
				
			||||||
	</natures>
 | 
					 | 
				
			||||||
</projectDescription>
 | 
					 | 
				
			||||||
							
								
								
									
										5
									
								
								extern/zxing-core/AndroidManifest.xml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								extern/zxing-core/AndroidManifest.xml
									
									
									
									
										vendored
									
									
								
							@ -1,5 +0,0 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="utf-8"?>
 | 
					 | 
				
			||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 | 
					 | 
				
			||||||
	package="com.google.zxing" >
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
</manifest>
 | 
					 | 
				
			||||||
							
								
								
									
										7
									
								
								extern/zxing-core/project.properties
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								extern/zxing-core/project.properties
									
									
									
									
										vendored
									
									
								
							@ -1,7 +0,0 @@
 | 
				
			|||||||
# Dummy value
 | 
					 | 
				
			||||||
target=android-19
 | 
					 | 
				
			||||||
android.library=true
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
source.dir=src/main/java
 | 
					 | 
				
			||||||
java.target=1.7
 | 
					 | 
				
			||||||
java.source=1.7
 | 
					 | 
				
			||||||
@ -24,7 +24,10 @@ package com.google.zxing;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
public final class ChecksumException extends ReaderException {
 | 
					public final class ChecksumException extends ReaderException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private static final ChecksumException instance = new ChecksumException();
 | 
					  private static final ChecksumException INSTANCE = new ChecksumException();
 | 
				
			||||||
 | 
					  static {
 | 
				
			||||||
 | 
					    INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private ChecksumException() {
 | 
					  private ChecksumException() {
 | 
				
			||||||
    // do nothing
 | 
					    // do nothing
 | 
				
			||||||
@ -35,18 +38,10 @@ public final class ChecksumException extends ReaderException {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public static ChecksumException getChecksumInstance() {
 | 
					  public static ChecksumException getChecksumInstance() {
 | 
				
			||||||
    if (isStackTrace) {
 | 
					    return isStackTrace ? new ChecksumException() : INSTANCE;
 | 
				
			||||||
      return new ChecksumException();
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      return instance;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public static ChecksumException getChecksumInstance(Throwable cause) {
 | 
					  public static ChecksumException getChecksumInstance(Throwable cause) {
 | 
				
			||||||
    if (isStackTrace) {
 | 
					    return isStackTrace ? new ChecksumException(cause) : INSTANCE;
 | 
				
			||||||
      return new ChecksumException(cause);
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      return instance;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -27,7 +27,8 @@ public enum EncodeHintType {
 | 
				
			|||||||
   * Specifies what degree of error correction to use, for example in QR Codes.
 | 
					   * Specifies what degree of error correction to use, for example in QR Codes.
 | 
				
			||||||
   * Type depends on the encoder. For example for QR codes it's type
 | 
					   * Type depends on the encoder. For example for QR codes it's type
 | 
				
			||||||
   * {@link com.google.zxing.qrcode.decoder.ErrorCorrectionLevel ErrorCorrectionLevel}.
 | 
					   * {@link com.google.zxing.qrcode.decoder.ErrorCorrectionLevel ErrorCorrectionLevel}.
 | 
				
			||||||
   * For Aztec it is of type {@link Integer}, representing the minimal percentage of error correction words. 
 | 
					   * For Aztec it is of type {@link Integer}, representing the minimal percentage of error correction words.
 | 
				
			||||||
 | 
					   * For PDF417 it is of type {@link Integer}, valid values being 0 to 8.
 | 
				
			||||||
   * Note: an Aztec symbol should have a minimum of 25% EC words.
 | 
					   * Note: an Aztec symbol should have a minimum of 25% EC words.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  ERROR_CORRECTION,
 | 
					  ERROR_CORRECTION,
 | 
				
			||||||
 | 
				
			|||||||
@ -25,7 +25,10 @@ package com.google.zxing;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
public final class FormatException extends ReaderException {
 | 
					public final class FormatException extends ReaderException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private static final FormatException instance = new FormatException();
 | 
					  private static final FormatException INSTANCE = new FormatException();
 | 
				
			||||||
 | 
					  static {
 | 
				
			||||||
 | 
					    INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private FormatException() {
 | 
					  private FormatException() {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -35,18 +38,10 @@ public final class FormatException extends ReaderException {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public static FormatException getFormatInstance() {
 | 
					  public static FormatException getFormatInstance() {
 | 
				
			||||||
    if (isStackTrace) {
 | 
					    return isStackTrace ? new FormatException() : INSTANCE;
 | 
				
			||||||
      return new FormatException();
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      return instance;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  public static FormatException getFormatInstance(Throwable cause) {
 | 
					  public static FormatException getFormatInstance(Throwable cause) {
 | 
				
			||||||
    if (isStackTrace) {
 | 
					    return isStackTrace ? new FormatException(cause) : INSTANCE;
 | 
				
			||||||
      return new FormatException(cause);
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      return instance;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -24,14 +24,17 @@ package com.google.zxing;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
public final class NotFoundException extends ReaderException {
 | 
					public final class NotFoundException extends ReaderException {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private static final NotFoundException instance = new NotFoundException();
 | 
					  private static final NotFoundException INSTANCE = new NotFoundException();
 | 
				
			||||||
 | 
					  static {
 | 
				
			||||||
 | 
					    INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private NotFoundException() {
 | 
					  private NotFoundException() {
 | 
				
			||||||
    // do nothing
 | 
					    // do nothing
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public static NotFoundException getNotFoundInstance() {
 | 
					  public static NotFoundException getNotFoundInstance() {
 | 
				
			||||||
    return instance;
 | 
					    return INSTANCE;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -26,7 +26,9 @@ package com.google.zxing;
 | 
				
			|||||||
public abstract class ReaderException extends Exception {
 | 
					public abstract class ReaderException extends Exception {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // disable stack traces when not running inside test units
 | 
					  // disable stack traces when not running inside test units
 | 
				
			||||||
  protected static final boolean isStackTrace = System.getProperty("surefire.test.class.path") != null;
 | 
					  protected static final boolean isStackTrace =
 | 
				
			||||||
 | 
					      System.getProperty("surefire.test.class.path") != null;
 | 
				
			||||||
 | 
					  protected static final StackTraceElement[] NO_TRACE = new StackTraceElement[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ReaderException() {
 | 
					  ReaderException() {
 | 
				
			||||||
    // do nothing
 | 
					    // do nothing
 | 
				
			||||||
 | 
				
			|||||||
@ -311,7 +311,7 @@ public final class Encoder {
 | 
				
			|||||||
      case 12:
 | 
					      case 12:
 | 
				
			||||||
        return GenericGF.AZTEC_DATA_12;
 | 
					        return GenericGF.AZTEC_DATA_12;
 | 
				
			||||||
      default:
 | 
					      default:
 | 
				
			||||||
        return null;
 | 
					        throw new IllegalArgumentException("Unsupported word size " + wordSize);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -230,15 +230,15 @@ public final class HighLevelEncoder {
 | 
				
			|||||||
          // any other mode except possibly digit (which uses only 4 bits).  Any
 | 
					          // any other mode except possibly digit (which uses only 4 bits).  Any
 | 
				
			||||||
          // other latch would be equally successful *after* this character, and
 | 
					          // other latch would be equally successful *after* this character, and
 | 
				
			||||||
          // so wouldn't save any bits.
 | 
					          // so wouldn't save any bits.
 | 
				
			||||||
          State latch_state = stateNoBinary.latchAndAppend(mode, charInMode);
 | 
					          State latchState = stateNoBinary.latchAndAppend(mode, charInMode);
 | 
				
			||||||
          result.add(latch_state);
 | 
					          result.add(latchState);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // Try generating the character by switching to its mode.
 | 
					        // Try generating the character by switching to its mode.
 | 
				
			||||||
        if (!charInCurrentTable && SHIFT_TABLE[state.getMode()][mode] >= 0) {
 | 
					        if (!charInCurrentTable && SHIFT_TABLE[state.getMode()][mode] >= 0) {
 | 
				
			||||||
          // It never makes sense to temporarily shift to another mode if the
 | 
					          // It never makes sense to temporarily shift to another mode if the
 | 
				
			||||||
          // character exists in the current mode.  That can never save bits.
 | 
					          // character exists in the current mode.  That can never save bits.
 | 
				
			||||||
          State shift_state = stateNoBinary.shiftAndAppend(mode, charInMode);
 | 
					          State shiftState = stateNoBinary.shiftAndAppend(mode, charInMode);
 | 
				
			||||||
          result.add(shift_state);
 | 
					          result.add(shiftState);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -270,10 +270,10 @@ public final class HighLevelEncoder {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    if (pairCode == 3 || pairCode == 4) {
 | 
					    if (pairCode == 3 || pairCode == 4) {
 | 
				
			||||||
      // both characters are in DIGITS.  Sometimes better to just add two digits
 | 
					      // both characters are in DIGITS.  Sometimes better to just add two digits
 | 
				
			||||||
      State digit_state = stateNoBinary
 | 
					      State digitState = stateNoBinary
 | 
				
			||||||
          .latchAndAppend(MODE_DIGIT, 16 - pairCode)  // period or comma in DIGIT
 | 
					          .latchAndAppend(MODE_DIGIT, 16 - pairCode)  // period or comma in DIGIT
 | 
				
			||||||
          .latchAndAppend(MODE_DIGIT, 1);             // space in DIGIT
 | 
					          .latchAndAppend(MODE_DIGIT, 1);             // space in DIGIT
 | 
				
			||||||
      result.add(digit_state);
 | 
					      result.add(digitState);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (state.getBinaryShiftByteCount() > 0) {
 | 
					    if (state.getBinaryShiftByteCount() > 0) {
 | 
				
			||||||
      // It only makes sense to do the characters as binary if we're already
 | 
					      // It only makes sense to do the characters as binary if we're already
 | 
				
			||||||
@ -287,7 +287,7 @@ public final class HighLevelEncoder {
 | 
				
			|||||||
    List<State> result = new LinkedList<>();
 | 
					    List<State> result = new LinkedList<>();
 | 
				
			||||||
    for (State newState : states) {
 | 
					    for (State newState : states) {
 | 
				
			||||||
      boolean add = true;
 | 
					      boolean add = true;
 | 
				
			||||||
      for (Iterator<State> iterator = result.iterator(); iterator.hasNext(); ) {
 | 
					      for (Iterator<State> iterator = result.iterator(); iterator.hasNext();) {
 | 
				
			||||||
        State oldState = iterator.next();
 | 
					        State oldState = iterator.next();
 | 
				
			||||||
        if (oldState.isBetterThanOrEqualTo(newState)) {
 | 
					        if (oldState.isBetterThanOrEqualTo(newState)) {
 | 
				
			||||||
          add = false;
 | 
					          add = false;
 | 
				
			||||||
 | 
				
			|||||||
@ -69,11 +69,9 @@ public final class URIParsedResult extends ParsedResult {
 | 
				
			|||||||
  private static String massageURI(String uri) {
 | 
					  private static String massageURI(String uri) {
 | 
				
			||||||
    uri = uri.trim();
 | 
					    uri = uri.trim();
 | 
				
			||||||
    int protocolEnd = uri.indexOf(':');
 | 
					    int protocolEnd = uri.indexOf(':');
 | 
				
			||||||
    if (protocolEnd < 0) {
 | 
					    if (protocolEnd < 0 || isColonFollowedByPortNumber(uri, protocolEnd)) {
 | 
				
			||||||
      // No protocol, assume http
 | 
					      // No protocol, or found a colon, but it looks like it is after the host, so the protocol is still missing,
 | 
				
			||||||
      uri = "http://" + uri;
 | 
					      // so assume http
 | 
				
			||||||
    } else if (isColonFollowedByPortNumber(uri, protocolEnd)) {
 | 
					 | 
				
			||||||
      // Found a colon, but it looks like it is after the host, so the protocol is still missing
 | 
					 | 
				
			||||||
      uri = "http://" + uri;
 | 
					      uri = "http://" + uri;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return uri;
 | 
					    return uri;
 | 
				
			||||||
 | 
				
			|||||||
@ -77,23 +77,20 @@ public final class BitMatrix implements Cloneable {
 | 
				
			|||||||
      if (stringRepresentation.charAt(pos) == '\n' ||
 | 
					      if (stringRepresentation.charAt(pos) == '\n' ||
 | 
				
			||||||
          stringRepresentation.charAt(pos) == '\r') {
 | 
					          stringRepresentation.charAt(pos) == '\r') {
 | 
				
			||||||
        if (bitsPos > rowStartPos) {
 | 
					        if (bitsPos > rowStartPos) {
 | 
				
			||||||
          if(rowLength == -1) {
 | 
					          if (rowLength == -1) {
 | 
				
			||||||
            rowLength = bitsPos - rowStartPos;
 | 
					            rowLength = bitsPos - rowStartPos;
 | 
				
			||||||
          }
 | 
					          } else if (bitsPos - rowStartPos != rowLength) {
 | 
				
			||||||
          else if (bitsPos - rowStartPos != rowLength) {
 | 
					 | 
				
			||||||
            throw new IllegalArgumentException("row lengths do not match");
 | 
					            throw new IllegalArgumentException("row lengths do not match");
 | 
				
			||||||
          }
 | 
					          }
 | 
				
			||||||
          rowStartPos = bitsPos;
 | 
					          rowStartPos = bitsPos;
 | 
				
			||||||
          nRows++;
 | 
					          nRows++;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        pos++;
 | 
					        pos++;
 | 
				
			||||||
      }
 | 
					      }  else if (stringRepresentation.substring(pos, pos + setString.length()).equals(setString)) {
 | 
				
			||||||
      else if (stringRepresentation.substring(pos, pos + setString.length()).equals(setString)) {
 | 
					 | 
				
			||||||
        pos += setString.length();
 | 
					        pos += setString.length();
 | 
				
			||||||
        bits[bitsPos] = true;
 | 
					        bits[bitsPos] = true;
 | 
				
			||||||
        bitsPos++;
 | 
					        bitsPos++;
 | 
				
			||||||
      }
 | 
					      } else if (stringRepresentation.substring(pos, pos + unsetString.length()).equals(unsetString)) {
 | 
				
			||||||
      else if (stringRepresentation.substring(pos, pos + unsetString.length()).equals(unsetString)) {
 | 
					 | 
				
			||||||
        pos += unsetString.length();
 | 
					        pos += unsetString.length();
 | 
				
			||||||
        bits[bitsPos] = false;
 | 
					        bits[bitsPos] = false;
 | 
				
			||||||
        bitsPos++;
 | 
					        bitsPos++;
 | 
				
			||||||
@ -408,16 +405,28 @@ public final class BitMatrix implements Cloneable {
 | 
				
			|||||||
    return hash;
 | 
					    return hash;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * @return string representation using "X" for set and " " for unset bits
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
  @Override
 | 
					  @Override
 | 
				
			||||||
  public String toString() {
 | 
					  public String toString() {
 | 
				
			||||||
    return toString("X ", "  ");
 | 
					    return toString("X ", "  ");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * @param setString representation of a set bit
 | 
				
			||||||
 | 
					   * @param unsetString representation of an unset bit
 | 
				
			||||||
 | 
					   * @return string representation of entire matrix utilizing given strings
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
  public String toString(String setString, String unsetString) {
 | 
					  public String toString(String setString, String unsetString) {
 | 
				
			||||||
    return toString(setString, unsetString, "\n");
 | 
					    return toString(setString, unsetString, "\n");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
 | 
					   * @param setString representation of a set bit
 | 
				
			||||||
 | 
					   * @param unsetString representation of an unset bit
 | 
				
			||||||
 | 
					   * @param lineSeparator newline character in string representation
 | 
				
			||||||
 | 
					   * @return string representation of entire matrix utilizing given strings and line separator
 | 
				
			||||||
   * @deprecated call {@link #toString(String,String)} only, which uses \n line separator always
 | 
					   * @deprecated call {@link #toString(String,String)} only, which uses \n line separator always
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  @Deprecated
 | 
					  @Deprecated
 | 
				
			||||||
 | 
				
			|||||||
@ -60,7 +60,7 @@ public final class DataMatrixWriter implements Writer {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Try to get force shape & min / max size
 | 
					    // Try to get force shape & min / max size
 | 
				
			||||||
    SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
 | 
					    SymbolShapeHint shape = SymbolShapeHint.FORCE_NONE;
 | 
				
			||||||
    Dimension minSize = new Dimension(width, height);
 | 
					    Dimension minSize = null;
 | 
				
			||||||
    Dimension maxSize = null;
 | 
					    Dimension maxSize = null;
 | 
				
			||||||
    if (hints != null) {
 | 
					    if (hints != null) {
 | 
				
			||||||
      SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
 | 
					      SymbolShapeHint requestedShape = (SymbolShapeHint) hints.get(EncodeHintType.DATA_MATRIX_SHAPE);
 | 
				
			||||||
 | 
				
			|||||||
@ -223,11 +223,21 @@ public final class Code93Reader extends OneDReader {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
          case 'b':
 | 
					          case 'b':
 | 
				
			||||||
            // %A to %E map to control codes ESC to US
 | 
					 | 
				
			||||||
            if (next >= 'A' && next <= 'E') {
 | 
					            if (next >= 'A' && next <= 'E') {
 | 
				
			||||||
 | 
					              // %A to %E map to control codes ESC to USep
 | 
				
			||||||
              decodedChar = (char) (next - 38);
 | 
					              decodedChar = (char) (next - 38);
 | 
				
			||||||
            } else if (next >= 'F' && next <= 'W') {
 | 
					            } else if (next >= 'F' && next <= 'J') {
 | 
				
			||||||
 | 
					              // %F to %J map to ; < = > ?
 | 
				
			||||||
              decodedChar = (char) (next - 11);
 | 
					              decodedChar = (char) (next - 11);
 | 
				
			||||||
 | 
					            } else if (next >= 'K' && next <= 'O') {
 | 
				
			||||||
 | 
					              // %K to %O map to [ \ ] ^ _
 | 
				
			||||||
 | 
					              decodedChar = (char) (next + 16);
 | 
				
			||||||
 | 
					            } else if (next >= 'P' && next <= 'S') {
 | 
				
			||||||
 | 
					              // %P to %S map to { | } ~
 | 
				
			||||||
 | 
					              decodedChar = (char) (next + 43);
 | 
				
			||||||
 | 
					            } else if (next >= 'T' && next <= 'Z') {
 | 
				
			||||||
 | 
					              // %T to %Z all map to DEL (127)
 | 
				
			||||||
 | 
					              decodedChar = 127;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
              throw FormatException.getFormatInstance();
 | 
					              throw FormatException.getFormatInstance();
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
@ -294,9 +294,6 @@ public final class ITFReader extends OneDReader {
 | 
				
			|||||||
  private static int[] findGuardPattern(BitArray row,
 | 
					  private static int[] findGuardPattern(BitArray row,
 | 
				
			||||||
                                        int rowOffset,
 | 
					                                        int rowOffset,
 | 
				
			||||||
                                        int[] pattern) throws NotFoundException {
 | 
					                                        int[] pattern) throws NotFoundException {
 | 
				
			||||||
 | 
					 | 
				
			||||||
    // TODO: This is very similar to implementation in UPCEANReader. Consider if they can be
 | 
					 | 
				
			||||||
    // merged to a single method.
 | 
					 | 
				
			||||||
    int patternLength = pattern.length;
 | 
					    int patternLength = pattern.length;
 | 
				
			||||||
    int[] counters = new int[patternLength];
 | 
					    int[] counters = new int[patternLength];
 | 
				
			||||||
    int width = row.getSize();
 | 
					    int width = row.getSize();
 | 
				
			||||||
 | 
				
			|||||||
@ -110,15 +110,12 @@ public final class RSSExpandedReader extends AbstractRSSReader {
 | 
				
			|||||||
    { 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 },
 | 
					    { 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 },
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //private static final int LONGEST_SEQUENCE_SIZE = FINDER_PATTERN_SEQUENCES[FINDER_PATTERN_SEQUENCES.length - 1].length;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  private static final int MAX_PAIRS = 11;
 | 
					  private static final int MAX_PAIRS = 11;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private final List<ExpandedPair> pairs = new ArrayList<>(MAX_PAIRS);
 | 
					  private final List<ExpandedPair> pairs = new ArrayList<>(MAX_PAIRS);
 | 
				
			||||||
  private final List<ExpandedRow> rows = new ArrayList<>();
 | 
					  private final List<ExpandedRow> rows = new ArrayList<>();
 | 
				
			||||||
  private final int [] startEnd = new int[2];
 | 
					  private final int [] startEnd = new int[2];
 | 
				
			||||||
  //private final int [] currentSequence = new int[LONGEST_SEQUENCE_SIZE];
 | 
					  private boolean startFromEven;
 | 
				
			||||||
  private boolean startFromEven = false;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Override
 | 
					  @Override
 | 
				
			||||||
  public Result decodeRow(int rowNumber,
 | 
					  public Result decodeRow(int rowNumber,
 | 
				
			||||||
@ -153,7 +150,6 @@ public final class RSSExpandedReader extends AbstractRSSReader {
 | 
				
			|||||||
      while (true){
 | 
					      while (true){
 | 
				
			||||||
        ExpandedPair nextPair = retrieveNextPair(row, this.pairs, rowNumber);
 | 
					        ExpandedPair nextPair = retrieveNextPair(row, this.pairs, rowNumber);
 | 
				
			||||||
        this.pairs.add(nextPair);
 | 
					        this.pairs.add(nextPair);
 | 
				
			||||||
        //System.out.println(this.pairs.size()+" pairs found so far on row "+rowNumber+": "+this.pairs);
 | 
					 | 
				
			||||||
        // exit this loop when retrieveNextPair() fails and throws
 | 
					        // exit this loop when retrieveNextPair() fails and throws
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } catch (NotFoundException nfe) {
 | 
					    } catch (NotFoundException nfe) {
 | 
				
			||||||
@ -171,7 +167,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
 | 
				
			|||||||
    boolean wasReversed = false; // TODO: deal with reversed rows
 | 
					    boolean wasReversed = false; // TODO: deal with reversed rows
 | 
				
			||||||
    storeRow(rowNumber, wasReversed);
 | 
					    storeRow(rowNumber, wasReversed);
 | 
				
			||||||
    if (tryStackedDecode) {
 | 
					    if (tryStackedDecode) {
 | 
				
			||||||
      // When the image is 180-rotated, then rows are sorted in wrong dirrection.
 | 
					      // When the image is 180-rotated, then rows are sorted in wrong direction.
 | 
				
			||||||
      // Try twice with both the directions.
 | 
					      // Try twice with both the directions.
 | 
				
			||||||
      List<ExpandedPair> ps = checkRows(false);
 | 
					      List<ExpandedPair> ps = checkRows(false);
 | 
				
			||||||
      if (ps != null) {
 | 
					      if (ps != null) {
 | 
				
			||||||
@ -189,7 +185,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
 | 
				
			|||||||
  private List<ExpandedPair> checkRows(boolean reverse) {
 | 
					  private List<ExpandedPair> checkRows(boolean reverse) {
 | 
				
			||||||
    // Limit number of rows we are checking
 | 
					    // Limit number of rows we are checking
 | 
				
			||||||
    // We use recursive algorithm with pure complexity and don't want it to take forever
 | 
					    // We use recursive algorithm with pure complexity and don't want it to take forever
 | 
				
			||||||
    // Stacked barcode can have up to 11 rows, so 25 seems resonable enough
 | 
					    // Stacked barcode can have up to 11 rows, so 25 seems reasonable enough
 | 
				
			||||||
    if (this.rows.size() > 25) {
 | 
					    if (this.rows.size() > 25) {
 | 
				
			||||||
      this.rows.clear();  // We will never have a chance to get result, so clear it
 | 
					      this.rows.clear();  // We will never have a chance to get result, so clear it
 | 
				
			||||||
      return null;
 | 
					      return null;
 | 
				
			||||||
@ -306,7 +302,7 @@ public final class RSSExpandedReader extends AbstractRSSReader {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  // Remove all the rows that contains only specified pairs 
 | 
					  // Remove all the rows that contains only specified pairs 
 | 
				
			||||||
  private static void removePartialRows(List<ExpandedPair> pairs, List<ExpandedRow> rows) {
 | 
					  private static void removePartialRows(List<ExpandedPair> pairs, List<ExpandedRow> rows) {
 | 
				
			||||||
    for (Iterator<ExpandedRow> iterator = rows.iterator(); iterator.hasNext(); ) {
 | 
					    for (Iterator<ExpandedRow> iterator = rows.iterator(); iterator.hasNext();) {
 | 
				
			||||||
      ExpandedRow r = iterator.next();
 | 
					      ExpandedRow r = iterator.next();
 | 
				
			||||||
      if (r.getPairs().size() == pairs.size()) {
 | 
					      if (r.getPairs().size() == pairs.size()) {
 | 
				
			||||||
        continue;
 | 
					        continue;
 | 
				
			||||||
 | 
				
			|||||||
@ -39,6 +39,11 @@ public final class PDF417Writer implements Writer {
 | 
				
			|||||||
   */
 | 
					   */
 | 
				
			||||||
  static final int WHITE_SPACE = 30;
 | 
					  static final int WHITE_SPACE = 30;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * default error correction level
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  static final int DEFAULT_ERROR_CORRECTION_LEVEL = 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Override
 | 
					  @Override
 | 
				
			||||||
  public BitMatrix encode(String contents,
 | 
					  public BitMatrix encode(String contents,
 | 
				
			||||||
                          BarcodeFormat format,
 | 
					                          BarcodeFormat format,
 | 
				
			||||||
@ -51,6 +56,7 @@ public final class PDF417Writer implements Writer {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    PDF417 encoder = new PDF417();
 | 
					    PDF417 encoder = new PDF417();
 | 
				
			||||||
    int margin = WHITE_SPACE;
 | 
					    int margin = WHITE_SPACE;
 | 
				
			||||||
 | 
					    int errorCorrectionLevel = DEFAULT_ERROR_CORRECTION_LEVEL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (hints != null) {
 | 
					    if (hints != null) {
 | 
				
			||||||
      if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
 | 
					      if (hints.containsKey(EncodeHintType.PDF417_COMPACT)) {
 | 
				
			||||||
@ -69,13 +75,16 @@ public final class PDF417Writer implements Writer {
 | 
				
			|||||||
      if (hints.containsKey(EncodeHintType.MARGIN)) {
 | 
					      if (hints.containsKey(EncodeHintType.MARGIN)) {
 | 
				
			||||||
        margin = ((Number) hints.get(EncodeHintType.MARGIN)).intValue();
 | 
					        margin = ((Number) hints.get(EncodeHintType.MARGIN)).intValue();
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					      if (hints.containsKey(EncodeHintType.ERROR_CORRECTION)) {
 | 
				
			||||||
 | 
					        errorCorrectionLevel = ((Number) hints.get(EncodeHintType.ERROR_CORRECTION)).intValue();
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
      if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
 | 
					      if (hints.containsKey(EncodeHintType.CHARACTER_SET)) {
 | 
				
			||||||
        String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
 | 
					        String encoding = (String) hints.get(EncodeHintType.CHARACTER_SET);
 | 
				
			||||||
        encoder.setEncoding(Charset.forName(encoding));
 | 
					        encoder.setEncoding(Charset.forName(encoding));
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return bitMatrixFromEncoder(encoder, contents, width, height, margin);
 | 
					    return bitMatrixFromEncoder(encoder, contents, errorCorrectionLevel, width, height, margin);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @Override
 | 
					  @Override
 | 
				
			||||||
@ -91,15 +100,14 @@ public final class PDF417Writer implements Writer {
 | 
				
			|||||||
   */
 | 
					   */
 | 
				
			||||||
  private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
 | 
					  private static BitMatrix bitMatrixFromEncoder(PDF417 encoder,
 | 
				
			||||||
                                                String contents,
 | 
					                                                String contents,
 | 
				
			||||||
 | 
					                                                int errorCorrectionLevel,
 | 
				
			||||||
                                                int width,
 | 
					                                                int width,
 | 
				
			||||||
                                                int height,
 | 
					                                                int height,
 | 
				
			||||||
                                                int margin) throws WriterException {
 | 
					                                                int margin) throws WriterException {
 | 
				
			||||||
    int errorCorrectionLevel = 2;
 | 
					 | 
				
			||||||
    encoder.generateBarcodeLogic(contents, errorCorrectionLevel);
 | 
					    encoder.generateBarcodeLogic(contents, errorCorrectionLevel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int lineThickness = 2;
 | 
					 | 
				
			||||||
    int aspectRatio = 4;
 | 
					    int aspectRatio = 4;
 | 
				
			||||||
    byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(lineThickness, aspectRatio * lineThickness);
 | 
					    byte[][] originalScale = encoder.getBarcodeMatrix().getScaledMatrix(1, aspectRatio);
 | 
				
			||||||
    boolean rotated = false;
 | 
					    boolean rotated = false;
 | 
				
			||||||
    if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
 | 
					    if ((height > width) ^ (originalScale[0].length < originalScale.length)) {
 | 
				
			||||||
      originalScale = rotateArray(originalScale);
 | 
					      originalScale = rotateArray(originalScale);
 | 
				
			||||||
@ -118,7 +126,7 @@ public final class PDF417Writer implements Writer {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if (scale > 1) {
 | 
					    if (scale > 1) {
 | 
				
			||||||
      byte[][] scaledMatrix =
 | 
					      byte[][] scaledMatrix =
 | 
				
			||||||
          encoder.getBarcodeMatrix().getScaledMatrix(scale * lineThickness, scale * aspectRatio * lineThickness);
 | 
					          encoder.getBarcodeMatrix().getScaledMatrix(scale, scale * aspectRatio);
 | 
				
			||||||
      if (rotated) {
 | 
					      if (rotated) {
 | 
				
			||||||
        scaledMatrix = rotateArray(scaledMatrix);
 | 
					        scaledMatrix = rotateArray(scaledMatrix);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
@ -88,7 +88,6 @@ final class BoundingBox {
 | 
				
			|||||||
      if (newMinY < 0) {
 | 
					      if (newMinY < 0) {
 | 
				
			||||||
        newMinY = 0;
 | 
					        newMinY = 0;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      // TODO use existing points to better interpolate the new x positions
 | 
					 | 
				
			||||||
      ResultPoint newTop = new ResultPoint(top.getX(), newMinY);
 | 
					      ResultPoint newTop = new ResultPoint(top.getX(), newMinY);
 | 
				
			||||||
      if (isLeft) {
 | 
					      if (isLeft) {
 | 
				
			||||||
        newTopLeft = newTop;
 | 
					        newTopLeft = newTop;
 | 
				
			||||||
@ -103,7 +102,6 @@ final class BoundingBox {
 | 
				
			|||||||
      if (newMaxY >= image.getHeight()) {
 | 
					      if (newMaxY >= image.getHeight()) {
 | 
				
			||||||
        newMaxY = image.getHeight() - 1;
 | 
					        newMaxY = image.getHeight() - 1;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      // TODO use existing points to better interpolate the new x positions
 | 
					 | 
				
			||||||
      ResultPoint newBottom = new ResultPoint(bottom.getX(), newMaxY);
 | 
					      ResultPoint newBottom = new ResultPoint(bottom.getX(), newMaxY);
 | 
				
			||||||
      if (isLeft) {
 | 
					      if (isLeft) {
 | 
				
			||||||
        newBottomLeft = newBottom;
 | 
					        newBottomLeft = newBottom;
 | 
				
			||||||
 | 
				
			|||||||
@ -25,6 +25,7 @@ import com.google.zxing.common.CharacterSetECI;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import java.math.BigInteger;
 | 
					import java.math.BigInteger;
 | 
				
			||||||
import java.nio.charset.Charset;
 | 
					import java.nio.charset.Charset;
 | 
				
			||||||
 | 
					import java.nio.charset.CharsetEncoder;
 | 
				
			||||||
import java.util.Arrays;
 | 
					import java.util.Arrays;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@ -178,12 +179,11 @@ final class PDF417HighLevelEncoder {
 | 
				
			|||||||
    int textSubMode = SUBMODE_ALPHA;
 | 
					    int textSubMode = SUBMODE_ALPHA;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // User selected encoding mode
 | 
					    // User selected encoding mode
 | 
				
			||||||
    byte[] bytes = null; //Fill later and only if needed
 | 
					 | 
				
			||||||
    if (compaction == Compaction.TEXT) {
 | 
					    if (compaction == Compaction.TEXT) {
 | 
				
			||||||
      encodeText(msg, p, len, sb, textSubMode);
 | 
					      encodeText(msg, p, len, sb, textSubMode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    } else if (compaction == Compaction.BYTE) {
 | 
					    } else if (compaction == Compaction.BYTE) {
 | 
				
			||||||
      bytes = msg.getBytes(encoding);
 | 
					      byte[] bytes = msg.getBytes(encoding);
 | 
				
			||||||
      encodeBinary(bytes, p, bytes.length, BYTE_COMPACTION, sb);
 | 
					      encodeBinary(bytes, p, bytes.length, BYTE_COMPACTION, sb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    } else if (compaction == Compaction.NUMERIC) {
 | 
					    } else if (compaction == Compaction.NUMERIC) {
 | 
				
			||||||
@ -211,19 +211,17 @@ final class PDF417HighLevelEncoder {
 | 
				
			|||||||
            textSubMode = encodeText(msg, p, t, sb, textSubMode);
 | 
					            textSubMode = encodeText(msg, p, t, sb, textSubMode);
 | 
				
			||||||
            p += t;
 | 
					            p += t;
 | 
				
			||||||
          } else {
 | 
					          } else {
 | 
				
			||||||
            if (bytes == null) {
 | 
					            int b = determineConsecutiveBinaryCount(msg, p, encoding);
 | 
				
			||||||
              bytes = msg.getBytes(encoding);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            int b = determineConsecutiveBinaryCount(msg, bytes, p);
 | 
					 | 
				
			||||||
            if (b == 0) {
 | 
					            if (b == 0) {
 | 
				
			||||||
              b = 1;
 | 
					              b = 1;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if (b == 1 && encodingMode == TEXT_COMPACTION) {
 | 
					            byte[] bytes = msg.substring(p, p + b).getBytes(encoding);
 | 
				
			||||||
 | 
					            if (bytes.length == 1 && encodingMode == TEXT_COMPACTION) {
 | 
				
			||||||
              //Switch for one byte (instead of latch)
 | 
					              //Switch for one byte (instead of latch)
 | 
				
			||||||
              encodeBinary(bytes, p, 1, TEXT_COMPACTION, sb);
 | 
					              encodeBinary(bytes, 0, 1, TEXT_COMPACTION, sb);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
              //Mode latch performed by encodeBinary()
 | 
					              //Mode latch performed by encodeBinary()
 | 
				
			||||||
              encodeBinary(bytes, p, b, encodingMode, sb);
 | 
					              encodeBinary(bytes, 0, bytes.length, encodingMode, sb);
 | 
				
			||||||
              encodingMode = BYTE_COMPACTION;
 | 
					              encodingMode = BYTE_COMPACTION;
 | 
				
			||||||
              textSubMode = SUBMODE_ALPHA; //Reset after latch
 | 
					              textSubMode = SUBMODE_ALPHA; //Reset after latch
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -530,12 +528,13 @@ final class PDF417HighLevelEncoder {
 | 
				
			|||||||
   * Determines the number of consecutive characters that are encodable using binary compaction.
 | 
					   * Determines the number of consecutive characters that are encodable using binary compaction.
 | 
				
			||||||
   *
 | 
					   *
 | 
				
			||||||
   * @param msg      the message
 | 
					   * @param msg      the message
 | 
				
			||||||
   * @param bytes    the message converted to a byte array
 | 
					 | 
				
			||||||
   * @param startpos the start position within the message
 | 
					   * @param startpos the start position within the message
 | 
				
			||||||
 | 
					   * @param encoding the charset used to convert the message to a byte array
 | 
				
			||||||
   * @return the requested character count
 | 
					   * @return the requested character count
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  private static int determineConsecutiveBinaryCount(CharSequence msg, byte[] bytes, int startpos)
 | 
					  private static int determineConsecutiveBinaryCount(String msg, int startpos, Charset encoding)
 | 
				
			||||||
      throws WriterException {
 | 
					      throws WriterException {
 | 
				
			||||||
 | 
					    final CharsetEncoder encoder = encoding.newEncoder();
 | 
				
			||||||
    int len = msg.length();
 | 
					    int len = msg.length();
 | 
				
			||||||
    int idx = startpos;
 | 
					    int idx = startpos;
 | 
				
			||||||
    while (idx < len) {
 | 
					    while (idx < len) {
 | 
				
			||||||
@ -556,10 +555,7 @@ final class PDF417HighLevelEncoder {
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
      ch = msg.charAt(idx);
 | 
					      ch = msg.charAt(idx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      //Check if character is encodable
 | 
					      if (!encoder.canEncode(ch)) {
 | 
				
			||||||
      //Sun returns a ASCII 63 (?) for a character that cannot be mapped. Let's hope all
 | 
					 | 
				
			||||||
      //other VMs do the same
 | 
					 | 
				
			||||||
      if (bytes[idx] == 63 && ch != '?') {
 | 
					 | 
				
			||||||
        throw new WriterException("Non-encodable character detected: " + ch + " (Unicode: " + (int) ch + ')');
 | 
					        throw new WriterException("Non-encodable character detected: " + ch + " (Unicode: " + (int) ch + ')');
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      idx++;
 | 
					      idx++;
 | 
				
			||||||
 | 
				
			|||||||
@ -261,7 +261,7 @@ public class Detector {
 | 
				
			|||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of
 | 
					   * See {@link #sizeOfBlackWhiteBlackRun(int, int, int, int)}; computes the total width of
 | 
				
			||||||
   * a finder pattern by looking for a black-white-black run from the center in the direction
 | 
					   * a finder pattern by looking for a black-white-black run from the center in the direction
 | 
				
			||||||
   * of another point (another finder pattern center), and in the opposite direction too.</p>
 | 
					   * of another point (another finder pattern center), and in the opposite direction too.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  private float sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, int toY) {
 | 
					  private float sizeOfBlackWhiteBlackRunBothWays(int fromX, int fromY, int toX, int toY) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user