"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "core/src/main/java/com/google/zxing/datamatrix/encoder/EdifactEncoder.java" between
zxing-zxing-3.4.0.tar.gz and zxing-zxing-3.4.1.tar.gz

About: ZXing ("zebra crossing") is a multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages.

EdifactEncoder.java  (zxing-zxing-3.4.0):EdifactEncoder.java  (zxing-zxing-3.4.1)
skipping to change at line 37 skipping to change at line 37
public void encode(EncoderContext context) { public void encode(EncoderContext context) {
//step F //step F
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
while (context.hasMoreCharacters()) { while (context.hasMoreCharacters()) {
char c = context.getCurrentChar(); char c = context.getCurrentChar();
encodeChar(c, buffer); encodeChar(c, buffer);
context.pos++; context.pos++;
int count = buffer.length(); int count = buffer.length();
if (count >= 4) { if (count >= 4) {
context.writeCodewords(encodeToCodewords(buffer, 0)); context.writeCodewords(encodeToCodewords(buffer));
buffer.delete(0, 4); buffer.delete(0, 4);
int newMode = HighLevelEncoder.lookAheadTest(context.getMessage(), conte xt.pos, getEncodingMode()); int newMode = HighLevelEncoder.lookAheadTest(context.getMessage(), conte xt.pos, getEncodingMode());
if (newMode != getEncodingMode()) { if (newMode != getEncodingMode()) {
// Return to ASCII encodation, which will actually handle latch to new mode // Return to ASCII encodation, which will actually handle latch to new mode
context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION); context.signalEncoderChange(HighLevelEncoder.ASCII_ENCODATION);
break; break;
} }
} }
} }
skipping to change at line 83 skipping to change at line 83
} }
if (remaining <= available && available <= 2) { if (remaining <= available && available <= 2) {
return; //No unlatch return; //No unlatch
} }
} }
if (count > 4) { if (count > 4) {
throw new IllegalStateException("Count must not exceed 4"); throw new IllegalStateException("Count must not exceed 4");
} }
int restChars = count - 1; int restChars = count - 1;
String encoded = encodeToCodewords(buffer, 0); String encoded = encodeToCodewords(buffer);
boolean endOfSymbolReached = !context.hasMoreCharacters(); boolean endOfSymbolReached = !context.hasMoreCharacters();
boolean restInAscii = endOfSymbolReached && restChars <= 2; boolean restInAscii = endOfSymbolReached && restChars <= 2;
if (restChars <= 2) { if (restChars <= 2) {
context.updateSymbolInfo(context.getCodewordCount() + restChars); context.updateSymbolInfo(context.getCodewordCount() + restChars);
int available = context.getSymbolInfo().getDataCapacity() - context.getC odewordCount(); int available = context.getSymbolInfo().getDataCapacity() - context.getC odewordCount();
if (available >= 3) { if (available >= 3) {
restInAscii = false; restInAscii = false;
context.updateSymbolInfo(context.getCodewordCount() + encoded.length() ); context.updateSymbolInfo(context.getCodewordCount() + encoded.length() );
//available = context.symbolInfo.dataCapacity - context.getCodewordCou nt(); //available = context.symbolInfo.dataCapacity - context.getCodewordCou nt();
skipping to change at line 118 skipping to change at line 118
private static void encodeChar(char c, StringBuilder sb) { private static void encodeChar(char c, StringBuilder sb) {
if (c >= ' ' && c <= '?') { if (c >= ' ' && c <= '?') {
sb.append(c); sb.append(c);
} else if (c >= '@' && c <= '^') { } else if (c >= '@' && c <= '^') {
sb.append((char) (c - 64)); sb.append((char) (c - 64));
} else { } else {
HighLevelEncoder.illegalCharacter(c); HighLevelEncoder.illegalCharacter(c);
} }
} }
private static String encodeToCodewords(CharSequence sb, int startPos) { private static String encodeToCodewords(CharSequence sb) {
int len = sb.length() - startPos; int len = sb.length();
if (len == 0) { if (len == 0) {
throw new IllegalStateException("StringBuilder must not be empty"); throw new IllegalStateException("StringBuilder must not be empty");
} }
char c1 = sb.charAt(startPos); char c1 = sb.charAt(0);
char c2 = len >= 2 ? sb.charAt(startPos + 1) : 0; char c2 = len >= 2 ? sb.charAt(1) : 0;
char c3 = len >= 3 ? sb.charAt(startPos + 2) : 0; char c3 = len >= 3 ? sb.charAt(2) : 0;
char c4 = len >= 4 ? sb.charAt(startPos + 3) : 0; char c4 = len >= 4 ? sb.charAt(3) : 0;
int v = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4; int v = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4;
char cw1 = (char) ((v >> 16) & 255); char cw1 = (char) ((v >> 16) & 255);
char cw2 = (char) ((v >> 8) & 255); char cw2 = (char) ((v >> 8) & 255);
char cw3 = (char) (v & 255); char cw3 = (char) (v & 255);
StringBuilder res = new StringBuilder(3); StringBuilder res = new StringBuilder(3);
res.append(cw1); res.append(cw1);
if (len >= 2) { if (len >= 2) {
res.append(cw2); res.append(cw2);
} }
 End of changes. 4 change blocks. 
8 lines changed or deleted 8 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)