Refactoring

Rename
Constructor of QrCode class
Not using abbrebiations
pull/90/head
김경진 5 years ago
parent 55dd3c881e
commit 8e33477b74

@ -238,32 +238,32 @@ public final class QrCode {
* error correction level, data codeword bytes, and mask number. * error correction level, data codeword bytes, and mask number.
* <p>This is a low-level API that most users should not use directly. A mid-level * <p>This is a low-level API that most users should not use directly. A mid-level
* API is the {@link #encodeSegments(List,Ecc,int,int,int,boolean)} function.</p> * API is the {@link #encodeSegments(List,Ecc,int,int,int,boolean)} function.</p>
* @param ver the version number to use, which must be in the range 1 to 40 (inclusive) * @param version the version number to use, which must be in the range 1 to 40 (inclusive)
* @param ecl the error correction level to use * @param errorCorrectionLevel the error correction level to use
* @param dataCodewords the bytes representing segments to encode (without ECC) * @param dataCodewords the bytes representing segments to encode (without ECC)
* @param msk the mask pattern to use, which is either &#x2212;1 for automatic choice or from 0 to 7 for fixed choice * @param mask the mask pattern to use, which is either &#x2212;1 for automatic choice or from 0 to 7 for fixed choice
* @throws NullPointerException if the byte array or error correction level is {@code null} * @throws NullPointerException if the byte array or error correction level is {@code null}
* @throws IllegalArgumentException if the version or mask value is out of range, * @throws IllegalArgumentException if the version or mask value is out of range,
* or if the data is the wrong length for the specified version and error correction level * or if the data is the wrong length for the specified version and error correction level
*/ */
public QrCode(int ver, Ecc ecl, byte[] dataCodewords, int msk) { public QrCode(int version, Ecc errorCorrectionLevel, byte[] dataCodewords, int mask) {
// Check arguments and initialize fields // Check arguments and initialize fields
if (ver < MIN_VERSION || ver > MAX_VERSION) if (version < MIN_VERSION || version > MAX_VERSION)
throw new IllegalArgumentException("Version value out of range"); throw new IllegalArgumentException("Version value out of range");
if (msk < -1 || msk > 7) if (mask < -1 || mask > 7)
throw new IllegalArgumentException("Mask value out of range"); throw new IllegalArgumentException("Mask value out of range");
version = ver; this.version = version;
size = ver * 4 + 17; this.size = version * 4 + 17;
errorCorrectionLevel = Objects.requireNonNull(ecl); this.errorCorrectionLevel = Objects.requireNonNull(errorCorrectionLevel);
Objects.requireNonNull(dataCodewords); Objects.requireNonNull(dataCodewords);
modules = new boolean[size][size]; // Initially all white this.modules = new boolean[size][size]; // Initially all white
isFunction = new boolean[size][size]; this.isFunction = new boolean[size][size];
// Compute ECC, draw modules, do masking // Compute ECC, draw modules, do masking
drawFunctionPatterns(); drawFunctionPatterns();
byte[] allCodewords = addEccAndInterleave(dataCodewords); byte[] allCodewords = addEccAndInterleave(dataCodewords);
drawCodewords(allCodewords); drawCodewords(allCodewords);
this.mask = handleConstructorMasking(msk); this.mask = handleConstructorMasking(mask);
isFunction = null; isFunction = null;
} }

Loading…
Cancel
Save