CodaBarWriter.java (zxing-zxing-3.4.0) | : | CodaBarWriter.java (zxing-zxing-3.4.1) | ||
---|---|---|---|---|
skipping to change at line 19 | skipping to change at line 19 | |||
* | * | |||
* 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 java.util.Collection; | ||||
import java.util.Collections; | ||||
/** | /** | |||
* This class renders CodaBar as {@code boolean[]}. | * This class renders CodaBar as {@code boolean[]}. | |||
* | * | |||
* @author dsbnatut@gmail.com (Kazuki Nishiura) | * @author dsbnatut@gmail.com (Kazuki Nishiura) | |||
*/ | */ | |||
public final class CodaBarWriter extends OneDimensionalCodeWriter { | public final class CodaBarWriter extends OneDimensionalCodeWriter { | |||
private static final char[] START_END_CHARS = {'A', 'B', 'C', 'D'}; | private static final char[] START_END_CHARS = {'A', 'B', 'C', 'D'}; | |||
private static final char[] ALT_START_END_CHARS = {'T', 'N', '*', 'E'}; | private static final char[] ALT_START_END_CHARS = {'T', 'N', '*', 'E'}; | |||
private static final char[] CHARS_WHICH_ARE_TEN_LENGTH_EACH_AFTER_DECODED = {' /', ':', '+', '.'}; | private static final char[] CHARS_WHICH_ARE_TEN_LENGTH_EACH_AFTER_DECODED = {' /', ':', '+', '.'}; | |||
private static final char DEFAULT_GUARD = START_END_CHARS[0]; | private static final char DEFAULT_GUARD = START_END_CHARS[0]; | |||
@Override | @Override | |||
protected Collection<BarcodeFormat> getSupportedWriteFormats() { | ||||
return Collections.singleton(BarcodeFormat.CODABAR); | ||||
} | ||||
@Override | ||||
public boolean[] encode(String contents) { | public boolean[] encode(String contents) { | |||
if (contents.length() < 2) { | if (contents.length() < 2) { | |||
// Can't have a start/end guard, so tentatively add default guards | // Can't have a start/end guard, so tentatively add default guards | |||
contents = DEFAULT_GUARD + contents + DEFAULT_GUARD; | contents = DEFAULT_GUARD + contents + DEFAULT_GUARD; | |||
} else { | } else { | |||
// Verify input and calculate decoded length. | // Verify input and calculate decoded length. | |||
char firstChar = Character.toUpperCase(contents.charAt(0)); | char firstChar = Character.toUpperCase(contents.charAt(0)); | |||
char lastChar = Character.toUpperCase(contents.charAt(contents.length() - 1)); | char lastChar = Character.toUpperCase(contents.charAt(contents.length() - 1)); | |||
boolean startsNormal = CodaBarReader.arrayContains(START_END_CHARS, firstC har); | boolean startsNormal = CodaBarReader.arrayContains(START_END_CHARS, firstC har); | |||
End of changes. 2 change blocks. | ||||
0 lines changed or deleted | 10 lines changed or added |