breakUpDataForEncoding method
dynamic
breakUpDataForEncoding()
Implementation
breakUpDataForEncoding() {
String temp = "";
String tempRawData = _data;
//breaking the raw data up for code A and code B will mess up the encoding
if (_code128Type == Code128Type.A || _code128Type == Code128Type.B) {
for (int i = 0; i < _data.length; i++) {
_formattedData.add(_data[i]);
}
return;
}
if (_code128Type == Code128Type.C) {
if (!checkNumericOnly(_data)) {
throw new Exception(
"EC128-6: Only numeric values can be encoded with C128-C.");
}
//CODE C: adds a 0 to the front of the Data if the length is not divisible by 2
if (_data.length % 2 > 0) {
tempRawData = "0" + _data;
}
}
for (int i = 0; i < tempRawData.length; i++) {
final String c = tempRawData[i];
if (c.isNumber()) {
if (temp == "") {
temp += c;
} else {
temp += c;
_formattedData.add(temp);
temp = "";
}
} else {
if (temp != "") {
_formattedData.add(temp);
temp = "";
}
_formattedData.add(c);
}
}
//if something is still in temp go ahead and push it onto the queue
if (temp != "") {
_formattedData.add(temp);
temp = "";
}
}