1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package net.sourceforge.jivalo.editor.key;
17
18
19 /**
20 * @author <a href="mailto:ivalo@iki.fi">Markku Saarela</a>
21 *
22 */
23 public final class KeyAction
24 {
25
26 /**
27 * Name of key action.
28 * @see javax.swing.text.DefaultEditorKit
29 */
30 private String name;
31
32 /**
33 * Value of key action.
34 * @see javax.swing.text.DefaultEditorKit
35 */
36 private String action;
37
38 /**
39 * Styled name of action.
40 */
41 private String actionName;
42
43 /**
44 * @param name javax.swing.text.DefaultEditorKit static field name
45 * @param action javax.swing.text.DefaultEditorKit static field value
46 */
47 public KeyAction( String name, Object action )
48 {
49 super();
50 this.name = name;
51 this.action = action.toString();
52
53 char[] cs = action.toString().replaceAll( "_", " " ).trim().toCharArray();
54
55 StringBuffer sb = new StringBuffer();
56
57 for ( int i = 0; i < cs.length; i++ )
58 {
59 if ( ( i == 0 )
60 || ( i > 0 && cs[i - 1] == ' ' ) )
61 {
62 sb.append( Character.toUpperCase( cs[i] ) );
63 }
64 else
65 {
66 sb.append( cs[i] );
67 }
68 }
69 }
70
71 /**
72 * @return the action
73 */
74 public String getAction()
75 {
76 return this.action;
77 }
78
79 /**
80 * @return the actionName
81 */
82 public String getActionName()
83 {
84 return this.actionName;
85 }
86
87 /**
88 * @return the name
89 */
90 public String getName()
91 {
92 return this.name;
93 }
94
95 }