/[classpath]/classpath/java/awt/AWTKeyStroke.java
ViewVC logotype

Diff of /classpath/java/awt/AWTKeyStroke.java

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

revision 1.6 by mkoch, Mon Sep 27 15:11:46 2004 UTC revision 1.7 by mark, Sun Feb 13 23:34:01 2005 UTC
# Line 1  Line 1 
1  /* AWTKeyStroke.java -- an immutable key stroke  /* AWTKeyStroke.java -- an immutable key stroke
2     Copyright (C) 2002, 2004  Free Software Foundation     Copyright (C) 2002, 2004, 2005  Free Software Foundation
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
5    
# Line 393  public class AWTKeyStroke implements Ser Line 393  public class AWTKeyStroke implements Ser
393     * </code>           * </code>      
394     *     *
395     * @param s the string to parse     * @param s the string to parse
396       * @throws IllegalArgumentException if s is null or cannot be parsed
397     * @return the specified keystroke     * @return the specified keystroke
    * @throws NullPointerException if s is null  
    * @throws IllegalArgumentException if s cannot be parsed  
398     */     */
399    public static AWTKeyStroke getAWTKeyStroke(String s)    public static AWTKeyStroke getAWTKeyStroke(String s)
400    {    {
401        if (s == null)
402          throw new IllegalArgumentException("null argument");
403      StringTokenizer t = new StringTokenizer(s, " ");      StringTokenizer t = new StringTokenizer(s, " ");
404      if (! t.hasMoreTokens())      if (! t.hasMoreTokens())
405        throw new IllegalArgumentException();        throw new IllegalArgumentException("no tokens '" + s + "'");
406      int modifiers = 0;      int modifiers = 0;
407      boolean released = false;      boolean released = false;
408      String token = null;      String token = null;
# Line 432  public class AWTKeyStroke implements Ser Line 433  public class AWTKeyStroke implements Ser
433                                           KeyEvent.VK_UNDEFINED, modifiers,                                           KeyEvent.VK_UNDEFINED, modifiers,
434                                           false);                                           false);
435                }                }
436              throw new IllegalArgumentException();              throw new IllegalArgumentException("Invalid 'typed' argument '"
437                                                   + s + "'");
438            }            }
439          else if ("pressed".equals(token))          else if ("pressed".equals(token))
440            {            {
# Line 453  public class AWTKeyStroke implements Ser Line 455  public class AWTKeyStroke implements Ser
455      while (t.hasMoreTokens());      while (t.hasMoreTokens());
456      // Now token contains the VK name we must parse.      // Now token contains the VK name we must parse.
457      Integer code = (Integer) vktable.get(token);      Integer code = (Integer) vktable.get(token);
458      if (code == null || t.hasMoreTokens())      if (code == null)
459        throw new IllegalArgumentException();        throw new IllegalArgumentException("Unknown token '" + token
460                                             + "' in '" + s + "'");
461        if (t.hasMoreTokens())
462          throw new IllegalArgumentException("Too many tokens: " + s);
463      return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, code.intValue(),      return getAWTKeyStroke(KeyEvent.CHAR_UNDEFINED, code.intValue(),
464                             modifiers, released);                             modifiers, released);
465    }    }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

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