399 |
StringBuffer result = new StringBuffer(value); |
StringBuffer result = new StringBuffer(value); |
400 |
char markChar; |
char markChar; |
401 |
char resultChar; |
char resultChar; |
402 |
|
boolean literal; |
403 |
|
|
404 |
// this boolean is specifically to avoid calling the isCharValid method |
// this boolean is specifically to avoid calling the isCharValid method |
405 |
// when neither invalidChars or validChars has been set |
// when neither invalidChars or validChars has been set |
407 |
|
|
408 |
for (int i = 0, j = 0; i < value.length(); i++, j++) |
for (int i = 0, j = 0; i < value.length(); i++, j++) |
409 |
{ |
{ |
410 |
|
literal = false; |
411 |
resultChar = result.charAt(i); |
resultChar = result.charAt(i); |
|
// If necessary, check if the character is valid. |
|
|
if (checkCharSets && !isCharValid(resultChar)) |
|
|
throw new ParseException("invalid character: "+resultChar, i); |
|
|
|
|
412 |
// This switch block on the mask character checks that the character |
// This switch block on the mask character checks that the character |
413 |
// within <code>value</code> at that point is valid according to the |
// within <code>value</code> at that point is valid according to the |
414 |
// mask and also converts to upper/lowercase as needed. |
// mask and also converts to upper/lowercase as needed. |
448 |
// Escape character, check the next character to make sure that |
// Escape character, check the next character to make sure that |
449 |
// the literals match |
// the literals match |
450 |
j++; |
j++; |
451 |
|
literal = true; |
452 |
if (resultChar != mask.charAt(j)) |
if (resultChar != mask.charAt(j)) |
453 |
throw new ParseException ("Invalid character: "+resultChar, i); |
throw new ParseException ("Invalid character: "+resultChar, i); |
454 |
break; |
break; |
455 |
default: |
default: |
456 |
|
literal = true; |
457 |
if (!getValueContainsLiteralCharacters() && convert) |
if (!getValueContainsLiteralCharacters() && convert) |
458 |
throw new ParseException ("Invalid character: "+resultChar, i); |
throw new ParseException ("Invalid character: "+resultChar, i); |
459 |
else if (resultChar != mask.charAt(j)) |
else if (resultChar != mask.charAt(j)) |
460 |
throw new ParseException ("Invalid character: "+resultChar, i); |
throw new ParseException ("Invalid character: "+resultChar, i); |
461 |
} |
} |
462 |
|
// If necessary, check if the character is valid. |
463 |
|
if (!literal && checkCharSets && !isCharValid(resultChar)) |
464 |
|
throw new ParseException("invalid character: "+resultChar, i); |
465 |
|
|
466 |
} |
} |
467 |
return result.toString(); |
return result.toString(); |
468 |
} |
} |