下面列出了java.util.MissingResourceException#printStackTrace ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static String get(String key) {
try {
return resourceBundle.getString(key)
.replace("BTC", baseCurrencyCode)
.replace("Bitcoin", baseCurrencyName)
.replace("bitcoin", baseCurrencyNameLowerCase);
} catch (MissingResourceException e) {
log.warn("Missing resource for key: {}", key);
e.printStackTrace();
if (DevEnv.isDevMode())
UserThread.runAfter(() -> {
// We delay a bit to not throw while UI is not ready
throw new RuntimeException("Missing resource for key: " + key);
}, 1);
return key;
}
}
public String getDisplayName(Object containerType, String containerCtx) {
try {
return bundle.getString(containerCtx);
} catch (MissingResourceException mre) {
mre.printStackTrace();
return containerCtx;
}
}
public String getDisplayName(String actionName, String containerCtx) {
try {
return bundle.getString(actionName);
} catch (MissingResourceException mre) {
mre.printStackTrace();
return actionName;
}
}
private AbstractButton findResetToDefaultButton(JDialog jd) {
String txt = null;
try {
txt = NbBundle.getMessage(PropertyDialogManager.class, "CTL_Default");
} catch (MissingResourceException mre) {
mre.printStackTrace();
fail("Bundle key CTL_DEFAULT missing from org.openide.explorer.propertysheet.Bundle.properties");
}
return findButton(jd.getContentPane(), txt);
}
public static void main(String[] args) throws Exception {
int errors = 0;
for (String loctag : args) {
Locale locale = Locale.forLanguageTag(loctag);
if (locale.equals(Locale.ROOT)) {
continue;
}
ResourceBundle rb = ResourceBundle.getBundle("jdk.test.resources.MyResources",
locale);
String tag = locale.toLanguageTag(); // normalized
String value = rb.getString("key");
System.out.println(rb.getBaseBundleName() + ": locale = " + tag + ", value = " + value);
if (!value.startsWith(tag + ':')) {
System.out.println("ERROR: " + value + " expected: " + tag);
errors++;
}
// inaccessible bundles
try {
ResourceBundle.getBundle("jdk.test.internal.resources.Foo", locale);
System.out.println("ERROR: jdk.test.internal.resources.Foo should not be accessible");
errors++;
} catch (MissingResourceException e) {
e.printStackTrace();
Throwable cause = e.getCause();
System.out.println("Expected: " +
(cause != null ? cause.getMessage() : e.getMessage()));
}
}
if (errors > 0) {
throw new RuntimeException(errors + " errors");
}
}
/** Loads an about image from its source */
private Image loadImage(String urlString) {
try {
URL u = getClass().getResource(urlString);
return Toolkit.getDefaultToolkit().getImage(u);
} catch (MissingResourceException exception) {
exception.printStackTrace();
return null;
}
}
/**
* @param key
* @param oa
* @param lcl
*/
public static String getString( String key, Object[] oa, ULocale lcl )
{
try
{
return SecurityUtil.formatMessage( getResourceBundle( lcl ).getString( key ),
oa );
}
catch ( MissingResourceException e )
{
e.printStackTrace( );
return '!' + key + '!';
}
}
/**
* @param key
* @param oa
* @param lcl
*/
public static String getString( String key, Object[] oa, ULocale lcl )
{
try
{
return SecurityUtil.formatMessage( getResourceBundle( lcl ).getString( key ),
oa );
}
catch ( MissingResourceException e )
{
e.printStackTrace( );
return '!' + key + '!';
}
}
/**
* @param key
* @param oa
* @param lcl
*/
public static String getString( String key, Object[] oa, ULocale lcl )
{
try
{
return SecurityUtil.formatMessage( getResourceBundle( lcl ).getString( key ),
oa );
}
catch ( MissingResourceException e )
{
e.printStackTrace( );
return '!' + key + '!';
}
}
/**
* @param key
* @param oa
* @param lcl
*/
public static String getString( String key, Object[] oa, ULocale lcl )
{
try
{
return SecurityUtil.formatMessage( getResourceBundle( lcl ).getString( key ),
oa );
}
catch ( MissingResourceException e )
{
e.printStackTrace( );
return '!' + key + '!';
}
}
/** Creates new form LabeledTextFieldDialog */
public LabeledTextFieldDialog(String notes)
{
String title = NbBundle.getMessage (LabeledTextFieldDialog.class, "RecreateTableRenameTable"); // NOI18N
String lab = NbBundle.getMessage (LabeledTextFieldDialog.class, "RecreateTableNewName"); // NOI18N
original_notes = notes;
initComponents();
try
{
Mnemonics.setLocalizedText(titleLabel, lab);
titleLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (LabeledTextFieldDialog.class, "ACS_RecreateTableNewNameA11yDesc")); // NOI18N
Mnemonics.setLocalizedText(descLabel, NbBundle.getMessage (LabeledTextFieldDialog.class, "RecreateTableRenameNotes")); // NOI18N
descLabel.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (LabeledTextFieldDialog.class, "ACS_RecreateTableRenameNotesA11yDesc")); // NOI18N
Mnemonics.setLocalizedText(editButton, NbBundle.getMessage (LabeledTextFieldDialog.class, "EditCommand")); // NOI18N
editButton.setToolTipText(NbBundle.getMessage (LabeledTextFieldDialog.class, "ACS_EditCommandA11yDesc")); // NOI18N
updateState();
ActionListener listener = new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
result = event.getSource() == DialogDescriptor.OK_OPTION;
}
};
getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (LabeledTextFieldDialog.class, "ACS_RecreateTableDialogA11yDesc")); // NOI18N
DialogDescriptor descriptor = new DialogDescriptor(this, title, true, listener);
dialog = DialogDisplayer.getDefault().createDialog(descriptor);
dialog.setResizable(true);
}
catch (MissingResourceException e)
{
e.printStackTrace();
}
}
/**
* Attempt to resolve the voice that most suits the conditions and the user's preferences.
*
* @param language the {@link Locale} language
* @param region the {@link Locale} region
* @param conditions the {@link SelfAwareConditions}
* @param params the {@link SelfAwareParameters}
* @return one of {@link #SUCCESS} or {@link #ERROR}
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private int resolveVoice(@NonNull final String language, @NonNull final String region,
@NonNull final SelfAwareConditions conditions, @NonNull final SelfAwareParameters params,
@Nullable final SaiyVoice currentVoice) {
if (DEBUG) {
MyLog.i(CLS_NAME, "resolveVoice");
}
final Pair<SaiyVoice, Locale> voicePair = new TTSVoice(language, region, conditions, params,
currentVoice).buildVoice();
if (voicePair.first != null) {
if (DEBUG) {
MyLog.i(CLS_NAME, "resolveVoice: Setting Voice: " + voicePair.first.toString());
MyLog.i(CLS_NAME, "resolveVoice: Setting Voice loc: " + voicePair.first.getLocale());
try {
MyLog.i(CLS_NAME, "resolveVoice: Setting Voice: isLanguageAvailable: "
+ resolveSuccess(isLanguageAvailable(new Locale(voicePair.first.getLocale().getLanguage(),
voicePair.first.getLocale().getCountry()))));
} catch (final MissingResourceException e) {
MyLog.w(CLS_NAME, "MissingResourceException: isLanguageAvailable failed");
e.printStackTrace();
}
}
return super.setVoice(voicePair.first);
} else {
if (voicePair.second != null) {
if (DEBUG) {
MyLog.i(CLS_NAME, "resolveVoice: Setting Locale deprecated");
}
return setVoiceDeprecated(voicePair.second.getLanguage(), voicePair.second.getCountry());
} else {
if (DEBUG) {
MyLog.w(CLS_NAME, "resolveVoice: voicePair.second null: falling back");
}
return resolveSuccess(super.setLanguage(new Locale(language, region)));
}
}
}