Program: 58367
Project: 58367
Buggy source:
private boolean calculateBinaryString(){
  encodeMode last_mode=encodeMode.NUMERIC;
  int encoding_method, i, j, read_posn;
  boolean latch;
  int remainder, d1, d2, value;
  String padstring;
  double weight;
  int group_val;
  int current_length;
  String patch;
  read_posn=0;
  if ((source.length() >= 16) && ((source.charAt(0) == '0') && (source.charAt(1) == '1'))) {
    encoding_method=1;
  }
 else {
    encoding_method=2;
  }
  if (((source.length() >= 20) && (encoding_method == 1)) && ((source.charAt(2) == '9') && (source.charAt(16) == '3'))) {
    if ((source.length() >= 26) && (source.charAt(17) == '1')) {
      if (source.charAt(18) == '0') {
        weight=0.0;
        for (i=0; i < 6; i++) {
          weight*=10;
          weight+=(source.charAt(20 + i) - '0');
        }
        if (weight < 99999.0) {
          if ((source.charAt(19) == '3') && (source.length() == 26)) {
            weight/=1000.0;
            if (weight <= 32.767) {
              encoding_method=3;
            }
          }
          if (source.length() == 34) {
            if ((source.charAt(26) == '1') && (source.charAt(27) == '1')) {
              encoding_method=7;
            }
            if ((source.charAt(26) == '1') && (source.charAt(27) == '3')) {
              encoding_method=9;
            }
            if ((source.charAt(26) == '1') && (source.charAt(27) == '5')) {
              encoding_method=11;
            }
            if ((source.charAt(26) == '1') && (source.charAt(27) == '7')) {
              encoding_method=13;
            }
          }
        }
      }
    }
    if ((source.length() >= 26) && (source.charAt(17) == '2')) {
      if (source.charAt(18) == '0') {
        weight=0.0;
        for (i=0; i < 6; i++) {
          weight*=10;
          weight+=(source.charAt(20 + i) - '0');
        }
        if (weight < 99999.0) {
          if (((source.charAt(19) == '2') || (source.charAt(19) == '3')) && (source.length() == 26)) {
            if (source.charAt(19) == '3') {
              weight/=1000.0;
              if (weight <= 22.767) {
                encoding_method=4;
              }
            }
 else {
              weight/=100.0;
              if (weight <= 99.99) {
                encoding_method=4;
              }
            }
          }
          if (source.length() == 34) {
            if ((source.charAt(26) == '1') && (source.charAt(27) == '1')) {
              encoding_method=8;
            }
            if ((source.charAt(26) == '1') && (source.charAt(27) == '3')) {
              encoding_method=10;
            }
            if ((source.charAt(26) == '1') && (source.charAt(27) == '5')) {
              encoding_method=12;
            }
            if ((source.charAt(26) == '1') && (source.charAt(27) == '7')) {
              encoding_method=14;
            }
          }
        }
      }
    }
    if (source.charAt(17) == '9') {
      if ((source.charAt(18) == '2') && ((source.charAt(19) >= '0') && (source.charAt(19) <= '3'))) {
        encoding_method=5;
      }
      if ((source.charAt(18) == '3') && ((source.charAt(19) >= '0') && (source.charAt(19) <= '3'))) {
        encoding_method=6;
      }
    }
  }
  encodeInfo+="String_Node_Str" + Integer.toString(encoding_method) + "String_Node_Str";
switch (encoding_method) {
case 1:
    binary_string+="String_Node_Str";
  read_posn=16;
break;
case 2:
binary_string+="String_Node_Str";
read_posn=0;
break;
case 3:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 4:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 5:
binary_string+="String_Node_Str";
read_posn=20;
break;
case 6:
binary_string+="String_Node_Str";
read_posn=23;
break;
case 7:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 8:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 9:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 10:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 11:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 12:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 13:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 14:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
}
for (i=0; i < read_posn; i++) {
if ((source.charAt(i) < '0') || (source.charAt(i) > '9')) {
if ((source.charAt(i) != '[') && (source.charAt(i) != ']')) {
error_msg="String_Node_Str";
return false;
}
}
}
if (encoding_method == 1) {
group_val=source.charAt(2) - '0';
for (j=0; j < 4; j++) {
if ((group_val & (0x08 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
for (i=1; i < 5; i++) {
group_val=100 * (source.charAt(i * 3) - '0');
group_val+=10 * (source.charAt((i * 3) + 1) - '0');
group_val+=source.charAt((i * 3) + 2) - '0';
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
}
if (encoding_method == 3) {
for (i=1; i < 5; i++) {
group_val=100 * (source.charAt(i * 3) - '0');
group_val+=10 * (source.charAt((i * 3) + 1) - '0');
group_val+=(source.charAt((i * 3) + 2) - '0');
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
group_val=0;
for (i=0; i < 6; i++) {
group_val*=10;
group_val+=source.charAt(20 + i) - '0';
}
for (j=0; j < 15; j++) {
if ((group_val & (0x4000 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
if (encoding_method == 4) {
for (i=1; i < 5; i++) {
group_val=100 * (source.charAt(i * 3) - '0');
group_val+=10 * (source.charAt((i * 3) + 1) - '0');
group_val+=(source.charAt((i * 3) + 2) - '0');
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
group_val=0;
for (i=0; i < 6; i++) {
group_val*=10;
group_val+=source.charAt(20 + i) - '0';
}
if (source.charAt(19) == '3') {
group_val=group_val + 10000;
}
for (j=0; j < 15; j++) {
if ((group_val & (0x4000 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
if ((encoding_method >= 7) && (encoding_method <= 14)) {
for (i=1; i < 5; i++) {
group_val=100 * (source.charAt(i * 3) - '0');
group_val+=10 * (source.charAt((i * 3) + 1) - '0');
group_val+=(source.charAt((i * 3) + 2) - '0');
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
group_val=source.charAt(19) - '0';
for (i=0; i < 5; i++) {
group_val*=10;
group_val+=source.charAt(21 + i) - '0';
}
for (j=0; j < 20; j++) {
if ((group_val & (0x80000 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
if (source.length() == 34) {
group_val=((10 * (source.charAt(28) - '0')) + (source.charAt(29) - '0')) * 384;
group_val+=(((10 * (source.charAt(30) - '0')) + (source.charAt(31) - '0')) - 1) * 32;
group_val+=(10 * (source.charAt(32) - '0')) + (source.charAt(33) - '0');
}
 else {
group_val=38400;
}
for (j=0; j < 16; j++) {
if ((group_val & (0x8000 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
if (encoding_method == 5) {
for (i=1; i < 5; i++) {
group_val=100 * (source.charAt(i * 3) - '0');
group_val+=10 * (source.charAt((i * 3) + 1) - '0');
group_val+=(source.charAt((i * 3) + 2) - '0');
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
switch (source.charAt(19)) {
case '0':
binary_string+="String_Node_Str";
break;
case '1':
binary_string+="String_Node_Str";
break;
case '2':
binary_string+="String_Node_Str";
break;
case '3':
binary_string+="String_Node_Str";
break;
}
}
if (encoding_method == 6) {
for (i=1; i < 5; i++) {
group_val=100 * (source.charAt(i * 3) - '0');
group_val+=10 * (source.charAt((i * 3) + 1) - '0');
group_val+=(source.charAt((i * 3) + 2) - '0');
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
switch (source.charAt(19)) {
case '0':
binary_string+="String_Node_Str";
break;
case '1':
binary_string+="String_Node_Str";
break;
case '2':
binary_string+="String_Node_Str";
break;
case '3':
binary_string+="String_Node_Str";
break;
}
group_val=0;
for (i=0; i < 3; i++) {
group_val*=10;
group_val+=source.charAt(20 + i) - '0';
}
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
general_field=source.substring(read_posn);
general_field_type=new encodeMode[general_field.length()];
if (general_field.length() != 0) {
latch=false;
for (i=0; i < general_field.length(); i++) {
if ((general_field.charAt(i) < ' ') || (general_field.charAt(i) > 'z')) {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
 else {
general_field_type[i]=encodeMode.ISOIEC;
}
if (general_field.charAt(i) == '#') {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
if (general_field.charAt(i) == '$') {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
if (general_field.charAt(i) == '@') {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
if (general_field.charAt(i) == 92) {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
if (general_field.charAt(i) == '^') {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
if (general_field.charAt(i) == 96) {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
if ((general_field.charAt(i) >= 'A') && (general_field.charAt(i) <= 'Z')) {
general_field_type[i]=encodeMode.ALPHA_OR_ISO;
}
if (general_field.charAt(i) == '*') {
general_field_type[i]=encodeMode.ALPHA_OR_ISO;
}
if (general_field.charAt(i) == ',') {
general_field_type[i]=encodeMode.ALPHA_OR_ISO;
}
if (general_field.charAt(i) == '-') {
general_field_type[i]=encodeMode.ALPHA_OR_ISO;
}
if (general_field.charAt(i) == '.') {
general_field_type[i]=encodeMode.ALPHA_OR_ISO;
}
if (general_field.charAt(i) == '/') {
general_field_type[i]=encodeMode.ALPHA_OR_ISO;
}
if ((general_field.charAt(i) >= '0') && (general_field.charAt(i) <= '9')) {
general_field_type[i]=encodeMode.ANY_ENC;
}
if (general_field.charAt(i) == '[') {
general_field_type[i]=encodeMode.ANY_ENC;
}
}
if (latch) {
error_msg="String_Node_Str";
return false;
}
for (i=0; i < general_field.length() - 1; i++) {
if ((general_field_type[i] == encodeMode.ISOIEC) && (general_field.charAt(i + 1) == '[')) {
general_field_type[i + 1]=encodeMode.ISOIEC;
}
}
for (i=0; i < general_field.length() - 1; i++) {
if ((general_field_type[i] == encodeMode.ALPHA_OR_ISO) && (general_field.charAt(i + 1) == '[')) {
general_field_type[i + 1]=encodeMode.ALPHA_OR_ISO;
}
}
latch=applyGeneralFieldRules();
if (general_field_type[0] == encodeMode.ALPHA) {
binary_string+="String_Node_Str";
last_mode=encodeMode.ALPHA;
}
if (general_field_type[0] == encodeMode.ISOIEC) {
binary_string+="String_Node_Str";
binary_string+="String_Node_Str";
last_mode=encodeMode.ISOIEC;
}
i=0;
do {
switch (general_field_type[i]) {
case NUMERIC:
if (last_mode != encodeMode.NUMERIC) {
binary_string+="String_Node_Str";
}
if (general_field.charAt(i) != '[') {
d1=general_field.charAt(i) - '0';
}
 else {
d1=10;
}
if (general_field.charAt(i + 1) != '[') {
d2=general_field.charAt(i + 1) - '0';
}
 else {
d2=10;
}
value=(11 * d1) + d2 + 8;
for (j=0; j < 7; j++) {
if ((value & (0x40 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
i+=2;
last_mode=encodeMode.NUMERIC;
break;
case ALPHA:
if (i != 0) {
if (last_mode == encodeMode.NUMERIC) {
binary_string+="String_Node_Str";
}
if (last_mode == encodeMode.ISOIEC) {
binary_string+="String_Node_Str";
}
}
if ((general_field.charAt(i) >= '0') && (general_field.charAt(i) <= '9')) {
value=general_field.charAt(i) - 43;
for (j=0; j < 5; j++) {
if ((value & (0x10 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
if ((general_field.charAt(i) >= 'A') && (general_field.charAt(i) <= 'Z')) {
value=general_field.charAt(i) - 33;
for (j=0; j < 6; j++) {
if ((value & (0x20 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
last_mode=encodeMode.ALPHA;
if (general_field.charAt(i) == '[') {
binary_string+="String_Node_Str";
last_mode=encodeMode.NUMERIC;
}
if (general_field.charAt(i) == '*') binary_string+="String_Node_Str";
if (general_field.charAt(i) == ',') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '-') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '.') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '/') binary_string+="String_Node_Str";
i++;
break;
case ISOIEC:
if (i != 0) {
if (last_mode == encodeMode.NUMERIC) {
binary_string+="String_Node_Str";
binary_string+="String_Node_Str";
}
if (last_mode == encodeMode.ALPHA) {
binary_string+="String_Node_Str";
}
}
if ((general_field.charAt(i) >= '0') && (general_field.charAt(i) <= '9')) {
value=general_field.charAt(i) - 43;
for (j=0; j < 5; j++) {
if ((value & (0x10 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
if ((general_field.charAt(i) >= 'A') && (general_field.charAt(i) <= 'Z')) {
value=general_field.charAt(i) - 1;
for (j=0; j < 7; j++) {
if ((value & (0x40 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
if ((general_field.charAt(i) >= 'a') && (general_field.charAt(i) <= 'z')) {
value=general_field.charAt(i) - 7;
for (j=0; j < 7; j++) {
if ((value & (0x40 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
last_mode=encodeMode.ISOIEC;
if (general_field.charAt(i) == '[') {
binary_string+="String_Node_Str";
last_mode=encodeMode.NUMERIC;
}
if (general_field.charAt(i) == '!') binary_string+="String_Node_Str";
if (general_field.charAt(i) == 34) binary_string+="String_Node_Str";
if (general_field.charAt(i) == 37) binary_string+="String_Node_Str";
if (general_field.charAt(i) == '&') binary_string+="String_Node_Str";
if (general_field.charAt(i) == 39) binary_string+="String_Node_Str";
if (general_field.charAt(i) == '(') binary_string+="String_Node_Str";
if (general_field.charAt(i) == ')') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '*') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '+') binary_string+="String_Node_Str";
if (general_field.charAt(i) == ',') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '-') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '.') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '/') binary_string+="String_Node_Str";
if (general_field.charAt(i) == ':') binary_string+="String_Node_Str";
if (general_field.charAt(i) == ';') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '<') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '=') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '>') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '?') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '_') binary_string+="String_Node_Str";
if (general_field.charAt(i) == ' ') binary_string+="String_Node_Str";
i++;
break;
}
current_length=i;
if (latch) {
current_length++;
}
}
 while (current_length < general_field.length());
remainder=12 - (binary_string.length() % 12);
if (remainder == 12) {
remainder=0;
}
if (binary_string.length() < 36) {
remainder=36 - binary_string.length();
}
if (latch) {
if (last_mode == encodeMode.NUMERIC) {
if ((remainder >= 4) && (remainder <= 6)) {
value=general_field.charAt(i) - '0';
value++;
for (j=0; j < 4; j++) {
if ((value & (0x08 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
 else {
d1=general_field.charAt(i) - '0';
d2=10;
value=(11 * d1) + d2 + 8;
for (j=0; j < 7; j++) {
if ((value & (0x40 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
}
 else {
value=general_field.charAt(i) - 43;
for (j=0; j < 5; j++) {
if ((value & (0x10 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
}
}
if (binary_string.length() > 252) {
error_msg="String_Node_Str";
return false;
}
remainder=36 - binary_string.length();
if (binary_string.length() > 36) {
for (i=36; i < binary_string.length(); i+=24) {
remainder=(i + 24) - binary_string.length();
}
}
i=remainder;
if ((general_field.length() != 0) && (last_mode == encodeMode.NUMERIC)) {
padstring="String_Node_Str";
i-=4;
}
 else {
padstring="String_Node_Str";
}
for (; i > 0; i-=5) {
padstring+="String_Node_Str";
}
binary_string+=padstring.substring(0,remainder);
patch="String_Node_Str";
if ((((binary_string.length() / 12) + 1) & 1) == 0) {
patch+="String_Node_Str";
}
 else {
patch+="String_Node_Str";
}
if (binary_string.length() <= 156) {
patch+="String_Node_Str";
}
 else {
patch+="String_Node_Str";
}
if (encoding_method == 1) {
binary_string=binary_string.substring(0,2) + patch + binary_string.substring(4);
}
if (encoding_method == 2) {
binary_string=binary_string.substring(0,3) + patch + binary_string.substring(5);
}
if ((encoding_method == 5) || (encoding_method == 6)) {
binary_string=binary_string.substring(0,6) + patch + binary_string.substring(8);
}
encodeInfo+="String_Node_Str" + Integer.toString(binary_string.length()) + "String_Node_Str";
displayBinaryString();
return true;
}

Fixed version (ground truth):
private boolean calculateBinaryString(){
  encodeMode last_mode=encodeMode.NUMERIC;
  int encoding_method, i, j, read_posn;
  boolean latch;
  int remainder, d1, d2, value;
  String padstring;
  double weight;
  int group_val;
  int current_length;
  String patch;
  read_posn=0;
  if ((source.length() >= 16) && ((source.charAt(0) == '0') && (source.charAt(1) == '1'))) {
    encoding_method=1;
  }
 else {
    encoding_method=2;
  }
  if (((source.length() >= 20) && (encoding_method == 1)) && ((source.charAt(2) == '9') && (source.charAt(16) == '3'))) {
    if ((source.length() >= 26) && (source.charAt(17) == '1')) {
      if (source.charAt(18) == '0') {
        weight=0.0;
        for (i=0; i < 6; i++) {
          weight*=10;
          weight+=(source.charAt(20 + i) - '0');
        }
        if (weight < 99999.0) {
          if ((source.charAt(19) == '3') && (source.length() == 26)) {
            weight/=1000.0;
            if (weight <= 32.767) {
              encoding_method=3;
            }
          }
          if (source.length() == 34) {
            if ((source.charAt(26) == '1') && (source.charAt(27) == '1')) {
              encoding_method=7;
            }
            if ((source.charAt(26) == '1') && (source.charAt(27) == '3')) {
              encoding_method=9;
            }
            if ((source.charAt(26) == '1') && (source.charAt(27) == '5')) {
              encoding_method=11;
            }
            if ((source.charAt(26) == '1') && (source.charAt(27) == '7')) {
              encoding_method=13;
            }
          }
        }
      }
    }
    if ((source.length() >= 26) && (source.charAt(17) == '2')) {
      if (source.charAt(18) == '0') {
        weight=0.0;
        for (i=0; i < 6; i++) {
          weight*=10;
          weight+=(source.charAt(20 + i) - '0');
        }
        if (weight < 99999.0) {
          if (((source.charAt(19) == '2') || (source.charAt(19) == '3')) && (source.length() == 26)) {
            if (source.charAt(19) == '3') {
              weight/=1000.0;
              if (weight <= 22.767) {
                encoding_method=4;
              }
            }
 else {
              weight/=100.0;
              if (weight <= 99.99) {
                encoding_method=4;
              }
            }
          }
          if (source.length() == 34) {
            if ((source.charAt(26) == '1') && (source.charAt(27) == '1')) {
              encoding_method=8;
            }
            if ((source.charAt(26) == '1') && (source.charAt(27) == '3')) {
              encoding_method=10;
            }
            if ((source.charAt(26) == '1') && (source.charAt(27) == '5')) {
              encoding_method=12;
            }
            if ((source.charAt(26) == '1') && (source.charAt(27) == '7')) {
              encoding_method=14;
            }
          }
        }
      }
    }
    if (source.charAt(17) == '9') {
      if ((source.charAt(18) == '2') && ((source.charAt(19) >= '0') && (source.charAt(19) <= '3'))) {
        encoding_method=5;
      }
      if ((source.charAt(18) == '3') && ((source.charAt(19) >= '0') && (source.charAt(19) <= '3'))) {
        encoding_method=6;
      }
    }
  }
  encodeInfo+="String_Node_Str" + Integer.toString(encoding_method) + "String_Node_Str";
switch (encoding_method) {
case 1:
    binary_string+="String_Node_Str";
  read_posn=16;
break;
case 2:
binary_string+="String_Node_Str";
read_posn=0;
break;
case 3:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 4:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 5:
binary_string+="String_Node_Str";
read_posn=20;
break;
case 6:
binary_string+="String_Node_Str";
read_posn=23;
break;
case 7:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 8:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 9:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 10:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 11:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 12:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 13:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
case 14:
binary_string+="String_Node_Str";
read_posn=source.length();
break;
}
for (i=0; i < read_posn; i++) {
if ((source.charAt(i) < '0') || (source.charAt(i) > '9')) {
if ((source.charAt(i) != '[') && (source.charAt(i) != ']')) {
error_msg="String_Node_Str";
return false;
}
}
}
if (encoding_method == 1) {
group_val=source.charAt(2) - '0';
for (j=0; j < 4; j++) {
if ((group_val & (0x08 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
for (i=1; i < 5; i++) {
group_val=100 * (source.charAt(i * 3) - '0');
group_val+=10 * (source.charAt((i * 3) + 1) - '0');
group_val+=source.charAt((i * 3) + 2) - '0';
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
}
if (encoding_method == 3) {
for (i=1; i < 5; i++) {
group_val=100 * (source.charAt(i * 3) - '0');
group_val+=10 * (source.charAt((i * 3) + 1) - '0');
group_val+=(source.charAt((i * 3) + 2) - '0');
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
group_val=0;
for (i=0; i < 6; i++) {
group_val*=10;
group_val+=source.charAt(20 + i) - '0';
}
for (j=0; j < 15; j++) {
if ((group_val & (0x4000 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
if (encoding_method == 4) {
for (i=1; i < 5; i++) {
group_val=100 * (source.charAt(i * 3) - '0');
group_val+=10 * (source.charAt((i * 3) + 1) - '0');
group_val+=(source.charAt((i * 3) + 2) - '0');
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
group_val=0;
for (i=0; i < 6; i++) {
group_val*=10;
group_val+=source.charAt(20 + i) - '0';
}
if (source.charAt(19) == '3') {
group_val=group_val + 10000;
}
for (j=0; j < 15; j++) {
if ((group_val & (0x4000 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
if ((encoding_method >= 7) && (encoding_method <= 14)) {
for (i=1; i < 5; i++) {
group_val=100 * (source.charAt(i * 3) - '0');
group_val+=10 * (source.charAt((i * 3) + 1) - '0');
group_val+=(source.charAt((i * 3) + 2) - '0');
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
group_val=source.charAt(19) - '0';
for (i=0; i < 5; i++) {
group_val*=10;
group_val+=source.charAt(21 + i) - '0';
}
for (j=0; j < 20; j++) {
if ((group_val & (0x80000 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
if (source.length() == 34) {
group_val=((10 * (source.charAt(28) - '0')) + (source.charAt(29) - '0')) * 384;
group_val+=(((10 * (source.charAt(30) - '0')) + (source.charAt(31) - '0')) - 1) * 32;
group_val+=(10 * (source.charAt(32) - '0')) + (source.charAt(33) - '0');
}
 else {
group_val=38400;
}
for (j=0; j < 16; j++) {
if ((group_val & (0x8000 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
if (encoding_method == 5) {
for (i=1; i < 5; i++) {
group_val=100 * (source.charAt(i * 3) - '0');
group_val+=10 * (source.charAt((i * 3) + 1) - '0');
group_val+=(source.charAt((i * 3) + 2) - '0');
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
switch (source.charAt(19)) {
case '0':
binary_string+="String_Node_Str";
break;
case '1':
binary_string+="String_Node_Str";
break;
case '2':
binary_string+="String_Node_Str";
break;
case '3':
binary_string+="String_Node_Str";
break;
}
}
if (encoding_method == 6) {
for (i=1; i < 5; i++) {
group_val=100 * (source.charAt(i * 3) - '0');
group_val+=10 * (source.charAt((i * 3) + 1) - '0');
group_val+=(source.charAt((i * 3) + 2) - '0');
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
switch (source.charAt(19)) {
case '0':
binary_string+="String_Node_Str";
break;
case '1':
binary_string+="String_Node_Str";
break;
case '2':
binary_string+="String_Node_Str";
break;
case '3':
binary_string+="String_Node_Str";
break;
}
group_val=0;
for (i=0; i < 3; i++) {
group_val*=10;
group_val+=source.charAt(20 + i) - '0';
}
for (j=0; j < 10; j++) {
if ((group_val & (0x200 >> j)) == 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
general_field=source.substring(read_posn);
general_field_type=new encodeMode[general_field.length()];
if (general_field.length() != 0) {
latch=false;
for (i=0; i < general_field.length(); i++) {
if ((general_field.charAt(i) < ' ') || (general_field.charAt(i) > 'z')) {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
 else {
general_field_type[i]=encodeMode.ISOIEC;
}
if (general_field.charAt(i) == '#') {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
if (general_field.charAt(i) == '$') {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
if (general_field.charAt(i) == '@') {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
if (general_field.charAt(i) == 92) {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
if (general_field.charAt(i) == '^') {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
if (general_field.charAt(i) == 96) {
general_field_type[i]=encodeMode.INVALID_CHAR;
latch=true;
}
if ((general_field.charAt(i) >= 'A') && (general_field.charAt(i) <= 'Z')) {
general_field_type[i]=encodeMode.ALPHA_OR_ISO;
}
if (general_field.charAt(i) == '*') {
general_field_type[i]=encodeMode.ALPHA_OR_ISO;
}
if (general_field.charAt(i) == ',') {
general_field_type[i]=encodeMode.ALPHA_OR_ISO;
}
if (general_field.charAt(i) == '-') {
general_field_type[i]=encodeMode.ALPHA_OR_ISO;
}
if (general_field.charAt(i) == '.') {
general_field_type[i]=encodeMode.ALPHA_OR_ISO;
}
if (general_field.charAt(i) == '/') {
general_field_type[i]=encodeMode.ALPHA_OR_ISO;
}
if ((general_field.charAt(i) >= '0') && (general_field.charAt(i) <= '9')) {
general_field_type[i]=encodeMode.ANY_ENC;
}
if (general_field.charAt(i) == '[') {
general_field_type[i]=encodeMode.ANY_ENC;
}
}
if (latch) {
error_msg="String_Node_Str";
return false;
}
for (i=0; i < general_field.length() - 1; i++) {
if ((general_field_type[i] == encodeMode.ISOIEC) && (general_field.charAt(i + 1) == '[')) {
general_field_type[i + 1]=encodeMode.ISOIEC;
}
}
for (i=0; i < general_field.length() - 1; i++) {
if ((general_field_type[i] == encodeMode.ALPHA_OR_ISO) && (general_field.charAt(i + 1) == '[')) {
general_field_type[i + 1]=encodeMode.ALPHA_OR_ISO;
}
}
latch=applyGeneralFieldRules();
if (general_field_type[0] == encodeMode.ALPHA) {
binary_string+="String_Node_Str";
last_mode=encodeMode.ALPHA;
}
if (general_field_type[0] == encodeMode.ISOIEC) {
binary_string+="String_Node_Str";
binary_string+="String_Node_Str";
last_mode=encodeMode.ISOIEC;
}
i=0;
do {
switch (general_field_type[i]) {
case NUMERIC:
if (last_mode != encodeMode.NUMERIC) {
binary_string+="String_Node_Str";
}
if (general_field.charAt(i) != '[') {
d1=general_field.charAt(i) - '0';
}
 else {
d1=10;
}
if (general_field.charAt(i + 1) != '[') {
d2=general_field.charAt(i + 1) - '0';
}
 else {
d2=10;
}
value=(11 * d1) + d2 + 8;
for (j=0; j < 7; j++) {
if ((value & (0x40 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
i+=2;
last_mode=encodeMode.NUMERIC;
break;
case ALPHA:
if (i != 0) {
if (last_mode == encodeMode.NUMERIC) {
binary_string+="String_Node_Str";
}
if (last_mode == encodeMode.ISOIEC) {
binary_string+="String_Node_Str";
}
}
if ((general_field.charAt(i) >= '0') && (general_field.charAt(i) <= '9')) {
value=general_field.charAt(i) - 43;
for (j=0; j < 5; j++) {
if ((value & (0x10 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
if ((general_field.charAt(i) >= 'A') && (general_field.charAt(i) <= 'Z')) {
value=general_field.charAt(i) - 33;
for (j=0; j < 6; j++) {
if ((value & (0x20 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
last_mode=encodeMode.ALPHA;
if (general_field.charAt(i) == '[') {
binary_string+="String_Node_Str";
last_mode=encodeMode.NUMERIC;
}
if (general_field.charAt(i) == '*') binary_string+="String_Node_Str";
if (general_field.charAt(i) == ',') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '-') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '.') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '/') binary_string+="String_Node_Str";
i++;
break;
case ISOIEC:
if (i != 0) {
if (last_mode == encodeMode.NUMERIC) {
binary_string+="String_Node_Str";
binary_string+="String_Node_Str";
}
if (last_mode == encodeMode.ALPHA) {
binary_string+="String_Node_Str";
}
}
if ((general_field.charAt(i) >= '0') && (general_field.charAt(i) <= '9')) {
value=general_field.charAt(i) - 43;
for (j=0; j < 5; j++) {
if ((value & (0x10 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
if ((general_field.charAt(i) >= 'A') && (general_field.charAt(i) <= 'Z')) {
value=general_field.charAt(i) - 1;
for (j=0; j < 7; j++) {
if ((value & (0x40 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
if ((general_field.charAt(i) >= 'a') && (general_field.charAt(i) <= 'z')) {
value=general_field.charAt(i) - 7;
for (j=0; j < 7; j++) {
if ((value & (0x40 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
last_mode=encodeMode.ISOIEC;
if (general_field.charAt(i) == '[') {
binary_string+="String_Node_Str";
last_mode=encodeMode.NUMERIC;
}
if (general_field.charAt(i) == '!') binary_string+="String_Node_Str";
if (general_field.charAt(i) == 34) binary_string+="String_Node_Str";
if (general_field.charAt(i) == 37) binary_string+="String_Node_Str";
if (general_field.charAt(i) == '&') binary_string+="String_Node_Str";
if (general_field.charAt(i) == 39) binary_string+="String_Node_Str";
if (general_field.charAt(i) == '(') binary_string+="String_Node_Str";
if (general_field.charAt(i) == ')') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '*') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '+') binary_string+="String_Node_Str";
if (general_field.charAt(i) == ',') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '-') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '.') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '/') binary_string+="String_Node_Str";
if (general_field.charAt(i) == ':') binary_string+="String_Node_Str";
if (general_field.charAt(i) == ';') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '<') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '=') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '>') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '?') binary_string+="String_Node_Str";
if (general_field.charAt(i) == '_') binary_string+="String_Node_Str";
if (general_field.charAt(i) == ' ') binary_string+="String_Node_Str";
i++;
break;
}
current_length=i;
if (latch) {
current_length++;
}
}
 while (current_length < general_field.length());
remainder=calculateRemainder(binary_string.length());
if (latch) {
if (last_mode == encodeMode.NUMERIC) {
if ((remainder >= 4) && (remainder <= 6)) {
value=general_field.charAt(i) - '0';
value++;
for (j=0; j < 4; j++) {
if ((value & (0x08 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
 else {
d1=general_field.charAt(i) - '0';
d2=10;
value=(11 * d1) + d2 + 8;
for (j=0; j < 7; j++) {
if ((value & (0x40 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
}
 else {
value=general_field.charAt(i) - 43;
for (j=0; j < 5; j++) {
if ((value & (0x10 >> j)) != 0) {
binary_string+="String_Node_Str";
}
 else {
binary_string+="String_Node_Str";
}
}
}
}
}
if (binary_string.length() > 252) {
error_msg="String_Node_Str";
return false;
}
remainder=calculateRemainder(binary_string.length());
i=remainder;
if ((general_field.length() != 0) && (last_mode == encodeMode.NUMERIC)) {
padstring="String_Node_Str";
i-=4;
}
 else {
padstring="String_Node_Str";
}
for (; i > 0; i-=5) {
padstring+="String_Node_Str";
}
binary_string+=padstring.substring(0,remainder);
patch="String_Node_Str";
if ((((binary_string.length() / 12) + 1) & 1) == 0) {
patch+="String_Node_Str";
}
 else {
patch+="String_Node_Str";
}
if (binary_string.length() <= 156) {
patch+="String_Node_Str";
}
 else {
patch+="String_Node_Str";
}
if (encoding_method == 1) {
binary_string=binary_string.substring(0,2) + patch + binary_string.substring(4);
}
if (encoding_method == 2) {
binary_string=binary_string.substring(0,3) + patch + binary_string.substring(5);
}
if ((encoding_method == 5) || (encoding_method == 6)) {
binary_string=binary_string.substring(0,6) + patch + binary_string.substring(8);
}
encodeInfo+="String_Node_Str" + Integer.toString(binary_string.length()) + "String_Node_Str";
displayBinaryString();
return true;
}