Barcode128 extends Barcode1D { public static String getRawText(String text, boolean ucc, Barcode128CodeSet codeSet) { String out = ""; int tLen = text.length(); if (tLen == 0) { out += getStartSymbol(codeSet); if (ucc) out += FNC1_INDEX; return out; } int c; for (int k = 0; k < tLen; ++k) { c = text.charAt(k); if (c > 127 && c != FNC1) throw new PdfException(PdfException.ThereAreIllegalCharactersForBarcode128In1); } c = text.charAt(0); char currentCode = getStartSymbol(codeSet); int index = 0; if ((codeSet == Barcode128CodeSet.AUTO || codeSet == Barcode128CodeSet.C) && isNextDigits(text, index, 2)) { currentCode = START_C; out += currentCode; if (ucc) out += FNC1_INDEX; String out2 = getPackedRawDigits(text, index, 2); index += out2.charAt(0); out += out2.substring(1); } else if (c < ' ') { currentCode = START_A; out += currentCode; if (ucc) out += FNC1_INDEX; out += (char) (c + 64); ++index; } else { out += currentCode; if (ucc) out += FNC1_INDEX; if (c == FNC1) out += FNC1_INDEX; else out += (char) (c - ' '); ++index; } if (codeSet != Barcode128CodeSet.AUTO && currentCode != getStartSymbol(codeSet)) throw new PdfException(PdfException.ThereAreIllegalCharactersForBarcode128In1); while (index < tLen) { switch (currentCode) { case START_A: { if (codeSet == Barcode128CodeSet.AUTO && isNextDigits(text, index, 4)) { currentCode = START_C; out += CODE_AB_TO_C; String out2 = getPackedRawDigits(text, index, 4); index += out2.charAt(0); out += out2.substring(1); } else { c = text.charAt(index++); if (c == FNC1) out += FNC1_INDEX; else if (c > '_') { currentCode = START_B; out += CODE_AC_TO_B; out += (char) (c - ' '); } else if (c < ' ') out += (char) (c + 64); else out += (char) (c - ' '); } } break; case START_B: { if (codeSet == Barcode128CodeSet.AUTO && isNextDigits(text, index, 4)) { currentCode = START_C; out += CODE_AB_TO_C; String out2 = getPackedRawDigits(text, index, 4); index += out2.charAt(0); out += out2.substring(1); } else { c = text.charAt(index++); if (c == FNC1) out += FNC1_INDEX; else if (c < ' ') { currentCode = START_A; out += CODE_BC_TO_A; out += (char) (c + 64); } else { out += (char) (c - ' '); } } } break; case START_C: { if (isNextDigits(text, index, 2)) { String out2 = getPackedRawDigits(text, index, 2); index += out2.charAt(0); out += out2.substring(1); } else { c = text.charAt(index++); if (c == FNC1) out += FNC1_INDEX; else if (c < ' ') { currentCode = START_A; out += CODE_BC_TO_A; out += (char) (c + 64); } else { currentCode = START_B; out += CODE_AC_TO_B; out += (char) (c - ' '); } } } break; } if (codeSet != Barcode128CodeSet.AUTO && currentCode != getStartSymbol(codeSet)) throw new PdfException(PdfException.ThereAreIllegalCharactersForBarcode128In1); } return out; } Barcode128(PdfDocument document);  Barcode128(PdfDocument document, PdfFont font); void setCodeSet(Barcode128CodeSet codeSet); Barcode128CodeSet getCodeSet(); static String removeFNC1(String code); static String getHumanReadableUCCEAN(String code); static String getRawText(String text, boolean ucc, Barcode128CodeSet codeSet); static String getRawText(String text, boolean ucc); static byte[] getBarsCode128Raw(String text); @Override Rectangle getBarcodeSize(); @Override Rectangle placeBarcode(PdfCanvas canvas, Color barColor, Color textColor); @Override void setCode(String code); @Override java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color background); static final int CODE128; static final int CODE128_UCC; static final int CODE128_RAW; static final char CODE_AB_TO_C; static final char CODE_AC_TO_B; static final char CODE_BC_TO_A; static final char FNC1_INDEX; static final char START_A; static final char START_B; static final char START_C; static final char FNC1; static final char DEL; static final char FNC3; static final char FNC2; static final char SHIFT; static final char CODE_C; static final char CODE_A; static final char FNC4; static final char STARTA; static final char STARTB; static final char STARTC; }
@Test public void barcodeRawValueGenerationTest01() { Assert.assertEquals(new String(new byte[] {103, 17, 18, 19, 20, 21, 17, 18, 19, 20, 21}), Barcode128.getRawText("1234512345", false, Barcode128.Barcode128CodeSet.A)); }