Moved ByteArray up to core/common now that it has no dependencies on qrcode/encoder.
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 18 Nov 2008 23:01:42 +0000 (23:01 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Tue, 18 Nov 2008 23:01:42 +0000 (23:01 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@727 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/common/ByteArray.java [new file with mode: 0644]
core/src/com/google/zxing/qrcode/QRCodeWriter.java
core/src/com/google/zxing/qrcode/encoder/ByteArray.java [deleted file]
core/src/com/google/zxing/qrcode/encoder/Encoder.java
core/test/src/com/google/zxing/qrcode/encoder/EncoderTestCase.java

diff --git a/core/src/com/google/zxing/common/ByteArray.java b/core/src/com/google/zxing/common/ByteArray.java
new file mode 100644 (file)
index 0000000..ffcc472
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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.common;
+
+/**
+ * This class implements an array of unsigned bytes.
+ *
+ * @author dswitkin@google.com (Daniel Switkin)
+ */
+public final class ByteArray {
+
+  private static final int INITIAL_SIZE = 32;
+
+  private byte[] bytes;
+  private int size;
+
+  public ByteArray() {
+    bytes = null;
+    size = 0;
+  }
+
+  public ByteArray(int size) {
+    bytes = new byte[size];
+    this.size = size;
+  }
+
+  public ByteArray(String string) {
+    bytes = string.getBytes();
+    size = bytes.length;
+  }
+
+  public ByteArray(byte[] byteArray) {
+    bytes = byteArray;
+    size = bytes.length;
+  }
+
+  /**
+   * Access an unsigned byte at location index.
+   * @param index The index in the array to access.
+   * @return The unsigned value of the byte as an int.
+   */
+  public int at(int index) {
+    return bytes[index] & 0xff;
+  }
+
+  public void set(int index, int value) {
+    bytes[index] = (byte) value;
+  }
+
+  public int size() {
+    return size;
+  }
+
+  public boolean empty() {
+    return size == 0;
+  }
+
+  public void appendByte(int value) {
+    if (size == 0 || size >= bytes.length) {
+      int newSize = Math.max(INITIAL_SIZE, size * 2);
+      reserve(newSize);
+    }
+    bytes[size] = (byte) value;
+    size++;
+  }
+
+  public void reserve(int capacity) {
+    if (bytes == null || bytes.length < capacity) {
+      byte[] newArray = new byte[capacity];
+      if (bytes != null) {
+        System.arraycopy(bytes, 0, newArray, 0, bytes.length);
+      }
+      bytes = newArray;
+    }
+  }
+
+  // Copy count bytes from array source starting at offset.
+  public void set(byte[] source, int offset, int count) {
+    bytes = new byte[count];
+    size = count;
+    for (int x = 0; x < count; x++) {
+      bytes[x] = source[offset + x];
+    }
+  }
+
+}
index 4c5c6e2..d725813 100644 (file)
@@ -20,7 +20,7 @@ import com.google.zxing.BarcodeFormat;
 import com.google.zxing.Writer;
 import com.google.zxing.WriterException;
 import com.google.zxing.common.ByteMatrix;
-import com.google.zxing.qrcode.encoder.ByteArray;
+import com.google.zxing.common.ByteArray;
 import com.google.zxing.qrcode.encoder.Encoder;
 import com.google.zxing.qrcode.encoder.QRCode;
 
diff --git a/core/src/com/google/zxing/qrcode/encoder/ByteArray.java b/core/src/com/google/zxing/qrcode/encoder/ByteArray.java
deleted file mode 100644 (file)
index 1b8fc51..0000000
+++ /dev/null
@@ -1,100 +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.qrcode.encoder;
-
-/**
- * This class implements an array of unsigned bytes.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public final class ByteArray {
-
-  private static final int INITIAL_SIZE = 32;
-
-  private byte[] bytes;
-  private int size;
-
-  public ByteArray() {
-    bytes = null;
-    size = 0;
-  }
-
-  public ByteArray(int size) {
-    bytes = new byte[size];
-    this.size = size;
-  }
-
-  public ByteArray(String string) {
-    bytes = string.getBytes();
-    size = bytes.length;
-  }
-
-  public ByteArray(byte[] byteArray) {
-    bytes = byteArray;
-    size = bytes.length;
-  }
-
-  /**
-   * Access an unsigned byte at location index.
-   * @param index The index in the array to access.
-   * @return The unsigned value of the byte as an int.
-   */
-  public int at(int index) {
-    return bytes[index] & 0xff;
-  }
-
-  public void set(int index, int value) {
-    bytes[index] = (byte) value;
-  }
-
-  public int size() {
-    return size;
-  }
-
-  public boolean empty() {
-    return size == 0;
-  }
-
-  public void appendByte(int value) {
-    if (size == 0 || size >= bytes.length) {
-      int newSize = Math.max(INITIAL_SIZE, size * 2);
-      reserve(newSize);
-    }
-    bytes[size] = (byte) value;
-    size++;
-  }
-
-  public void reserve(int capacity) {
-    if (bytes == null || bytes.length < capacity) {
-      byte[] newArray = new byte[capacity];
-      if (bytes != null) {
-        System.arraycopy(bytes, 0, newArray, 0, bytes.length);
-      }
-      bytes = newArray;
-    }
-  }
-
-  // Copy count bytes from array source starting at offset.
-  public void set(byte[] source, int offset, int count) {
-    bytes = new byte[count];
-    size = count;
-    for (int x = 0; x < count; x++) {
-      bytes[x] = source[offset + x];
-    }
-  }
-
-}
index 8b4fce4..de2b342 100644 (file)
@@ -17,6 +17,7 @@
 package com.google.zxing.qrcode.encoder;
 
 import com.google.zxing.common.ByteMatrix;
+import com.google.zxing.common.ByteArray;
 import com.google.zxing.common.reedsolomon.GF256;
 import com.google.zxing.common.reedsolomon.ReedSolomonEncoder;
 
index 5a1107b..81157fc 100644 (file)
@@ -17,6 +17,7 @@
 package com.google.zxing.qrcode.encoder;
 
 import junit.framework.TestCase;
+import com.google.zxing.common.ByteArray;
 
 /**
  * @author satorux@google.com (Satoru Takabayashi) - creator