]> gitweb.fperrin.net Git - Dictionary.git/blob - jars/icu4j-4_2_1-src/src/com/ibm/richtext/uiimpl/resources/MenuData.java
icu4jsrc
[Dictionary.git] / jars / icu4j-4_2_1-src / src / com / ibm / richtext / uiimpl / resources / MenuData.java
1 /*\r
2  * (C) Copyright IBM Corp. 1998-2004.  All Rights Reserved.\r
3  *\r
4  * The program is provided "as is" without any warranty express or\r
5  * implied, including the warranty of non-infringement and the implied\r
6  * warranties of merchantibility and fitness for a particular purpose.\r
7  * IBM will not be liable for any damages suffered by you as a result\r
8  * of using the Program. In no event will IBM be liable for any\r
9  * special, indirect or consequential damages or lost profits even if\r
10  * IBM has been advised of the possibility of their occurrence. IBM\r
11  * will not be liable for any third party claims against you.\r
12  */\r
13 package com.ibm.richtext.uiimpl.resources;\r
14 \r
15 /**\r
16  * This class is used in resources to represent a Menu.  It is\r
17  * just a name and an optional shortcut key.\r
18  */\r
19 public final class MenuData {\r
20 \r
21     static final String COPYRIGHT =\r
22                 "(C) Copyright IBM Corp. 1998-1999 - All Rights Reserved";\r
23     private String fName;\r
24     private boolean fHasShortcut;\r
25     private char fShortcut;\r
26     private int fKeyCode;\r
27 \r
28     public MenuData(String name) {\r
29 \r
30         fName = name;\r
31         fHasShortcut = false;\r
32     }\r
33 \r
34     public MenuData(String name, char ch, int keyCode) {\r
35 \r
36         fName = name;\r
37         fHasShortcut = true;\r
38         fShortcut = ch;\r
39         fKeyCode = keyCode;\r
40     }\r
41 \r
42     public String getName() {\r
43 \r
44         return fName;\r
45     }\r
46 \r
47     public char getShortcutChar() {\r
48 \r
49         if (!fHasShortcut) {\r
50             throw new Error("Menu doesn't have shortcut");\r
51         }\r
52         return fShortcut;\r
53     }\r
54     \r
55     public int getShortcutKeyCode() {\r
56         if (!fHasShortcut) {\r
57             throw new Error("Menu doesn't have shortcut");\r
58         }\r
59         return fKeyCode;\r
60     }\r
61 \r
62     public boolean hasShortcut() {\r
63 \r
64         return fHasShortcut;\r
65     }\r
66 }