Code128Writer.java (zxing-zxing-3.4.0) | : | Code128Writer.java (zxing-zxing-3.4.1) | ||
---|---|---|---|---|
skipping to change at line 20 | skipping to change at line 20 | |||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | |||
* 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.WriterException; | ||||
import com.google.zxing.common.BitMatrix; | import com.google.zxing.common.BitMatrix; | |||
import java.util.ArrayList; | import java.util.ArrayList; | |||
import java.util.Collection; | import java.util.Collection; | |||
import java.util.Map; | import java.util.Collections; | |||
/** | /** | |||
* This object renders a CODE128 code as a {@link BitMatrix}. | * This object renders a CODE128 code as a {@link BitMatrix}. | |||
* | * | |||
* @author erik.barbara@gmail.com (Erik Barbara) | * @author erik.barbara@gmail.com (Erik Barbara) | |||
*/ | */ | |||
public final class Code128Writer extends OneDimensionalCodeWriter { | public final class Code128Writer extends OneDimensionalCodeWriter { | |||
private static final int CODE_START_A = 103; | private static final int CODE_START_A = 103; | |||
private static final int CODE_START_B = 104; | private static final int CODE_START_B = 104; | |||
skipping to change at line 64 | skipping to change at line 62 | |||
// Results of minimal lookahead for code C | // Results of minimal lookahead for code C | |||
private enum CType { | private enum CType { | |||
UNCODABLE, | UNCODABLE, | |||
ONE_DIGIT, | ONE_DIGIT, | |||
TWO_DIGITS, | TWO_DIGITS, | |||
FNC_1 | FNC_1 | |||
} | } | |||
@Override | @Override | |||
public BitMatrix encode(String contents, | protected Collection<BarcodeFormat> getSupportedWriteFormats() { | |||
BarcodeFormat format, | return Collections.singleton(BarcodeFormat.CODE_128); | |||
int width, | ||||
int height, | ||||
Map<EncodeHintType,?> hints) throws WriterException { | ||||
if (format != BarcodeFormat.CODE_128) { | ||||
throw new IllegalArgumentException("Can only encode CODE_128, but got " + | ||||
format); | ||||
} | ||||
return super.encode(contents, format, width, height, hints); | ||||
} | } | |||
@Override | @Override | |||
public boolean[] encode(String contents) { | public boolean[] encode(String contents) { | |||
int length = contents.length(); | int length = contents.length(); | |||
// Check length | // Check length | |||
if (length < 1 || length > 80) { | if (length < 1 || length > 80) { | |||
throw new IllegalArgumentException( | throw new IllegalArgumentException( | |||
"Contents length should be between 1 and 80 characters, but got " + le ngth); | "Contents length should be between 1 and 80 characters, but got " + le ngth); | |||
} | } | |||
End of changes. 3 change blocks. | ||||
13 lines changed or deleted | 3 lines changed or added |