UPCAWriter.java (zxing-zxing-3.4.0) | : | UPCAWriter.java (zxing-zxing-3.4.1) | ||
---|---|---|---|---|
skipping to change at line 22 | skipping to change at line 22 | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | |||
* limitations under the License. | * limitations under the License. | |||
*/ | */ | |||
package com.google.zxing.oned; | package com.google.zxing.oned; | |||
import com.google.zxing.BarcodeFormat; | import com.google.zxing.BarcodeFormat; | |||
import com.google.zxing.EncodeHintType; | import com.google.zxing.EncodeHintType; | |||
import com.google.zxing.Writer; | import com.google.zxing.Writer; | |||
import com.google.zxing.WriterException; | ||||
import com.google.zxing.common.BitMatrix; | import com.google.zxing.common.BitMatrix; | |||
import java.util.Map; | import java.util.Map; | |||
/** | /** | |||
* This object renders a UPC-A code as a {@link BitMatrix}. | * This object renders a UPC-A code as a {@link BitMatrix}. | |||
* | * | |||
* @author qwandor@google.com (Andrew Walbran) | * @author qwandor@google.com (Andrew Walbran) | |||
*/ | */ | |||
public final class UPCAWriter implements Writer { | public final class UPCAWriter implements Writer { | |||
private final EAN13Writer subWriter = new EAN13Writer(); | private final EAN13Writer subWriter = new EAN13Writer(); | |||
@Override | @Override | |||
public BitMatrix encode(String contents, BarcodeFormat format, int width, int | public BitMatrix encode(String contents, BarcodeFormat format, int width, int | |||
height) | height) { | |||
throws WriterException { | ||||
return encode(contents, format, width, height, null); | return encode(contents, format, width, height, null); | |||
} | } | |||
@Override | @Override | |||
public BitMatrix encode(String contents, | public BitMatrix encode(String contents, | |||
BarcodeFormat format, | BarcodeFormat format, | |||
int width, | int width, | |||
int height, | int height, | |||
Map<EncodeHintType,?> hints) throws WriterException { | Map<EncodeHintType,?> hints) { | |||
if (format != BarcodeFormat.UPC_A) { | if (format != BarcodeFormat.UPC_A) { | |||
throw new IllegalArgumentException("Can only encode UPC-A, but got " + for mat); | throw new IllegalArgumentException("Can only encode UPC-A, but got " + for mat); | |||
} | } | |||
// Transform a UPC-A code into the equivalent EAN-13 code and write it that way | // Transform a UPC-A code into the equivalent EAN-13 code and write it that way | |||
return subWriter.encode('0' + contents, BarcodeFormat.EAN_13, width, height, hints); | return subWriter.encode('0' + contents, BarcodeFormat.EAN_13, width, height, hints); | |||
} | } | |||
} | } | |||
End of changes. 3 change blocks. | ||||
5 lines changed or deleted | 3 lines changed or added |