/[classpath]/classpath/javax/swing/text/MaskFormatter.java
ViewVC logotype

Diff of /classpath/javax/swing/text/MaskFormatter.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by abalkiss, Tue Nov 22 19:42:04 2005 UTC revision 1.3 by abalkiss, Tue Nov 22 20:10:23 2005 UTC
# Line 399  public class MaskFormatter extends Defau Line 399  public class MaskFormatter extends Defau
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
# Line 406  public class MaskFormatter extends Defau Line 407  public class MaskFormatter extends Defau
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.
# Line 450  public class MaskFormatter extends Defau Line 448  public class MaskFormatter extends Defau
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    }    }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26