Skip navigation links

Oracle® Fusion Middleware Site Studio for External Applications Java API Reference
11g Release 1 (11.1.1)

E17273-01


oracle.stellent.wcm.common.utils
Class MnemonicUtil

java.lang.Object
  extended by oracle.stellent.wcm.common.utils.MnemonicUtil


public class MnemonicUtil
extends java.lang.Object

Mnemonic utility class


Field Summary
static char CLOSING_PARENTHESIS
          Constant for the closing parenthesis (=right parenthesis) ')'.
static char MNEMONIC_INDICATOR
          Constant for the mnemonic indicator '&'.
static char OPENING_PARENTHESIS
          Constant for the opening parenthesis (=left parenthesis) '('.

 

Constructor Summary
MnemonicUtil()
           

 

Method Summary
static java.lang.String addMnemonicToLabel(java.lang.String label, char mnemonic)
           Returns label text with mnemonic character enclosed in parenthesis.
static java.lang.String extractLabelTextWithMnemonic(java.lang.String labelAndMnemonic)
           Extracts label text by removing non-displayable mnemonic indicator (conventionally ampersand ('&')) from label text and mnemonic resource.
static java.lang.String extractLabelTextWithoutMnemonic(java.lang.String labelAndMnemonic)
           Extracts label text by removing mnemonic characters (e.g., "(F)" and "(&F)") from label text resource containing mnemonic.
static int getMnemonicCharacter(java.lang.String labelAndMnemonic)
           Gets the keyboard mnemonic from label and mnemonic text.
static int getMnemonicIndex(java.lang.String labelAndMnemonic)
           Gets the index of the mnemonic from label and mnemonic text.
static MnemonicKeyValidator getMnemonicKeyValidator()
           
static boolean isValidMnemonicKey(int key)
          Returns true if key is an valid mnemonic key based on mnemonic key validator associated with thid class.
static void setLabelAndTextFor(javax.swing.JLabel label, java.awt.Component labelFor, LocaleMessage labelText)
           
static void setMnemonicKeyValidator(MnemonicKeyValidator mnemonicKeyValidator)
           
static void setTextAndMnemonic(javax.swing.AbstractButton button, LocaleMessage buttonText)
          Set label text and keyboard mnemonic of specified this component

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Field Detail

MNEMONIC_INDICATOR

public static final char MNEMONIC_INDICATOR
Constant for the mnemonic indicator '&'.
See Also:
Constant Field Values

OPENING_PARENTHESIS

public static final char OPENING_PARENTHESIS
Constant for the opening parenthesis (=left parenthesis) '('.
See Also:
Constant Field Values

CLOSING_PARENTHESIS

public static final char CLOSING_PARENTHESIS
Constant for the closing parenthesis (=right parenthesis) ')'.
See Also:
Constant Field Values

Constructor Detail

MnemonicUtil

public MnemonicUtil()

Method Detail

getMnemonicCharacter

public static int getMnemonicCharacter(java.lang.String labelAndMnemonic)
                                throws java.lang.NullPointerException

Gets the keyboard mnemonic from label and mnemonic text. Mnemonic character is indicated by MNEMONIC_INDICATOR. If label and mnemonic text contains two or more mnemonic indicator, second and after appearance of mnemonic indicators are ignored.

For example,

From To
&File  →  F
ファイル(&F)  →  F
Parameters:
labelAndMnemonic - label text containing mnemonic
Returns:
an int specifying the accelerator key. 0, if no mnemonic characterr in this string
Throws:
java.lang.NullPointerException - if labelAndMnemonic is null

getMnemonicIndex

public static int getMnemonicIndex(java.lang.String labelAndMnemonic)
                            throws java.lang.NullPointerException

Gets the index of the mnemonic from label and mnemonic text.

For example,

From To
&File  →  F
ファイル(&F)  →  F
Parameters:
labelAndMnemonic - label text containing mnemonic
Returns:
an int specifying the accelerator key index. 0, if no mnemonic characterr in this string
Throws:
java.lang.NullPointerException - if labelAndMnemonic is null

extractLabelTextWithMnemonic

public static java.lang.String extractLabelTextWithMnemonic(java.lang.String labelAndMnemonic)
                                                     throws java.lang.NullPointerException

Extracts label text by removing non-displayable mnemonic indicator (conventionally ampersand ('&')) from label text and mnemonic resource. If label and mnemonic text contains two or more mnemonic indicator, second and after appearance of mnemonic indicators are ignored.

For example,

From To
&File  →  File
ファイル(&F)  →  ファイル(F)
Parameters:
labelAndMnemonic - label text containing mnemonic
Returns:
label text without mnemonic
Throws:
java.lang.NullPointerException - if labelAndMnemonic is null

addMnemonicToLabel

public static java.lang.String addMnemonicToLabel(java.lang.String label,
                                                  char mnemonic)
                                           throws java.lang.NullPointerException

Returns label text with mnemonic character enclosed in parenthesis. If the label does not contain mnemonic character (ignoring case), mnemonic character is enclosed in parenthesis and added end of menu label. If mnemonic is not a valid character for mnemonic key, only label will be returned.

When you need menu label for CJK translation (or translated menu label does not contain mnemonic character), you have to add mnemonic label after menu label text. The mnemonic character should be enclosed in parenthesis and added end of menu label for CJK translation.

For example,
From To
F  +  ファイル  →  ファイル(F)
Parameters:
label -
mnemonic -
Returns:
label text with mnemonic
Throws:
java.lang.NullPointerException - if labelAndMnemonic is null

extractLabelTextWithoutMnemonic

public static java.lang.String extractLabelTextWithoutMnemonic(java.lang.String labelAndMnemonic)
                                                        throws java.lang.NullPointerException

Extracts label text by removing mnemonic characters (e.g., "(F)" and "(&F)") from label text resource containing mnemonic.

For example,

From To
&File  →  File
ファイル(&F)  →  ファイル
ファイル(F)  →  ファイル

Conventionally, mnemonic indicator is ampersand ('&') and mnemonic character for CJK translation is enclosed by OPENING_PARENTHESIS ('(') and CLOSING_PARENTHESIS (')').

If label and mnemonic text contains two or more mnemonic indicator, second and after appearance of mnemonic indicators are ignored.
If parenthesis are not enclosing only mnemonic character, parenthesis are not removed.
If mnemonic indicator is not found in CJK translation resource, last occurrence of the parenthesis and enclosed mnemonic character will be removed.

Parameters:
labelAndMnemonic -
Returns:
label text without mnemonic
Throws:
java.lang.NullPointerException - if labelAndMnemonic is null

setTextAndMnemonic

public static void setTextAndMnemonic(javax.swing.AbstractButton button,
                                      LocaleMessage buttonText)
Set label text and keyboard mnemonic of specified this component
Parameters:
button - component to set label text and mnemonic
buttonText - label text with mnemonic character

setLabelAndTextFor

public static void setLabelAndTextFor(javax.swing.JLabel label,
                                      java.awt.Component labelFor,
                                      LocaleMessage labelText)

isValidMnemonicKey

public static boolean isValidMnemonicKey(int key)
Returns true if key is an valid mnemonic key based on mnemonic key validator associated with thid class.
Parameters:
key - mnemonic key
Returns:
true if key is valid mnemonic key, else false

setMnemonicKeyValidator

public static void setMnemonicKeyValidator(MnemonicKeyValidator mnemonicKeyValidator)

getMnemonicKeyValidator

public static MnemonicKeyValidator getMnemonicKeyValidator()

Skip navigation links

Oracle® Fusion Middleware Site Studio for External Applications Java API Reference
11g Release 1 (11.1.1)

E17273-01


Copyright © 2010, Oracle and/or its affiliates. All rights reserved.