java.util.ListResourceBundle Java Examples

The following examples show how to use java.util.ListResourceBundle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SecuritySupport.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #2
Source File: NewResourcesNames.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
Example #3
Source File: NewResourcesNames.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
Example #4
Source File: NewResourcesNames.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
Example #5
Source File: SecuritySupport.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #6
Source File: NewResourcesNames.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
Example #7
Source File: SecuritySupport.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #8
Source File: NewResourcesNames.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
Example #9
Source File: SecuritySupport.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #10
Source File: Logger.java    From j2objc with Apache License 2.0 6 votes vote down vote up
private static ResourceBundle findSystemResourceBundle(final Locale locale) {
  // J2ObjC: inlined contents of sun/util/logging/resources/logging/logging.properties
  return new ListResourceBundle() {
    @Override
    protected Object[][] getContents() {
      return new Object[][] {
        { "ALL", "ALL" },
        { "SEVERE", "SEVERE" },
        { "WARNING", "WARNING" },
        { "INFO", "INFO" },
        { "CONFIG", "CONFIG" },
        { "FINE", "FINE" },
        { "FINER", "FINER" },
        { "FINEST", "FINEST" },
        { "OFF", "OFF" }
      };
    }
  };
}
 
Example #11
Source File: SecuritySupport.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #12
Source File: SecuritySupport.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #13
Source File: SecuritySupport.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #14
Source File: EvaluateActionSetter.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This method associates Ctrl+new line with the evaluation of commands in the console.
 */
@Override
public void onCreateActions(ListResourceBundle resources, final BaseEditor baseEditor, IProgressMonitor monitor) {
    final PyEdit edit = (PyEdit) baseEditor;
    final EvaluateAction evaluateAction = new EvaluateAction(edit);
    evaluateAction.setActionDefinitionId(IInteractiveConsoleConstants.EVALUATE_ACTION_ID);
    evaluateAction.setId(IInteractiveConsoleConstants.EVALUATE_ACTION_ID);
    Runnable runnable = new Runnable() {
        @Override
        public void run() {
            if (!edit.isDisposed()) {
                edit.setAction(IInteractiveConsoleConstants.EVALUATE_ACTION_ID, evaluateAction);
            }
        }
    };
    Display.getDefault().syncExec(runnable);
}
 
Example #15
Source File: Prd5262IT.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected ExpressionRuntime createRuntime() throws ReportProcessingException {
  ResourceBundle b = new ListResourceBundle() {
    protected Object[][] getContents() {
      return new Object[][] { { "format", "$(date,date,yyyy-MM-dd'T'HH:mm:ss,SSSZZZ)" } };
    }
  };

  ResourceBundleFactory f = Mockito.mock( ResourceBundleFactory.class );
  Mockito.when( f.getLocale() ).thenReturn( Locale.US );
  Mockito.when( f.getTimeZone() ).thenReturn( TimeZone.getTimeZone( "PST" ) );
  Mockito.when( f.getResourceBundle( "test" ) ).thenReturn( b );

  ProcessingContext pc = Mockito.mock( ProcessingContext.class );
  Mockito.when( pc.getResourceBundleFactory() ).thenReturn( f );

  DataRow r = Mockito.mock( DataRow.class );
  Mockito.when( r.get( "number" ) ).thenReturn( new Double( 123456.78901 ) );
  Mockito.when( r.get( "date" ) ).thenReturn( new Date( 1234567890123l ) );

  return new DebugExpressionRuntime( r, new DefaultTableModel(), 0, pc );
}
 
Example #16
Source File: SecuritySupport.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #17
Source File: SecuritySupport.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #18
Source File: AdditionalInfoIntegrityChecker.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void onCreateActions(ListResourceBundle resources, final BaseEditor baseEditor, IProgressMonitor monitor) {
    IPyEdit edit = (IPyEdit) baseEditor;
    edit.addOfflineActionListener("--internal-test-modules", new Action() {
        @Override
        public void run() {
            List<IPythonNature> allPythonNatures = PythonNature.getAllPythonNatures();
            StringBuffer buf = new StringBuffer();
            try {
                for (IPythonNature nature : allPythonNatures) {
                    buf.append(checkIntegrity(nature, new NullProgressMonitor(), true));
                }
            } catch (MisconfigurationException e) {
                buf.append(e.getMessage());
            }
            PyDialogHelpers.showString(buf.toString());
        }
    }, "Used just for testing (do not use).", true);
}
 
Example #19
Source File: SecuritySupport.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #20
Source File: SecuritySupport.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #21
Source File: SecuritySupport.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #22
Source File: SecuritySupport.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the
 * caller's class loader.
 *
 * @param bundle the base name of the resource bundle, a fully qualified
 * class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle) ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle) ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #23
Source File: NewResourcesNames.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
Example #24
Source File: PyEditNotifier.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Notifies listeners that the actions have just been created in the editor.
 */
public void notifyOnCreateActions(final ListResourceBundle resources) {
    final BaseEditor edit = pyEdit.get();
    if (edit == null) {
        return;
    }
    INotifierRunnable runnable = new INotifierRunnable() {
        @Override
        public void run(final IProgressMonitor monitor) {
            for (IPyEditListener listener : edit.getAllListeners()) {
                try {
                    if (!monitor.isCanceled()) {
                        listener.onCreateActions(resources, edit, monitor);
                    }
                } catch (Exception e) {
                    //must not fail
                    Log.log(e);
                }
            }
        }
    };
    runIt(runnable);
}
 
Example #25
Source File: SecuritySupport.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ListResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ListResourceBundle>() {
        public ListResourceBundle run() {
            try {
                return (ListResourceBundle)ResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return (ListResourceBundle)ResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
Example #26
Source File: NewResourcesNames.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
Example #27
Source File: InteractiveConsoleCommandsSyncListener.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void onCreateActions(ListResourceBundle resources, BaseEditor baseEditor, IProgressMonitor monitor) {
    //Note: can be called multiple times (will only create handlers for the new actions).
    Map<String, InteractiveCommandCustomHandler> commandIdToHandler = InteractiveConsoleCommand
            .getCommandIdToHandler();
    Set<Entry<String, InteractiveCommandCustomHandler>> entrySet = commandIdToHandler.entrySet();
    for (Entry<String, InteractiveCommandCustomHandler> entry : entrySet) {
        if (idToAction.containsKey(entry.getKey())) {
            continue;
        }
        InteractiveConsoleUserCommandAction action = new InteractiveConsoleUserCommandAction(resources,
                "Pyedit.InteractiveConsoleUserCommand", baseEditor, entry.getKey());
        action.setActionDefinitionId(entry.getKey());
        action.setId(entry.getKey());
        baseEditor.setAction(FullRepIterable.getLastPart(entry.getKey()), action);
        idToAction.put(entry.getKey(), action);
    }
    this.resources = resources;
    this.weakEditor = new WeakReference<>(baseEditor);
    InteractiveConsoleCommand.onCommandIdToHandlerChanged.registerListener(onCommandIdToHandlerChangedCallback);
}
 
Example #28
Source File: NewResourcesNames.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Loads a resources using JRE and returns the names
 */
private static Set<String> loadClass(String clazz) throws Exception {
    ListResourceBundle lrb =
            (ListResourceBundle)Class.forName(clazz).newInstance();
    Set<String> keys = lrb.keySet();
    Map<String,String> newold = new HashMap<String,String>();
    boolean dup = false;
    // Check if normalize() creates dup entries. This is crucial.
    for (String k: keys) {
        String key = normalize(k);
        if (newold.containsKey(key)) {
            err("Dup found for " + key + ":");
            err("["+newold.get(key)+"]");
            err("["+k+"]");
            dup = true;
        }
        newold.put(key, k);
    }
    if (dup) throw new Exception();
    return keys;
}
 
Example #29
Source File: JstlLocalizationTest.java    From vraptor4 with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
	request = mock(HttpServletRequest.class);
	servletContext = mock(ServletContext.class);
	session = mock(HttpSession.class);

	localization = new JstlLocalization(request);

	ResourceBundle bundle = new ListResourceBundle() {
		@Override
		protected Object[][] getContents() {
			return new Object[][] { { "my.key", "abc" } };
		}
	};

	LocalizationContext context = new LocalizationContext(bundle);
	when(request.getAttribute(FMT_LOCALIZATION_CONTEXT + ".request")).thenReturn(context);

	when(request.getSession(false)).thenReturn(session);
	when(request.getServletContext()).thenReturn(servletContext);
}
 
Example #30
Source File: TestSetSecurityAnswersHandler.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
@Provides @Named(SetSecurityAnswersHandler.NAME_RESOURCE_BUNDLE)
public ResourceBundle stubSecurityQuestionBundle() {
   return new ListResourceBundle()
   {
      @Override
      protected Object[][] getContents()
      {
         return new Object[][] {
            { "questionA", "Mother's maiden name?" },
            { "questionB", "Father's middle name?" },
            { "questionC", "First car?" },
         };
      }
   };
}