Java Examples for java.util.ResourceBundle

The following java examples will help you to understand the usage of java.util.ResourceBundle. These source code samples are taken from different open source projects.

Example 1
Project: JavaFrameByFrameVideo-master  File: I18N.java View source code
public static String getResource(String key) {
    //$$ Testing - cania
    //$$ java.util.Locale.setDefault(Locale.GERMANY);
    Locale currentLocale = java.util.Locale.getDefault();
    if (bundle == null) {
        try {
            bundle = java.util.ResourceBundle.getBundle("com.sun.media.customizer.Props", currentLocale);
        } catch (java.util.MissingResourceException e) {
            e.printStackTrace();
            System.out.println("Could not load Resources");
            System.exit(0);
        }
    }
    String value = new String("");
    try {
        value = (String) bundle.getObject(key);
    } catch (java.util.MissingResourceException e) {
        System.out.println("Could not find " + key);
    }
    return value;
}
Example 2
Project: barchart-udt-master  File: ResourcesMgr.java View source code
public static String getString(String s) {
    if (bundle == null) {
        // only load if/when needed
        bundle = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<java.util.ResourceBundle>() {

            public java.util.ResourceBundle run() {
                return (java.util.ResourceBundle.getBundle("sun.security.util.Resources"));
            }
        });
    }
    return bundle.getString(s);
}
Example 3
Project: classlib6-master  File: ResourcesMgr.java View source code
public static String getString(String s) {
    if (bundle == null) {
        // only load if/when needed
        bundle = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<java.util.ResourceBundle>() {

            public java.util.ResourceBundle run() {
                return (java.util.ResourceBundle.getBundle("sun.security.util.Resources"));
            }
        });
    }
    return bundle.getString(s);
}
Example 4
Project: ikvm-openjdk-master  File: ResourcesMgr.java View source code
public static String getString(String s) {
    if (bundle == null) {
        // only load if/when needed
        bundle = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<java.util.ResourceBundle>() {

            public java.util.ResourceBundle run() {
                return (java.util.ResourceBundle.getBundle("sun.security.util.Resources"));
            }
        });
    }
    return bundle.getString(s);
}
Example 5
Project: j2objc-master  File: ResourcesMgr.java View source code
public static String getString(String s) {
    if (bundle == null) {
        // only load if/when needed
        bundle = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<java.util.ResourceBundle>() {

            public java.util.ResourceBundle run() {
                // Android changed: Work around class name.
                return java.util.ResourceBundle.getBundle(Resources.class.getName());
            }
        });
    }
    return bundle.getString(s);
}
Example 6
Project: jdk7u-jdk-master  File: ResourcesMgr.java View source code
public static String getString(String s) {
    if (bundle == null) {
        // only load if/when needed
        bundle = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<java.util.ResourceBundle>() {

            public java.util.ResourceBundle run() {
                return (java.util.ResourceBundle.getBundle("sun.security.util.Resources"));
            }
        });
    }
    return bundle.getString(s);
}
Example 7
Project: ManagedRuntimeInitiative-master  File: ResourcesMgr.java View source code
public static String getString(String s) {
    if (bundle == null) {
        // only load if/when needed
        bundle = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<java.util.ResourceBundle>() {

            public java.util.ResourceBundle run() {
                return (java.util.ResourceBundle.getBundle("sun.security.util.Resources"));
            }
        });
    }
    return bundle.getString(s);
}
Example 8
Project: openjdk-master  File: ResourcesMgr.java View source code
public static String getString(String s) {
    if (bundle == null) {
        // only load if/when needed
        bundle = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<java.util.ResourceBundle>() {

            public java.util.ResourceBundle run() {
                return (java.util.ResourceBundle.getBundle("sun.security.util.Resources"));
            }
        });
    }
    return bundle.getString(s);
}
Example 9
Project: openjdk8-jdk-master  File: ResourcesMgr.java View source code
public static String getString(String s) {
    if (bundle == null) {
        // only load if/when needed
        bundle = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<java.util.ResourceBundle>() {

            public java.util.ResourceBundle run() {
                return (java.util.ResourceBundle.getBundle("sun.security.util.Resources"));
            }
        });
    }
    return bundle.getString(s);
}
Example 10
Project: jboss-seam-2.3.0.Final-Hibernate.3-master  File: ResourceLoader.java View source code
/**
    * Load a resource bundle by name (may be overridden by subclasses
    * who want to use non-standard resource bundle types).
    * 
    * @param bundleName the name of the resource bundle
    * @return an instance of java.util.ResourceBundle
    */
public java.util.ResourceBundle loadBundle(String bundleName) {
    try {
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(bundleName, Locale.instance(), Thread.currentThread().getContextClassLoader());
        // for getting bundle from page level message properties
        if (bundle == null) {
            bundle = java.util.ResourceBundle.getBundle(bundleName, Locale.instance(), ServletLifecycle.getCurrentServletContext().getClass().getClassLoader());
        }
        log.debug("loaded resource bundle: " + bundleName);
        return bundle;
    } catch (MissingResourceException mre) {
        log.debug("resource bundle missing: " + bundleName);
        return null;
    }
}
Example 11
Project: seam-2.2-master  File: ResourceLoader.java View source code
/**
    * Load a resource bundle by name (may be overridden by subclasses
    * who want to use non-standard resource bundle types).
    * 
    * @param bundleName the name of the resource bundle
    * @return an instance of java.util.ResourceBundle
    */
public java.util.ResourceBundle loadBundle(String bundleName) {
    try {
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(bundleName, Locale.instance(), Thread.currentThread().getContextClassLoader());
        // for getting bundle from page level message properties
        if (bundle == null) {
            bundle = java.util.ResourceBundle.getBundle(bundleName, Locale.instance(), ServletLifecycle.getCurrentServletContext().getClass().getClassLoader());
        }
        log.debug("loaded resource bundle: " + bundleName);
        return bundle;
    } catch (MissingResourceException mre) {
        log.debug("resource bundle missing: " + bundleName);
        return null;
    }
}
Example 12
Project: seam-revisited-master  File: ResourceLoader.java View source code
/**
    * Load a resource bundle by name (may be overridden by subclasses
    * who want to use non-standard resource bundle types).
    * 
    * @param bundleName the name of the resource bundle
    * @return an instance of java.util.ResourceBundle
    */
public java.util.ResourceBundle loadBundle(String bundleName) {
    try {
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(bundleName, Locale.instance(), Thread.currentThread().getContextClassLoader());
        // for getting bundle from page level message properties
        if (bundle == null) {
            bundle = java.util.ResourceBundle.getBundle(bundleName, Locale.instance(), ServletLifecycle.getCurrentServletContext().getClass().getClassLoader());
        }
        log.debug("loaded resource bundle: " + bundleName);
        return bundle;
    } catch (MissingResourceException mre) {
        log.debug("resource bundle missing: " + bundleName);
        return null;
    }
}
Example 13
Project: seam2jsf2-master  File: ResourceLoader.java View source code
/**
    * Load a resource bundle by name (may be overridden by subclasses
    * who want to use non-standard resource bundle types).
    * 
    * @param bundleName the name of the resource bundle
    * @return an instance of java.util.ResourceBundle
    */
public java.util.ResourceBundle loadBundle(String bundleName) {
    try {
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(bundleName, Locale.instance(), Thread.currentThread().getContextClassLoader());
        // for getting bundle from page level message properties
        if (bundle == null) {
            bundle = java.util.ResourceBundle.getBundle(bundleName, Locale.instance(), ServletLifecycle.getCurrentServletContext().getClass().getClassLoader());
        }
        log.debug("loaded resource bundle: " + bundleName);
        return bundle;
    } catch (MissingResourceException mre) {
        log.debug("resource bundle missing: " + bundleName);
        return null;
    }
}
Example 14
Project: taylor-seam-jsf2-master  File: ResourceLoader.java View source code
/**
    * Load a resource bundle by name (may be overridden by subclasses
    * who want to use non-standard resource bundle types).
    * 
    * @param bundleName the name of the resource bundle
    * @return an instance of java.util.ResourceBundle
    */
public java.util.ResourceBundle loadBundle(String bundleName) {
    try {
        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle(bundleName, Locale.instance(), Thread.currentThread().getContextClassLoader());
        // for getting bundle from page level message properties
        if (bundle == null) {
            bundle = java.util.ResourceBundle.getBundle(bundleName, Locale.instance(), ServletLifecycle.getCurrentServletContext().getClass().getClassLoader());
        }
        log.debug("loaded resource bundle: " + bundleName);
        return bundle;
    } catch (MissingResourceException mre) {
        log.debug("resource bundle missing: " + bundleName);
        return null;
    }
}
Example 15
Project: phoneme-components-cdc-master  File: ResourcesMgr.java View source code
public static String getString(String s) {
    if (bundle == null) {
        // only load if/when needed
        bundle = (java.util.ResourceBundle) java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {

            public Object run() {
                return (java.util.ResourceBundle.getBundle("sun.security.util.Resources"));
            }
        });
    }
    return bundle.getString(s);
}
Example 16
Project: beanfuse-master  File: BundleTextResourceTest.java View source code
@Test
public void testGetText() {
    Locale locale = new Locale("zh", "CN");
    ResourceBundle bundle = ResourceBundle.getBundle("message", locale);
    assertNotNull(bundle);
    BundleTextResource tr = new BundleTextResource();
    tr.setLocale(locale);
    tr.setBundle(bundle);
    assertEquals(tr.getText("hello.world"), "nihao");
}
Example 17
Project: classpath-doctor-master  File: DisplayClassPathFormatter.java View source code
public StringBuilder format(ClassPath cp, StringBuilder builder) {
    if (builder == null) {
        builder = new StringBuilder();
    }
    List<PathEntry> entries = cp.getEntries();
    if (entries.isEmpty()) {
        builder.append(ResourceBundle.getBundle("UsersMessages").getString("classpath.is.empty"));
    } else {
        builder.append(ResourceBundle.getBundle("UsersMessages").getString("classpath.entries.list")).append(LINE_SEPARATOR);
        for (PathEntry entry : entries) {
            builder.append(entry.toString()).append(LINE_SEPARATOR);
        }
    }
    return builder;
}
Example 18
Project: jKaiUI_Custom-master  File: MessengerMode.java View source code
protected JPopupMenu getPopupMenu(KaiObject obj) {
    JPopupMenu popup = new JPopupMenu();
    if (obj instanceof User) {
        User user = (User) obj;
        if (user.isOnline()) {
            String currentArena = user.getCurrentArena();
            jmiFollowUser = new JMenuItem(java.util.ResourceBundle.getBundle("pt/jkaiui/ui/Bundle").getString("LBL_FollowUser"));
            jmiFollowUser.setIcon(FOLLOW_ICON);
            jmiFollowUser.addActionListener(this);
            if (currentArena == null || currentArena.equals("") || !user.getCurrentArena().startsWith("Arena"))
                jmiFollowUser.setEnabled(false);
            popup.add(jmiFollowUser);
            jmiChat = new JMenuItem(java.util.ResourceBundle.getBundle("pt/jkaiui/ui/Bundle").getString("LBL_OpenChat"));
            jmiChat.setIcon(CHAT_ICON);
            jmiChat.addActionListener(this);
            popup.add(jmiChat);
        }
    }
    jmiUserProfile = new JMenuItem(java.util.ResourceBundle.getBundle("pt/jkaiui/ui/Bundle").getString("LBL_UserProfile"));
    jmiUserProfile.setIcon(USERPROFILE_ICON);
    popup.add(jmiUserProfile);
    jmiUserProfile.addActionListener(this);
    popup.addSeparator();
    jmiRemove = new JMenuItem(java.util.ResourceBundle.getBundle("pt/jkaiui/ui/Bundle").getString("LBL_RemoveBuddy"));
    jmiRemove.setIcon(DELETE_ICON);
    popup.add(jmiRemove);
    jmiRemove.addActionListener(this);
    return popup;
}
Example 19
Project: FreeRoute-master  File: PrintableShape.java View source code
public String toString() {
    java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", this.locale);
    String result = resources.getString("circle") + ": ";
    if (center.x != 0 || center.y != 0) {
        String center_string = resources.getString("center") + " =" + center.to_string(this.locale);
        result += center_string;
    }
    java.text.NumberFormat nf = java.text.NumberFormat.getInstance(this.locale);
    nf.setMaximumFractionDigits(4);
    String radius_string = resources.getString("radius") + " = " + nf.format((float) radius);
    result += radius_string;
    return result;
}
Example 20
Project: Freerouting-master  File: PrintableShape.java View source code
public String toString() {
    java.util.ResourceBundle resources = java.util.ResourceBundle.getBundle("board.resources.ObjectInfoPanel", this.locale);
    String result = resources.getString("circle") + ": ";
    if (center.x != 0 || center.y != 0) {
        String center_string = resources.getString("center") + " =" + center.to_string(this.locale);
        result += center_string;
    }
    java.text.NumberFormat nf = java.text.NumberFormat.getInstance(this.locale);
    nf.setMaximumFractionDigits(4);
    String radius_string = resources.getString("radius") + " = " + nf.format((float) radius);
    result += radius_string;
    return result;
}
Example 21
Project: PoCoTo-master  File: CloneConcordanceTopComponent.java View source code
@Override
public void actionPerformed(ActionEvent e) {
    NotifyDescriptor.InputLine d = new NotifyDescriptor.InputLine(java.util.ResourceBundle.getBundle("jav/concordance/Bundle").getString("newcand"), java.util.ResourceBundle.getBundle("jav/concordance/Bundle").getString("candidateRep"));
    String candidateString = tokens.get(tokens.keySet().iterator().next()).getCandidateString();
    d.setInputText(candidateString);
    Object retval = DialogDisplayer.getDefault().notify(d);
    if (retval.equals(NotifyDescriptor.OK_OPTION)) {
        candidateString = d.getInputText();
        if (!candidateString.equals("")) {
            for (ConcordanceEntry cce : tokens.values()) {
                if (!cce.isCorrected() & !cce.isDisabled()) {
                    cce.setCandidateString(candidateString);
                }
            }
            cp.setCandidateString(candidateString);
            if (!candidateString.equals("") && numSelected > 0) {
                jButton1.setEnabled(true);
            }
        }
    }
}
Example 22
Project: TumblrLikesViewer-master  File: MainViewGUI.java View source code
private JMenuBar createMenuBar() {
    JMenuBar jMenuBar = new JMenuBar();
    modeSelectMenu = new JMenu("...");
    modeSelectMenu.setEnabled(false);
    ButtonGroup modeSelectGroup = new ButtonGroup();
    modeItems = new LinkedHashMap<>();
    modeItems.put(DisplayModes.POSTS, new JRadioButtonMenuItem(java.util.ResourceBundle.getBundle("en_gb").getString("POSTS")));
    modeItems.put(DisplayModes.LIKES, new JRadioButtonMenuItem(java.util.ResourceBundle.getBundle("en_gb").getString("LIKES")));
    modeItems.put(DisplayModes.DASHBOARD, new JRadioButtonMenuItem(java.util.ResourceBundle.getBundle("en_gb").getString("DASHBOARD")));
    for (JRadioButtonMenuItem modeItem : modeItems.values()) {
        modeSelectGroup.add(modeItem);
        modeSelectMenu.add(modeItem);
        modeItem.addActionListener(new ModeSelectActionListener());
        modeItem.setEnabled(false);
    }
    avatarIconViewMenuItem = new JMenuItem();
    avatarIconViewMenuItem.setEnabled(false);
    avatarIconViewMenuItem.setIcon(loadingImageIcon);
    avatarIconViewMenuItem.addActionListener(new avatarIconViewMenuItemActionListener());
    modeSelectMenu.add(avatarIconViewMenuItem);
    followingOrNotMenu = new JMenu("...");
    followingOrNotMenu.setEnabled(false);
    followBlogMenuItem = new JMenuItem(java.util.ResourceBundle.getBundle("en_gb").getString("FOLLOW"));
    unfollowBlogMenuItem = new JMenuItem(java.util.ResourceBundle.getBundle("en_gb").getString("UNFOLLOW"));
    followBlogMenuItem.addActionListener(new FollowOrUnfollowMenuItemActionListener());
    unfollowBlogMenuItem.addActionListener(new FollowOrUnfollowMenuItemActionListener());
    followingOrNotMenu.add(followBlogMenuItem);
    followingOrNotMenu.add(unfollowBlogMenuItem);
    currentUserOptionsMenu = new JMenu(java.util.ResourceBundle.getBundle("en_gb").getString("GO TO"));
    currentUserOptionsMenu.setEnabled(false);
    //Will be replaced by users home blog
    currentUserGoToMenu = new JMenuItem("...");
    currentUserGoToMenu.addActionListener(new currentUserGoToMenuItemActionListener());
    currentUserFollowingMenu = new JMenu(java.util.ResourceBundle.getBundle("en_gb").getString("FOLLOWING"));
    currentUserFollowingMenu.setEnabled(false);
    currentUserFollowersMenu = new JMenu(java.util.ResourceBundle.getBundle("en_gb").getString("FOLLOWERS"));
    currentUserFollowersMenu.setEnabled(false);
    JMenuItem currentUserEnterBlogNameMenuItem = new JMenuItem(java.util.ResourceBundle.getBundle("en_gb").getString("ENTER BLOG NAME"));
    currentUserEnterBlogNameMenuItem.addActionListener(new EnterBlogNameMenuItemActionListener());
    currentUserOptionsMenu.add(currentUserGoToMenu);
    currentUserOptionsMenu.add(currentUserEnterBlogNameMenuItem);
    currentUserOptionsMenu.add(currentUserFollowingMenu);
    currentUserOptionsMenu.add(currentUserFollowersMenu);
    jMenuBar.add(modeSelectMenu);
    jMenuBar.add(currentUserOptionsMenu);
    jMenuBar.add(followingOrNotMenu);
    (new Thread(new RefreshControls(), "MainViewGUI Refresh Controls")).start();
    return jMenuBar;
}
Example 23
Project: BungeeAdminTools-master  File: UTF8_Control.java View source code
@Override
public ResourceBundle newBundle(final String baseName, final Locale locale, final String format, final ClassLoader loader, final boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    final String bundleName = toBundleName(baseName, locale);
    final String resourceName = toResourceName(bundleName, "language");
    ResourceBundle bundle = null;
    InputStream stream = null;
    if (reload) {
        final URL url = loader.getResource(resourceName);
        if (url != null) {
            final URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                stream = connection.getInputStream();
            }
        }
    } else {
        stream = loader.getResourceAsStream(resourceName);
    }
    if (stream != null) {
        try {
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
        } finally {
            stream.close();
        }
    }
    return bundle;
}
Example 24
Project: fastcatsearch-master  File: ResourceBundleControl.java View source code
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    // The below is a copy of the default implementation.
    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "txt");
    ResourceBundle bundle = null;
    InputStream stream = null;
    Enumeration<URL> resources = DynamicClassLoader.getResources(resourceName);
    URL url = null;
    for (; resources.hasMoreElements(); ) {
        url = resources.nextElement();
        if (url != null) {
            URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                stream = connection.getInputStream();
                break;
            }
        }
    }
    if (stream != null) {
        try {
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, charset));
        } finally {
            stream.close();
        }
    }
    return bundle;
}
Example 25
Project: gdl-tools-master  File: UTF8Control.java View source code
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    // The below is a copy of the default implementation.
    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "properties");
    ResourceBundle bundle = null;
    InputStream stream = null;
    if (reload) {
        URL url = loader.getResource(resourceName);
        if (url != null) {
            URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                stream = connection.getInputStream();
            }
        }
    } else {
        stream = loader.getResourceAsStream(resourceName);
    }
    if (stream != null) {
        try {
            // Only this line is changed to make it to read properties files as UTF-8.
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
        } finally {
            stream.close();
        }
    }
    return bundle;
}
Example 26
Project: mmlTools-master  File: ResourceLoader.java View source code
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "properties");
    InputStream stream = new FileInputStream("properties/" + resourceName);
    ResourceBundle resource = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
    stream.close();
    return resource;
}
Example 27
Project: polly-master  File: UTF8Control.java View source code
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    // The below is a copy of the default implementation.
    final String bundleName = toBundleName(baseName, locale);
    //$NON-NLS-1$
    final String resourceName = toResourceName(bundleName, "properties");
    ResourceBundle bundle = null;
    InputStream stream = null;
    if (reload) {
        URL url = loader.getResource(resourceName);
        if (url != null) {
            URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                stream = connection.getInputStream();
            }
        }
    } else {
        stream = loader.getResourceAsStream(resourceName);
    }
    if (stream != null) {
        try {
            // Only this line is changed to make it to read properties files as UTF-8.
            bundle = new PropertyResourceBundle(//$NON-NLS-1$
            new InputStreamReader(stream, "UTF-8"));
        } finally {
            stream.close();
        }
    }
    return bundle;
}
Example 28
Project: android-libcore64-master  File: P.java View source code
private String findProp(Class cls, String key) {
    String ret = null;
    try {
        ResourceBundle b = ResourceBundle.getBundle(cls.getName());
        ret = (String) b.getObject(key);
    } catch (Exception e) {
    }
    if (ret == null && !cls.equals(Object.class) && !cls.isPrimitive()) {
        ret = findProp(cls.getSuperclass(), key);
    }
    return ret;
}
Example 29
Project: android-sdk-sources-for-api-level-23-master  File: ControlTest.java View source code
/**
     * {@link java.util.ResourceBundle.Control#getCandidateLocales(java.lang.String, java.util.Locale)}.
     */
@SuppressWarnings("nls")
public void test_getCandidateLocales_LStringLLocale() {
    // the ResourceBundle for this baseName and Locale does not exists
    List<Locale> result = control.getCandidateLocales("baseName", new Locale("one", "two", "three"));
    assertEquals(4, result.size());
    Locale locale = result.get(0);
    assertEquals("one", locale.getLanguage());
    assertEquals("TWO", locale.getCountry());
    assertEquals("three", locale.getVariant());
    assertEquals(new Locale("one", "TWO"), result.get(1));
    assertEquals(new Locale("one"), result.get(2));
    assertSame(Locale.ROOT, result.get(3));
    // ArrayList is not immutable
    assertTrue(ArrayList.class == result.getClass());
    result = control.getCandidateLocales("baseName", new Locale("one", "two", ""));
    assertEquals(new Locale("one", "TWO"), result.get(0));
    assertEquals(new Locale("one"), result.get(1));
    assertSame(Locale.ROOT, result.get(2));
    result = control.getCandidateLocales("baseName", new Locale("one", "", "three"));
    assertEquals(new Locale("one", "", "three"), result.get(0));
    assertEquals(new Locale("one"), result.get(1));
    assertSame(Locale.ROOT, result.get(2));
    result = control.getCandidateLocales("baseName", new Locale("", "two", "three"));
    assertEquals(new Locale("", "TWO", "three"), result.get(0));
    assertEquals(new Locale("", "TWO"), result.get(1));
    assertSame(Locale.ROOT, result.get(2));
    result = control.getCandidateLocales("baseName", new Locale("", "", "three"));
    assertEquals(new Locale("", "", "three"), result.get(0));
    assertSame(Locale.ROOT, result.get(1));
    result = control.getCandidateLocales("baseName", new Locale("", "two", ""));
    assertEquals(new Locale("", "TWO"), result.get(0));
    assertSame(Locale.ROOT, result.get(1));
    result = control.getCandidateLocales("baseName", Locale.ROOT);
    assertSame(Locale.ROOT, result.get(0));
    try {
        control.getCandidateLocales(null, Locale.US);
        fail("Should throw NullPointerException");
    } catch (NullPointerException e) {
    }
    try {
        control.getCandidateLocales("baseName", null);
        fail("Should throw NullPointerException");
    } catch (NullPointerException e) {
    }
}
Example 30
Project: android_libcore-master  File: P.java View source code
private String findProp(Class cls, String key) {
    String ret = null;
    try {
        ResourceBundle b = ResourceBundle.getBundle(cls.getName());
        ret = (String) b.getObject(key);
    } catch (Exception e) {
    }
    if (ret == null && !cls.equals(Object.class) && !cls.isPrimitive()) {
        ret = findProp(cls.getSuperclass(), key);
    }
    return ret;
}
Example 31
Project: android_platform_libcore-master  File: P.java View source code
private String findProp(Class cls, String key) {
    String ret = null;
    try {
        ResourceBundle b = ResourceBundle.getBundle(cls.getName());
        ret = (String) b.getObject(key);
    } catch (Exception e) {
    }
    if (ret == null && !cls.equals(Object.class) && !cls.isPrimitive()) {
        ret = findProp(cls.getSuperclass(), key);
    }
    return ret;
}
Example 32
Project: ARTPart-master  File: ControlTest.java View source code
/**
     * {@link java.util.ResourceBundle.Control#getCandidateLocales(java.lang.String, java.util.Locale)}.
     */
@SuppressWarnings("nls")
public void test_getCandidateLocales_LStringLLocale() {
    // the ResourceBundle for this baseName and Locale does not exists
    List<Locale> result = control.getCandidateLocales("baseName", new Locale("one", "two", "three"));
    assertEquals(4, result.size());
    Locale locale = result.get(0);
    assertEquals("one", locale.getLanguage());
    assertEquals("TWO", locale.getCountry());
    assertEquals("three", locale.getVariant());
    assertEquals(new Locale("one", "TWO"), result.get(1));
    assertEquals(new Locale("one"), result.get(2));
    assertSame(Locale.ROOT, result.get(3));
    // ArrayList is not immutable
    assertTrue(ArrayList.class == result.getClass());
    result = control.getCandidateLocales("baseName", new Locale("one", "two", ""));
    assertEquals(new Locale("one", "TWO"), result.get(0));
    assertEquals(new Locale("one"), result.get(1));
    assertSame(Locale.ROOT, result.get(2));
    result = control.getCandidateLocales("baseName", new Locale("one", "", "three"));
    assertEquals(new Locale("one", "", "three"), result.get(0));
    assertEquals(new Locale("one"), result.get(1));
    assertSame(Locale.ROOT, result.get(2));
    result = control.getCandidateLocales("baseName", new Locale("", "two", "three"));
    assertEquals(new Locale("", "TWO", "three"), result.get(0));
    assertEquals(new Locale("", "TWO"), result.get(1));
    assertSame(Locale.ROOT, result.get(2));
    result = control.getCandidateLocales("baseName", new Locale("", "", "three"));
    assertEquals(new Locale("", "", "three"), result.get(0));
    assertSame(Locale.ROOT, result.get(1));
    result = control.getCandidateLocales("baseName", new Locale("", "two", ""));
    assertEquals(new Locale("", "TWO"), result.get(0));
    assertSame(Locale.ROOT, result.get(1));
    result = control.getCandidateLocales("baseName", Locale.ROOT);
    assertSame(Locale.ROOT, result.get(0));
    try {
        control.getCandidateLocales(null, Locale.US);
        fail("Should throw NullPointerException");
    } catch (NullPointerException e) {
    }
    try {
        control.getCandidateLocales("baseName", null);
        fail("Should throw NullPointerException");
    } catch (NullPointerException e) {
    }
}
Example 33
Project: Aspose_Cells_Java-master  File: CreateMavenProjectCallback.java View source code
@Override
public boolean executeTask(@NotNull ProgressIndicator progressIndicator) {
    progressIndicator.setIndeterminate(true);
    progressIndicator.setText(ResourceBundle.getBundle("Bundle").getString("AsposeManager.projectMessage"));
    AsposeMavenProjectManager comManager = AsposeMavenProjectManager.getInstance();
    return comManager.retrieveAsposeMavenDependencies(progressIndicator);
}
Example 34
Project: Aspose_Words_Java-master  File: CreateMavenProjectCallback.java View source code
@Override
public boolean executeTask(@NotNull ProgressIndicator progressIndicator) {
    progressIndicator.setIndeterminate(true);
    progressIndicator.setText(ResourceBundle.getBundle("Bundle").getString("AsposeManager.projectMessage"));
    AsposeMavenProjectManager comManager = AsposeMavenProjectManager.getInstance();
    return comManager.retrieveAsposeMavenDependencies(progressIndicator);
}
Example 35
Project: elexis-3-core-master  File: LocalizeUtil.java View source code
/**
	 * Use with EMF generated not instances of {@link ILocalizedEnum}. Get the localized String for
	 * the {@link Enumerator}.
	 * 
	 * @param enumerator
	 * @return
	 */
public static String getLocaleText(Enumerator enumerator) {
    if (enumerator != null) {
        try {
            return ResourceBundle.getBundle("ch.elexis.core.types.messages").getString(enumerator.getClass().getSimpleName() + "." + enumerator.getName());
        } catch (Exception e) {
            return enumerator.getName();
        }
    }
    return "?";
}
Example 36
Project: JavaSE6Tutorial-master  File: MessageFormatDemo.java View source code
public static void main(String[] args) {
    try {
        // �定messages.properties
        ResourceBundle resource = ResourceBundle.getBundle("messages2");
        String message = resource.getString("onlyfun.caterpillar.greeting");
        Object[] params = new Object[] { args[0], args[1] };
        MessageFormat formatter = new MessageFormat(message);
        // 顯示格�化後的訊�
        System.out.println(formatter.format(params));
    } catch (ArrayIndexOutOfBoundsException e) {
        System.out.println("沒有指定引數");
    }
}
Example 37
Project: oripa-master  File: ChangeHint.java View source code
@Override
public void changeViewSetting() {
    ResourceHolder holder = ResourceHolder.getInstance();
    ResourceBundle resource = holder.getResource(ResourceKey.EXPLANATION);
    String hint = null;
    try {
        hint = resource.getString(id);
    } catch (Exception e) {
    }
    frameSetting.setHint(hint);
    frameSetting.notifyObservers();
}
Example 38
Project: robovm-master  File: P.java View source code
private String findProp(Class cls, String key) {
    String ret = null;
    try {
        ResourceBundle b = ResourceBundle.getBundle(cls.getName());
        ret = (String) b.getObject(key);
    } catch (Exception e) {
    }
    if (ret == null && !cls.equals(Object.class) && !cls.isPrimitive()) {
        ret = findProp(cls.getSuperclass(), key);
    }
    return ret;
}
Example 39
Project: TechnologyReadinessTool-master  File: CoreResourceBundleMessageSource.java View source code
@Override
protected ResourceBundle doGetBundle(String basename, Locale locale) throws MissingResourceException {
    ResourceBundle bundleToWrap = super.doGetBundle(basename, locale);
    String[] names = applicationContext.getBeanNamesForType(DatabaseResourceBundleImpl.class);
    if (names != null && names.length > 0) {
        bundleToWrap = (DatabaseResourceBundleImpl) applicationContext.getBean(names[0], bundleToWrap);
    }
    return new ELAwareResourceBundle(bundleToWrap);
}
Example 40
Project: tutorial-master  File: MessageFormatDemo.java View source code
public static void main(String[] args) {
    try {
        // �定messages.properties
        ResourceBundle resource = ResourceBundle.getBundle("messages2");
        String message = resource.getString("onlyfun.caterpillar.greeting");
        Object[] params = new Object[] { args[0], args[1] };
        MessageFormat formatter = new MessageFormat(message);
        // 顯示格�化後的訊�
        System.out.println(formatter.format(params));
    } catch (ArrayIndexOutOfBoundsException e) {
        System.out.println("沒有指定引數");
    }
}
Example 41
Project: vraptor-i18n-master  File: I18nRoutesResourceTest.java View source code
@Test
public void shouldReturnResourceBundlePtBR() {
    bundles.bindResourcesBundle();
    List<ResourceBundle> availableBundles = bundles.getAvailableBundles();
    ResourceBundle resourceBundle = availableBundles.get(0);
    assertEquals(availableBundles.size(), 1);
    assertEquals(resourceBundle.getLocale().getLanguage(), "pt");
    assertEquals(resourceBundle.getLocale().getCountry(), "BR");
    assertEquals(resourceBundle.getString("/absolutePath"), "/absoluto");
}
Example 42
Project: jpexs-decompiler-master  File: ScriptRunnerAction.java View source code
@Override
public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) {
    try {
        ScriptEngine eng = getEngine(target);
        if (eng != null) {
            getEngine(target).eval(target.getText());
        }
    } catch (ScriptException ex) {
        JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(target), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptRunnerAction.ErrorExecutingScript") + ex.getMessage(), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptRunnerAction.ScriptError"), JOptionPane.ERROR_MESSAGE);
        ActionUtils.setCaretPosition(target, ex.getLineNumber(), ex.getColumnNumber());
    }
}
Example 43
Project: jsyntaxpane-master  File: ScriptRunnerAction.java View source code
@Override
public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) {
    try {
        ScriptEngine eng = getEngine(target);
        if (eng != null) {
            getEngine(target).eval(target.getText());
        }
    } catch (ScriptException ex) {
        JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(target), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptRunnerAction.ErrorExecutingScript") + ex.getMessage(), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptRunnerAction.ScriptError"), JOptionPane.ERROR_MESSAGE);
        ActionUtils.setCaretPosition(target, ex.getLineNumber(), ex.getColumnNumber());
    }
}
Example 44
Project: jvm-tools-master  File: FilterParserCorpusTest.java View source code
@Parameters(name = "\"{0}\" {1}")
public static List<Object[]> getExpressions() {
    addCase(10912, "**");
    addCase(10912, "org.apache.catalina.connector.CoyoteAdapter.service");
    addCase(1467, "**.CoyoteAdapter.service+org.jboss.jca.adapters.jdbc,javax.jdbc");
    addCase(2891, "**.CoyoteAdapter.service+org.hibernate.internal.SessionImpl.autoFlushIfRequired");
    addCase(2605, "**.CoyoteAdapter.service+org.hibernate.internal.SessionImpl.autoFlushIfRequired!org.jboss.jca.adapters.jdbc,javax.jdbc");
    addCase(439, "**.CoyoteAdapter.service+org.hibernate.!org.hibernate.internal.SessionImpl.autoFlushIfRequired!org.jboss.jca.adapters.jdbc,javax.jdbc");
    addCase(1544, "**.CoyoteAdapter.service+com.sun.faces.facelets.compiler.Compiler.compile");
    addCase(1287, "**.CoyoteAdapter.service+javax.xml.");
    addCase(38, "**.CoyoteAdapter.service+javax.xml.!com.sun.faces.facelets.compiler.Compiler.compile");
    addCase(256, "**.CoyoteAdapter.service+java.util.ResourceBundle.getObject*ResourceBundle.java:395");
    addCase(256, "**.CoyoteAdapter.service+java.util.ResourceBundle.getObject*:395");
    addCase(933, "**.CoyoteAdapter.service+java.util.ResourceBundle.getObject");
    addCase(677, "**.CoyoteAdapter.service+java.util.ResourceBundle.getObject!java.util.ResourceBundle.getObject*:395");
    addCase(3584, "**.CoyoteAdapter.service+org.jboss.seam.core.BijectionInterceptor.aroundInvoke,org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke+**.proceed");
    addCase(0, "**.CoyoteAdapter.service+org.jboss.seam.core.BijectionInterceptor.aroundInvoke,org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke!**.proceed");
    addCase(1362, "**.CoyoteAdapter.service+org.jboss.seam.core.BijectionInterceptor.aroundInvoke,org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke/!**.proceed");
    addCase(934, "**.CoyoteAdapter.service+org.jboss.seam.core.BijectionInterceptor.aroundInvoke,org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke/!**.proceed+org.jboss.seam.Component.*ject");
    addCase(428, "**.CoyoteAdapter.service+org.jboss.seam.core.BijectionInterceptor.aroundInvoke,org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke/!**.proceed+java.util.concurrent.locks.ReentrantLock");
    addCase(2891, "org.hibernate/^+**.onAutoFlush");
    addCase(1542, "org.hibernate/^!**.onAutoFlush");
    return cases;
}
Example 45
Project: kevoree-master  File: ScriptRunnerAction.java View source code
@Override
public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) {
    try {
        ScriptEngine eng = getEngine(target);
        if (eng != null) {
            getEngine(target).eval(target.getText());
        }
    } catch (ScriptException ex) {
        JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(target), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptRunnerAction.ErrorExecutingScript") + ex.getMessage(), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptRunnerAction.ScriptError"), JOptionPane.ERROR_MESSAGE);
        ActionUtils.setCaretPosition(target, ex.getLineNumber(), ex.getColumnNumber());
    }
}
Example 46
Project: Scute-master  File: ScriptRunnerAction.java View source code
@Override
public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) {
    try {
        ScriptEngine eng = getEngine(target);
        if (eng != null) {
            getEngine(target).eval(target.getText());
        }
    } catch (ScriptException ex) {
        JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(target), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptRunnerAction.ErrorExecutingScript") + ex.getMessage(), java.util.ResourceBundle.getBundle("jsyntaxpane/Bundle").getString("ScriptRunnerAction.ScriptError"), JOptionPane.ERROR_MESSAGE);
        ActionUtils.setCaretPosition(target, ex.getLineNumber(), ex.getColumnNumber());
    }
}
Example 47
Project: SyntaxPane-master  File: ScriptRunnerAction.java View source code
@Override
public void actionPerformed(JTextComponent target, SyntaxDocument sDoc, int dot, ActionEvent e) {
    try {
        ScriptEngine eng = getEngine(target);
        if (eng != null) {
            getEngine(target).eval(target.getText());
        }
    } catch (ScriptException ex) {
        JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(target), java.util.ResourceBundle.getBundle("de/sciss/syntaxpane/Bundle").getString("ScriptRunnerAction.ErrorExecutingScript") + ex.getMessage(), java.util.ResourceBundle.getBundle("de/sciss/syntaxpane/Bundle").getString("ScriptRunnerAction.ScriptError"), JOptionPane.ERROR_MESSAGE);
        ActionUtils.setCaretPosition(target, ex.getLineNumber(), ex.getColumnNumber());
    }
}
Example 48
Project: confeito-master  File: ResourceBundleUtil.java View source code
/**
	 * <#if locale="en">
	 * <p>
	 * Get {@link ResourceBundle} without caching.If
	 * {@link MissingResourceException} throws, simply return null.
	 * 
	 * </p>
	 * <#else>
	 * <p>
	 * 
	 * </p>
	 * </#if>
	 * 
	 * @param bundleName
	 * @param locale
	 * @param loader
	 * @return
	 */
public static ResourceBundle getBundleNoCache(String bundleName, Locale locale, ClassLoader loader) {
    try {
        return ResourceBundle.getBundle(bundleName, locale, loader, new ResourceBundle.Control() {

            @Override
            public long getTimeToLive(String baseName, Locale locale) {
                return Control.TTL_DONT_CACHE;
            }
        });
    } catch (MissingResourceException e) {
        return null;
    }
}
Example 49
Project: aem-id-googlesearch-master  File: Functions.java View source code
public static String Translate(Page currentPage, SlingHttpServletRequest slingRequest, String value) {
    if (!"".equals(value)) {
        Locale pageLocale = currentPage.getLanguage(false);
        //Locale myLocale = new Locale("fr");  
        ResourceBundle resourceBundle = slingRequest.getResourceBundle(pageLocale);
        I18n i18n = new I18n(resourceBundle);
        //			I18n i18n = new I18n(slingRequest);
        return i18n.get(value);
    //return i18n.get(value);
    }
    return "";
}
Example 50
Project: behave-master  File: UserBC.java View source code
public User find(String login, String password) {
    try {
        if (bundle == null) {
            bundle = ResourceBundle.getBundle("treino_login");
        }
        String senha = bundle.getString(login);
        if (senha != null && senha.equals(password)) {
            return new User(login, password);
        } else {
            throw new TestGridException(ErrorMessage.USER_LOGIN);
        }
    } catch (MissingResourceException e) {
        throw new TestGridException(ErrorMessage.USER_LOGIN);
    }
}
Example 51
Project: caelum-stella-master  File: StellaMessagesTest.java View source code
@Test
public void deveConterMensagensPadraoParaTodosOsErrosPossiveis() throws Exception {
    Locale locale = new Locale("pt", "BR");
    ResourceBundle messages = ResourceBundle.getBundle("StellaMessages", locale);
    ResourceBundleMessageProducer producer = new ResourceBundleMessageProducer(messages);
    for (Class c : ERROR_CLASSES) {
        InvalidValue[] errors = (InvalidValue[]) c.getMethod("values").invoke(null);
        for (InvalidValue error : errors) {
            String errorKey = producer.messageKeyFor(locale, c, error);
            assertNotNull(messages.getString(errorKey));
        }
    }
}
Example 52
Project: cfmap-master  File: Messages.java View source code
// METHODS ........................................................
public static String getString(String key) {
    if (RESOURCE_BUNDLE == null) {
        if (System.getenv("propertyfile") != null) {
            RESOURCE_BUNDLE = ResourceBundle.getBundle(System.getenv("propertyfile"));
        } else {
            RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
        }
    }
    // System.out.println(" === " + System.getProperty("user.dir"));
    try {
        // RESOURCE_BUNDLE.getString(key)+": "+key);
        return RESOURCE_BUNDLE.getString(key);
    } catch (MissingResourceException e) {
        System.out.println("resource not found: " + key);
        return null;
    }
}
Example 53
Project: chartsy-master  File: PredefinedIndicators.java View source code
public static Collection<IndexedIndicator> getIndicators() {
    Collection<IndexedIndicator> indicators = new ArrayList<IndexedIndicator>();
    ResourceBundle bundle = ResourceBundle.getBundle("org.chartsy.stockscanpro.completion.predefined");
    Enumeration<String> keys = bundle.getKeys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        String[] params = bundle.getString(key).split(":");
        indicators.add(createIndicator(key, params[0].equals("null") ? "" : params[0], Boolean.parseBoolean(params[1]), false));
        indicators.add(createIndicator(key, params[0].equals("null") ? "" : params[0], Boolean.parseBoolean(params[1]), true));
    }
    return indicators;
}
Example 54
Project: collect-bad-master  File: CrawlLauncher.java View source code
private static void run(String bundleName) {
    ResourceBundle parametersBundle = ResourceBundle.getBundle(bundleName);
    SlurpManager slurpManager = new SlurpManagerImpl();
    String url = parametersBundle.getString("url");
    String scope = parametersBundle.getString("scope");
    if (!url.isEmpty()) {
        try {
            System.out.println(slurpManager.create(url, CrawlScope.valueOf(scope), ""));
        } catch (WebarchiveCreationException ex) {
            Logger.getLogger(CrawlLauncher.class.getName()).log(Level.WARNING, null, ex);
        }
    }
}
Example 55
Project: cucumber-jvm-master  File: ReadInjectionProviderClassNames.java View source code
public final Set<String> apply(final ResourceBundle resourceBundle) {
    final LinkedHashSet<String> result = new LinkedHashSet<String>();
    if (resourceBundle != null && resourceBundle.containsKey(CUSTOM_INJECTION_PROVIDER_CLASSES)) {
        final String csvProperty = resourceBundle.getString(CUSTOM_INJECTION_PROVIDER_CLASSES);
        for (final String className : csvProperty.split(",")) {
            if (className != null) {
                final String trim = className.trim();
                if (!"".equals(trim)) {
                    result.add(trim);
                }
            }
        }
    }
    return result;
}
Example 56
Project: es6draft-master  File: PropertiesReaderControl.java View source code
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IOException {
    if ("java.properties".equals(format)) {
        String bundleName = toBundleName(baseName, locale);
        String resourceName = toResourceName(bundleName, "properties");
        InputStream stream = getInputStream(loader, resourceName, reload);
        if (stream == null) {
            return null;
        }
        try (Reader reader = new InputStreamReader(stream, charset)) {
            return new PropertyResourceBundle(reader);
        }
    }
    throw new IllegalArgumentException("unknown format: " + format);
}
Example 57
Project: floaty-field-master  File: FloatyFieldAppView.java View source code
public void initialize(URL url, ResourceBundle r) {
    titleFieldController.promptTextProperty().set("Title");
    priceFieldController.promptTextProperty().set("Price");
    locationFieldController.promptTextProperty().set("Specific Location (optional)");
    descriptionFieldController.promptTextProperty().set("Description");
    List<StringProperty> asList = Arrays.asList(titleFieldController.textProperty(), priceFieldController.textProperty(), locationFieldController.textProperty(), descriptionFieldController.textProperty());
    rewinder = new TextRewinder(asList);
}
Example 58
Project: i18n.generator-master  File: I18NSupport.java View source code
private ResourceBundle getLocalizedBundle() {
    if (localeProvider == null) {
        return ResourceBundle.getBundle(getBundleName());
    }
    Locale locale = localeProvider.get();
    if (locale == null) {
        return ResourceBundle.getBundle(getBundleName());
    }
    return ResourceBundle.getBundle(getBundleName(), locale);
}
Example 59
Project: javardices-master  File: PropertyReader.java View source code
public void read(ResourceBundle bundle) {
    Properties p = System.getProperties();
    Enumeration<String> keys = bundle.getKeys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        if (!p.containsKey(key)) {
            p.put(key, bundle.getString(key));
        }
    }
    System.setProperties(p);
}
Example 60
Project: jucy-master  File: NLS.java View source code
public static void load(String bundleName, Class<?> clazz) {
    ResourceBundle rb = ResourceBundle.getBundle(bundleName, Locale.getDefault(), clazz.getClassLoader());
    ResourceBundle rbDefault = null;
    final Field[] fieldArray = clazz.getDeclaredFields();
    for (Field f : fieldArray) {
        String name = f.getName();
        String translation = null;
        try {
            translation = rb.getString(name);
        } catch (MissingResourceException mre) {
            if (rbDefault == null) {
                rbDefault = ResourceBundle.getBundle(bundleName, Locale.ENGLISH, clazz.getClassLoader());
            }
            translation = rb.getString(name);
        }
        if (translation == null) {
            throw new MissingResourceException("Not found res", clazz.getCanonicalName(), name);
        }
        try {
            f.set(null, translation);
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
Example 61
Project: MATLAB-Server-Pages-master  File: uploadBean.java View source code
public String pass() {
    try {
        ResourceBundle rb;
        try {
            rb = ResourceBundle.getBundle("MSP");
        } catch (Exception ex) {
            rb = ResourceBundle.getBundle("MSPRMI");
        }
        String Code_Dir = rb.getString("Code_directory");
        String fullpath = Code_Dir + "\\" + "uploadedFile.m";
        FileOutputStream fo = new FileOutputStream(fullpath);
        fo.write(matlabFile.getBytes());
        return "PASS";
    } catch (IOException e) {
        e.printStackTrace();
        return "FAIL";
    }
}
Example 62
Project: muikku-master  File: TimedNotificationsPluginDescriptor.java View source code
@Override
public List<LocaleBundle> getLocaleBundles() {
    return Arrays.asList(new LocaleBundle(LocaleLocation.APPLICATION, ResourceBundle.getBundle("fi.otavanopisto.muikku.plugins.timednotifications.TimedNotificationsPluginMessages", LocaleUtils.toLocale("fi"))), new LocaleBundle(LocaleLocation.APPLICATION, ResourceBundle.getBundle("fi.otavanopisto.muikku.plugins.timednotifications.TimedNotificationsPluginMessages", LocaleUtils.toLocale("en"))));
}
Example 63
Project: Netuno-master  File: TrimValidator.java View source code
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
    if (value != null) {
        String valor = value.toString();
        if (valor.trim().equals("")) {
            ResourceBundle bundle = context.getApplication().getResourceBundle(context, "contratacaoMsg");
            FacesMessage msg = new FacesMessage(bundle.getString("trimValidator.erro"));
            msg.setSeverity(FacesMessage.SEVERITY_ERROR);
            throw new ValidatorException(msg);
        }
    }
}
Example 64
Project: ngilasp-master  File: DbResourceUtil.java View source code
/**
     *
     * @return
     */
public static DbProperties getDbProperties() {
    ResourceBundle bundle = ResourceBundle.getBundle("Database.Connections.db");
    String username = bundle.getString("username");
    String password = bundle.getString("password");
    String dbUrl = bundle.getString("db_url");
    String driverClass = bundle.getString("driver_class");
    String minConnections = bundle.getString("min_connections");
    String maxConnections = bundle.getString("max_connections");
    String maxIdleTime = bundle.getString("max_idle_time");
    if (minConnections == null || maxConnections == null) {
        return new DbProperties(username, password, dbUrl, driverClass);
    }
    return new DbProperties(username, password, dbUrl, driverClass, new ConnectionProperties(Integer.parseInt(minConnections), Integer.parseInt(maxConnections), Integer.parseInt(maxIdleTime)));
}
Example 65
Project: OpenDolphin-master  File: AccountMakerView.java View source code
/**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    accountMakeBtn = new javax.swing.JButton();
    // NOI18N
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("open/dolphin/project/resources/AccountMakerView");
    // NOI18N
    setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("jPanel.borderTitle")));
    // NOI18N
    accountMakeBtn.setText(bundle.getString("accountMakeBtn.text"));
    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup().addContainerGap(92, Short.MAX_VALUE).add(accountMakeBtn).addContainerGap(93, Short.MAX_VALUE)));
    layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(layout.createSequentialGroup().addContainerGap().add(accountMakeBtn).addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
}
Example 66
Project: partyplayer-master  File: TestGui.java View source code
public static void main(String[] args) {
    Library lib;
    try {
        lib = new Library(new File(System.getProperty("user.dir") + "/music"));
        Player player = new Player();
        Properties settings = new Properties();
        ResourceBundle bundle = ResourceBundle.getBundle("resources.lang");
        LibraryFrame frame = new LibraryFrame(lib, player, settings, bundle);
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Example 67
Project: pentaho-platform-master  File: AbstractAuthorizationAction.java View source code
protected ResourceBundle getResourceBundle(String localeString) {
    //$NON-NLS-1$
    final String UNDERSCORE = "_";
    Locale locale;
    if (localeString == null) {
        return Messages.getInstance().getBundle();
    } else {
        String[] tokens = localeString.split(UNDERSCORE);
        if (tokens.length == 3) {
            locale = new Locale(tokens[0], tokens[1], tokens[2]);
        } else if (tokens.length == 2) {
            locale = new Locale(tokens[0], tokens[1]);
        } else {
            locale = new Locale(tokens[0]);
        }
        return Messages.getInstance().getBundle(locale);
    }
}
Example 68
Project: salesforce-plugin-master  File: SalesForceBundle.java View source code
private static ResourceBundle getBundle() {
    ResourceBundle bundle;
    if (SalesForceBundle.bundle == null) {
        bundle = ResourceBundle.getBundle(BUNDLE_NAME);
        SalesForceBundle.bundle = new SoftReference<ResourceBundle>(bundle);
    } else {
        bundle = SalesForceBundle.bundle.get();
    }
    return bundle;
}
Example 69
Project: seeur-master  File: RegexSummaryController.java View source code
@Override
public void initialize(URL location, ResourceBundle resources) {
    try {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(ClassLoader.getSystemResourceAsStream("seeurrenamer/main/resources/text/regex_summary.txt")));
        this.regexSummaryTextArea.setText(bufferedReader.lines().collect(Collectors.joining("\n")));
        bufferedReader.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Example 70
Project: SnakeFX-master  File: PanelView.java View source code
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
    points.textProperty().bind(viewModel.pointsLabelText());
    playPause.textProperty().bind(viewModel.playPauseButtonText());
    playPause.disableProperty().bind(viewModel.playPauseButtonDisabled());
    speed.getItems().addAll(viewModel.speedLevels());
    speed.valueProperty().bindBidirectional(viewModel.selectedSpeedLevel());
    speed.getSelectionModel().selectFirst();
}
Example 71
Project: violetumleditor-master  File: ResourceManager.java View source code
public final String getString(String key) {
    while (true) {
        for (ResourceBundle resourceBundle : resourceBundles) {
            try {
                return resourceBundle.getString(key);
            } catch (Exception ignored) {
            }
        }
        int indexOfSeparator = key.indexOf('.');
        if (-1 == indexOfSeparator) {
            break;
        }
        key = key.substring(indexOfSeparator + 1);
    }
    return key;
}
Example 72
Project: vraptor-master  File: MessageSerializerTest.java View source code
@Test
public void shouldSerializeI18nMessage() {
    String expectedResult = "{\"category\":\"validation\",\"message\":\"you are underage\"}";
    I18nMessage message = new I18nMessage("validation", "underage");
    message.setBundle(ResourceBundle.getBundle("messages"));
    JsonElement jsonElement = new MessageSerializer().serialize(message, mock(Type.class), mock(JsonSerializationContext.class));
    assertEquals(expectedResult, jsonElement.getAsJsonObject().toString());
}
Example 73
Project: vraptor2_sexy_urls-master  File: ValidatorLocatorTest.java View source code
public void testGrabsTheCachedValidator() {
    ValidatorLocator loc = new ValidatorLocator();
    ClassValidator<ValidatorLocatorTest> validator = loc.getValidator(ValidatorLocatorTest.class, ResourceBundle.getBundle("messages"));
    ClassValidator<ValidatorLocatorTest> validator2 = loc.getValidator(ValidatorLocatorTest.class, ResourceBundle.getBundle("messages"));
    assertEquals(validator, validator2);
}
Example 74
Project: webpie-master  File: Messages.java View source code
public String get(String key, Locale locale) {
    //TODO: We need to fix this so we are not throwing exceptions when bundles are not found
    if (bundleName != null) {
        try {
            ResourceBundle b = ResourceBundleUtf8.load(bundleName, locale);
            String value = b.getString(key);
            if (value != null)
                return value;
        } catch (MissingResourceException e) {
        }
    }
    try {
        ResourceBundle global = ResourceBundleUtf8.load(globalBundleName, locale);
        return global.getString(key);
    } catch (MissingResourceException e) {
        return null;
    }
}
Example 75
Project: micro-master  File: ResourceBundleMessageSource.java View source code
/**
     * Resolves the given message code as key in the registered resource bundles,
     * returning the value found in the bundle as-is (without MessageFormat parsing).
     */
protected String resolveCodeWithoutArguments(String code, Locale locale) {
    String result = null;
    for (int i = 0; result == null && i < this.basenames.length; i++) {
        ResourceBundle bundle = getResourceBundle(this.basenames[i], locale);
        if (bundle != null) {
            result = getStringOrNull(bundle, code);
        }
    }
    return result;
}
Example 76
Project: bladecoder-adventure-engine-master  File: I18NControl.java View source code
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "properties");
    ResourceBundle bundle = null;
    InputStream inputStream = null;
    FileHandle fileHandle = EngineAssetManager.getInstance().getAsset(resourceName);
    if (FileUtils.exists(fileHandle)) {
        try {
            // inputStream = loader.getResourceAsStream(resourceName);
            inputStream = fileHandle.read();
            bundle = new PropertyResourceBundle(new InputStreamReader(inputStream, encoding));
        } finally {
            if (inputStream != null)
                inputStream.close();
        }
    }
    return bundle;
}
Example 77
Project: humanize-master  File: UTF8Control.java View source code
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    // The below is a copy of the default implementation.
    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "properties");
    ResourceBundle bundle = null;
    InputStream stream = (reload) ? reload(loader.getResource(resourceName)) : loader.getResourceAsStream(resourceName);
    if (stream != null) {
        try {
            // Only this line is changed to make it to read properties files
            // as UTF-8.
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
        } finally {
            stream.close();
        }
    }
    return bundle;
}
Example 78
Project: idnadrev-master  File: UTF8Control.java View source code
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    String resourceName = getResourceName(baseName, locale);
    ResourceBundle bundle = null;
    InputStream stream = null;
    if (reload) {
        URL url = loader.getResource(resourceName);
        if (url != null) {
            URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                stream = connection.getInputStream();
            }
        }
    } else {
        stream = loader.getResourceAsStream(resourceName);
    }
    if (stream != null) {
        try {
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
        } finally {
            stream.close();
        }
    }
    return bundle;
}
Example 79
Project: interval-music-compositor-master  File: Utf8Control.java View source code
/*
   * Code taken from: http://stackoverflow.com/questions/4659929/how-to-use-utf-8-in-resource-properties-with-resourcebundle/4660195#4660195
   */
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    String resourceName = toResourceName(toBundleName(baseName, locale), "properties");
    ResourceBundle bundle = null;
    InputStream stream = null;
    if (reload) {
        URL url = loader.getResource(resourceName);
        if (url != null) {
            URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                stream = connection.getInputStream();
            }
        }
    } else {
        stream = loader.getResourceAsStream(resourceName);
    }
    if (stream != null) {
        try {
            // Only this line is changed to make it to read properties files as UTF-8.
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, Charsets.UTF_8));
        } finally {
            stream.close();
        }
    }
    return bundle;
}
Example 80
Project: jabref-master  File: EncodingControl.java View source code
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    // The below is a copy of the default implementation.
    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "properties");
    ResourceBundle bundle = null;
    if (reload) {
        URL url = loader.getResource(resourceName);
        if (url != null) {
            URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                try (InputStream stream = connection.getInputStream()) {
                    bundle = new PropertyResourceBundle(new InputStreamReader(stream, encoding));
                }
            }
        }
    } else {
        try (InputStream stream = loader.getResourceAsStream(resourceName)) {
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, encoding));
        }
    }
    return bundle;
}
Example 81
Project: java-libs-master  File: UTF8Control.java View source code
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    // The below is a copy of the default implementation.
    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "properties");
    ResourceBundle bundle = null;
    InputStream stream = null;
    if (reload) {
        URL url = loader.getResource(resourceName);
        if (url != null) {
            URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                stream = connection.getInputStream();
            }
        }
    } else {
        stream = loader.getResourceAsStream(resourceName);
    }
    if (stream != null) {
        try {
            // Only this line is changed to make it to read properties files as UTF-8.
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
        } finally {
            stream.close();
        }
    }
    return bundle;
}
Example 82
Project: l2adena-l2j-core-master  File: LanguageControl.java View source code
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    if (baseName == null || locale == null || format == null || loader == null) {
        throw new NullPointerException();
    }
    ResourceBundle bundle = null;
    if (format.equals("java.properties")) {
        format = "properties";
        String bundleName = toBundleName(baseName, locale);
        String resourceName = LANGUAGES_DIRECTORY + toResourceName(bundleName, format);
        BufferedInputStream bis = null;
        try {
            bis = new BufferedInputStream(new FileInputStream(resourceName));
            bundle = new PropertyResourceBundle(bis);
        } finally {
            bis.close();
        }
    }
    return bundle;
}
Example 83
Project: L2jServer_Core-master  File: LanguageControl.java View source code
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IOException {
    if (baseName == null || locale == null || format == null || loader == null) {
        throw new NullPointerException();
    }
    ResourceBundle bundle = null;
    if (format.equals("java.properties")) {
        format = "properties";
        String bundleName = toBundleName(baseName, locale);
        String resourceName = LANGUAGES_DIRECTORY + toResourceName(bundleName, format);
        BufferedInputStream bis = null;
        try {
            bis = new BufferedInputStream(new FileInputStream(resourceName));
            bundle = new PropertyResourceBundle(bis);
        } finally {
            bis.close();
        }
    }
    return bundle;
}
Example 84
Project: l2jtw_pvp_server-master  File: LanguageControl.java View source code
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IOException {
    if ((baseName == null) || (locale == null) || (format == null) || (loader == null)) {
        throw new NullPointerException();
    }
    ResourceBundle bundle = null;
    if (format.equals("java.properties")) {
        format = "properties";
        String bundleName = toBundleName(baseName, locale);
        String resourceName = LANGUAGES_DIRECTORY + toResourceName(bundleName, format);
        try (FileInputStream fis = new FileInputStream(resourceName);
            BufferedInputStream bis = new BufferedInputStream(fis)) {
            bundle = new PropertyResourceBundle(bis);
        }
    }
    return bundle;
}
Example 85
Project: openwayback-master  File: UTF8Control.java View source code
/**
     *
     * @param baseName
     * @param locale
     * @param format
     * @param loader
     * @param reload
     * @return
     * @throws IllegalAccessException
     * @throws InstantiationException
     * @throws IOException
     */
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    // The below is a copy of the default implementation.
    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "properties");
    ResourceBundle bundle = null;
    InputStream stream = null;
    if (reload) {
        URL url = loader.getResource(resourceName);
        if (url != null) {
            URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                stream = connection.getInputStream();
            }
        }
    } else {
        stream = loader.getResourceAsStream(resourceName);
    }
    if (stream != null) {
        try {
            // Only this line is changed to make it to read properties files as UTF-8.
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
        } finally {
            stream.close();
        }
    }
    return bundle;
}
Example 86
Project: ORCID-Source-master  File: UTF8Control.java View source code
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException {
    // The below is a copy of the default implementation.
    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "properties");
    ResourceBundle bundle = null;
    InputStream stream = null;
    if (reload) {
        URL url = loader.getResource(resourceName);
        if (url != null) {
            URLConnection connection = url.openConnection();
            if (connection != null) {
                connection.setUseCaches(false);
                stream = connection.getInputStream();
            }
        }
    } else {
        stream = loader.getResourceAsStream(resourceName);
    }
    if (stream != null) {
        try {
            // Only this line is changed to make it to read properties files as UTF-8.
            bundle = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
        } finally {
            stream.close();
        }
    }
    return bundle;
}
Example 87
Project: gtitool-master  File: ConfirmDialogForm.java View source code
/**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;
    jGTIScrollPaneInfo = new de.unisiegen.gtitool.ui.swing.JGTIScrollPane();
    jGTITextAreaInfo = new de.unisiegen.gtitool.ui.swing.JGTITextArea();
    jGTIButtonYes = new de.unisiegen.gtitool.ui.swing.JGTIButton();
    jGTIButtonYesToAll = new de.unisiegen.gtitool.ui.swing.JGTIButton();
    jGTIButtonNo = new de.unisiegen.gtitool.ui.swing.JGTIButton();
    jGTIButtonNoToAll = new de.unisiegen.gtitool.ui.swing.JGTIButton();
    jGTIButtonCancel = new de.unisiegen.gtitool.ui.swing.JGTIButton();
    setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
    setResizable(false);
    addWindowListener(new java.awt.event.WindowAdapter() {

        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });
    getContentPane().setLayout(new java.awt.GridBagLayout());
    jGTIScrollPaneInfo.setBorder(null);
    jGTITextAreaInfo.setFocusable(false);
    // NOI18N
    jGTITextAreaInfo.setFont(new java.awt.Font("Dialog", 1, 12));
    jGTITextAreaInfo.setOpaque(false);
    jGTIScrollPaneInfo.setViewportView(jGTITextAreaInfo);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 5;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(16, 16, 5, 16);
    getContentPane().add(jGTIScrollPaneInfo, gridBagConstraints);
    jGTIButtonYes.setMnemonic(java.util.ResourceBundle.getBundle("de/unisiegen/gtitool/ui/i18n/messages").getString("ConfirmDialog.YesMnemonic").charAt(0));
    // NOI18N
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("de/unisiegen/gtitool/ui/i18n/messages");
    // NOI18N
    jGTIButtonYes.setText(bundle.getString("ConfirmDialog.Yes"));
    jGTIButtonYes.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jGTIButtonYesActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 16, 16, 5);
    getContentPane().add(jGTIButtonYes, gridBagConstraints);
    jGTIButtonYesToAll.setMnemonic(java.util.ResourceBundle.getBundle("de/unisiegen/gtitool/ui/i18n/messages").getString("ConfirmDialog.YesToAllMnemonic").charAt(0));
    // NOI18N
    jGTIButtonYesToAll.setText(bundle.getString("ConfirmDialog.YesToAll"));
    jGTIButtonYesToAll.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jGTIButtonYesToAllActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 16, 5);
    getContentPane().add(jGTIButtonYesToAll, gridBagConstraints);
    jGTIButtonNo.setMnemonic(java.util.ResourceBundle.getBundle("de/unisiegen/gtitool/ui/i18n/messages").getString("ConfirmDialog.NoMnemonic").charAt(0));
    // NOI18N
    jGTIButtonNo.setText(bundle.getString("ConfirmDialog.No"));
    jGTIButtonNo.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jGTIButtonNoActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 16, 5);
    getContentPane().add(jGTIButtonNo, gridBagConstraints);
    jGTIButtonNoToAll.setMnemonic(java.util.ResourceBundle.getBundle("de/unisiegen/gtitool/ui/i18n/messages").getString("ConfirmDialog.NoToAllMnemonic").charAt(0));
    // NOI18N
    jGTIButtonNoToAll.setText(bundle.getString("ConfirmDialog.NoToAll"));
    jGTIButtonNoToAll.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jGTIButtonNoToAllActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 16, 5);
    getContentPane().add(jGTIButtonNoToAll, gridBagConstraints);
    jGTIButtonCancel.setMnemonic(java.util.ResourceBundle.getBundle("de/unisiegen/gtitool/ui/i18n/messages").getString("ConfirmDialog.CancelMnemonic").charAt(0));
    // NOI18N
    jGTIButtonCancel.setText(bundle.getString("ConfirmDialog.Cancel"));
    jGTIButtonCancel.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jGTIButtonCancelActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 4;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 16, 16);
    getContentPane().add(jGTIButtonCancel, gridBagConstraints);
    setSize(new java.awt.Dimension(600, 250));
}
Example 88
Project: tpml-master  File: MainWindow.java View source code
// Self-defined methods:
void openFile(File file) {
    if (file == null) {
        throw new NullPointerException("file is null");
    }
    try {
        // check if we already have an editor panel for the file
        EditorPanel editorPanel = null;
        for (Component component : window.tabbedPane.getComponents()) {
            if (component instanceof EditorPanelForm && file.equals((((EditorPanelForm) component).getCaller()).getFile())) {
                editorPanel = ((EditorPanelForm) component).getCaller();
                break;
            }
        }
        // if we don't already have the editor panel, create a new one
        if (editorPanel == null) {
            LanguageFactory langfactory = LanguageFactory.newInstance();
            Language language = langfactory.getLanguageByFile(file);
            String str = null;
            StringBuilder buffer = new StringBuilder();
            int onechar;
            try {
                BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF8"));
                while ((onechar = in.read()) != -1) {
                    buffer.append((char) onechar);
                }
                in.close();
            } catch (UnsupportedEncodingException e) {
                System.err.println("UnsupportedEncodingException");
            }
            if (language.isTypeLanguage()) {
                editorPanel = new EditorPanelTypes(language, this);
            } else {
                editorPanel = new EditorPanelExpression(language, this);
            }
            window.tabbedPane.add((Component) editorPanel.getPanel());
            editorPanel.setAdvanced(window.advancedRadioButton.isSelected());
            editorPanel.setFileName(file.getName());
            editorPanel.setEditorText(buffer.toString());
            editorPanel.setFile(file);
            editorPanel.addPropertyChangeListener(editorPanelListener);
            editorPanel.setTexteditor(true);
        }
        window.tabbedPane.setSelectedComponent((Component) editorPanel.getPanel());
        setGeneralStates(true);
        updateEditorStates(editorPanel);
    } catch (NoSuchLanguageException e) {
        logger.error("Language does not exist.", e);
        JOptionPane.showMessageDialog(window, java.util.ResourceBundle.getBundle("de/unisiegen/tpml/ui/ui").getString("FileNotSupported"), java.util.ResourceBundle.getBundle("de/unisiegen/tpml/ui/ui").getString("Open_File"), JOptionPane.ERROR_MESSAGE);
    } catch (FileNotFoundException e) {
        logger.error("File specified could not be found", e);
        JOptionPane.showMessageDialog(window, java.util.ResourceBundle.getBundle("de/unisiegen/tpml/ui/ui").getString("FileCannotBeFound"), java.util.ResourceBundle.getBundle("de/unisiegen/tpml/ui/ui").getString("Open_File"), JOptionPane.ERROR_MESSAGE);
    } catch (IOException e) {
        logger.error("Could not read from the file specified", e);
        JOptionPane.showMessageDialog(window, java.util.ResourceBundle.getBundle("de/unisiegen/tpml/ui/ui").getString("FileCannotBeRead"), java.util.ResourceBundle.getBundle("de/unisiegen/tpml/ui/ui").getString("Open_File"), JOptionPane.ERROR_MESSAGE);
    }
}
Example 89
Project: spring-framework-2.5.x-master  File: ResourceBundleMessageSource.java View source code
/**
	 * Resolves the given message code as key in the registered resource bundles,
	 * returning the value found in the bundle as-is (without MessageFormat parsing).
	 */
protected String resolveCodeWithoutArguments(String code, Locale locale) {
    String result = null;
    for (int i = 0; result == null && i < this.basenames.length; i++) {
        ResourceBundle bundle = getResourceBundle(this.basenames[i], locale);
        if (bundle != null) {
            result = getStringOrNull(bundle, code);
        }
    }
    return result;
}
Example 90
Project: spring-framework-master  File: ResourceBundleViewResolver.java View source code
/**
	 * Initialize the View {@link BeanFactory} from the {@code ResourceBundle},
	 * for the given {@link Locale locale}.
	 * <p>Synchronized because of access by parallel threads.
	 * @param locale the target {@code Locale}
	 * @return the View factory for the given Locale
	 * @throws BeansException in case of initialization errors
	 */
protected synchronized BeanFactory initFactory(Locale locale) throws BeansException {
    // Have we already encountered that Locale before?
    if (isCache()) {
        BeanFactory cachedFactory = this.localeCache.get(locale);
        if (cachedFactory != null) {
            return cachedFactory;
        }
    }
    // Build list of ResourceBundle references for Locale.
    List<ResourceBundle> bundles = new LinkedList<>();
    for (String basename : this.basenames) {
        ResourceBundle bundle = getBundle(basename, locale);
        bundles.add(bundle);
    }
    // even if Locale was different, same bundles might have been found.
    if (isCache()) {
        BeanFactory cachedFactory = this.bundleCache.get(bundles);
        if (cachedFactory != null) {
            this.localeCache.put(locale, cachedFactory);
            return cachedFactory;
        }
    }
    // Create child ApplicationContext for views.
    GenericWebApplicationContext factory = new GenericWebApplicationContext();
    factory.setParent(getApplicationContext());
    factory.setServletContext(getServletContext());
    // Load bean definitions from resource bundle.
    PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(factory);
    reader.setDefaultParentBean(this.defaultParentView);
    for (ResourceBundle bundle : bundles) {
        reader.registerBeanDefinitions(bundle);
    }
    factory.refresh();
    // Cache factory for both Locale and ResourceBundle list.
    if (isCache()) {
        this.localeCache.put(locale, factory);
        this.bundleCache.put(bundles, factory);
    }
    return factory;
}
Example 91
Project: VisiCut-master  File: EditProfilesDialog.java View source code
/** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
@SuppressWarnings("unchecked")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
    Profiles = new javax.swing.JLabel();
    jButton4 = new javax.swing.JButton();
    jButton5 = new javax.swing.JButton();
    editableTablePanel1 = new com.t_oster.uicomponents.EditableTablePanel();
    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    // NOI18N
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("com/t_oster/visicut/gui/resources/EditProfilesDialog");
    // NOI18N
    setTitle(bundle.getString("TITLE"));
    // NOI18N
    setName("Form");
    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(com.t_oster.visicut.gui.VisicutApp.class).getContext().getResourceMap(EditProfilesDialog.class);
    // NOI18N
    Profiles.setText(resourceMap.getString("Profiles.text"));
    // NOI18N
    Profiles.setName("Profiles");
    // NOI18N
    jButton4.setText(resourceMap.getString("jButton4.text"));
    // NOI18N
    jButton4.setName("jButton4");
    jButton4.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton4ActionPerformed(evt);
        }
    });
    // NOI18N
    jButton5.setText(resourceMap.getString("jButton5.text"));
    // NOI18N
    jButton5.setName("jButton5");
    jButton5.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton5ActionPerformed(evt);
        }
    });
    // NOI18N
    editableTablePanel1.setName("editableTablePanel1");
    editableTablePanel1.setProvider(this);
    org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${currentProfiles}"), editableTablePanel1, org.jdesktop.beansbinding.BeanProperty.create("objects"), "materials");
    bindingGroup.addBinding(binding);
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(editableTablePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE).addComponent(Profiles).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addComponent(jButton5).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jButton4))).addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addComponent(Profiles).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(editableTablePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 261, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jButton4).addComponent(jButton5)).addContainerGap()));
    bindingGroup.bind();
    pack();
}
Example 92
Project: PortableSigner2-master  File: PDFSigner.java View source code
/** Creates a new instance of DoSignPDF */
public void doSignPDF(String pdfInputFileName, String pdfOutputFileName, String pkcs12FileName, String password, Boolean signText, String signLanguage, String sigLogo, Boolean finalize, String sigComment, String signReason, String signLocation, Boolean noExtraPage, float verticalPos, float leftMargin, float rightMargin, Boolean signLastPage, byte[] ownerPassword) throws PDFSignerException {
    try {
        //System.out.println("-> DoSignPDF <-");
        //System.out.println("Eingabedatei: " + pdfInputFileName);
        //System.out.println("Ausgabedatei: " + pdfOutputFileName);
        //System.out.println("Signaturdatei: " + pkcs12FileName);
        //System.out.println("Signaturblock?: " + signText);
        //System.out.println("Sprache der Blocks: " + signLanguage);
        //System.out.println("Signaturlogo: " + sigLogo);
        System.err.println("Position V:" + verticalPos + " L:" + leftMargin + " R:" + rightMargin);
        Rectangle signatureBlock;
        java.security.Security.insertProviderAt(new org.bouncycastle.jce.provider.BouncyCastleProvider(), 2);
        pkcs12 = new GetPKCS12(pkcs12FileName, password);
        PdfReader reader = null;
        try {
            //                System.out.println("Password:" + ownerPassword.toString());
            if (ownerPassword == null)
                reader = new PdfReader(pdfInputFileName);
            else
                reader = new PdfReader(pdfInputFileName, ownerPassword);
        } catch (IOException e) {
            throw new PDFSignerException(java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n").getString("CouldNotBeOpened"), true, e.getLocalizedMessage());
        }
        FileOutputStream fout = null;
        try {
            fout = new FileOutputStream(pdfOutputFileName);
        } catch (FileNotFoundException e) {
            throw new PDFSignerException(java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n").getString("CouldNotBeWritten"), true, e.getLocalizedMessage());
        }
        PdfStamper stp = null;
        try {
            Date datum = new Date(System.currentTimeMillis());
            int pages = reader.getNumberOfPages();
            Rectangle size = reader.getPageSize(pages);
            stp = PdfStamper.createSignature(reader, fout, '\0', null, true);
            HashMap<String, String> pdfInfo = reader.getInfo();
            // thanks to Markus Feisst
            String pdfInfoProducer = "";
            if (pdfInfo.get("Producer") != null) {
                pdfInfoProducer = pdfInfo.get("Producer").toString();
                pdfInfoProducer = pdfInfoProducer + " (signed with PortableSigner " + Version.release + ")";
            } else {
                pdfInfoProducer = "Unknown Producer (signed with PortableSigner " + Version.release + ")";
            }
            pdfInfo.put("Producer", pdfInfoProducer);
            //System.err.print("++ Producer:" + pdfInfo.get("Producer").toString());
            stp.setMoreInfo(pdfInfo);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            XmpWriter xmp = new XmpWriter(baos, pdfInfo);
            xmp.close();
            stp.setXmpMetadata(baos.toByteArray());
            if (signText) {
                String greet, signator, datestr, ca, serial, special, note, urn, urnvalue;
                int specialcount = 0;
                int sigpage;
                int rightMarginPT, leftMarginPT;
                float verticalPositionPT;
                ResourceBundle block = ResourceBundle.getBundle("net/pflaeging/PortableSigner/Signatureblock_" + signLanguage);
                greet = block.getString("greeting");
                signator = block.getString("signator");
                datestr = block.getString("date");
                ca = block.getString("issuer");
                serial = block.getString("serial");
                special = block.getString("special");
                note = block.getString("note");
                urn = block.getString("urn");
                urnvalue = block.getString("urnvalue");
                //sigcomment = block.getString(signLanguage + "-comment");
                // upper y
                float topy = size.getTop();
                System.err.println("Top: " + topy * ptToCm);
                // right x
                float rightx = size.getRight();
                System.err.println("Right: " + rightx * ptToCm);
                if (!noExtraPage) {
                    sigpage = pages + 1;
                    stp.insertPage(sigpage, size);
                    // 30pt left, 30pt right, 20pt from top
                    rightMarginPT = 30;
                    leftMarginPT = 30;
                    verticalPositionPT = topy - 20;
                } else {
                    if (signLastPage) {
                        sigpage = pages;
                    } else {
                        sigpage = 1;
                    }
                    System.err.println("Page: " + sigpage);
                    rightMarginPT = Math.round(rightMargin / ptToCm);
                    leftMarginPT = Math.round(leftMargin / ptToCm);
                    verticalPositionPT = topy - Math.round(verticalPos / ptToCm);
                }
                if (!GetPKCS12.atEgovOID.equals("")) {
                    specialcount = 1;
                }
                PdfContentByte content = stp.getOverContent(sigpage);
                float[] cellsize = new float[2];
                cellsize[0] = 100f;
                // rightx = width of page
                // 60 = 2x30 margins
                // cellsize[0] = description row
                // cellsize[1] = 0
                // 70 = logo width
                cellsize[1] = rightx - rightMarginPT - leftMarginPT - cellsize[0] - cellsize[1] - 70;
                // Pagetable = Greeting, signatureblock, comment
                // sigpagetable = outer table
                //      consist: greetingcell, signatureblock , commentcell
                PdfPTable signatureBlockCompleteTable = new PdfPTable(2);
                PdfPTable signatureTextTable = new PdfPTable(2);
                PdfPCell signatureBlockHeadingCell = new PdfPCell(new Paragraph(new Chunk(greet, new Font(Font.FontFamily.HELVETICA, 12))));
                signatureBlockHeadingCell.setPaddingBottom(5);
                signatureBlockHeadingCell.setColspan(2);
                signatureBlockHeadingCell.setBorderWidth(0f);
                signatureBlockCompleteTable.addCell(signatureBlockHeadingCell);
                // inner table start
                // Line 1
                signatureTextTable.addCell(new Paragraph(new Chunk(signator, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                signatureTextTable.addCell(new Paragraph(new Chunk(GetPKCS12.subject, new Font(Font.FontFamily.COURIER, 10))));
                // Line 2
                signatureTextTable.addCell(new Paragraph(new Chunk(datestr, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                signatureTextTable.addCell(new Paragraph(new Chunk(datum.toString(), new Font(Font.FontFamily.COURIER, 10))));
                // Line 3
                signatureTextTable.addCell(new Paragraph(new Chunk(ca, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                signatureTextTable.addCell(new Paragraph(new Chunk(GetPKCS12.issuer, new Font(Font.FontFamily.COURIER, 10))));
                // Line 4
                signatureTextTable.addCell(new Paragraph(new Chunk(serial, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                signatureTextTable.addCell(new Paragraph(new Chunk(GetPKCS12.serial.toString(), new Font(Font.FontFamily.COURIER, 10))));
                // Line 5
                if (specialcount == 1) {
                    signatureTextTable.addCell(new Paragraph(new Chunk(special, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                    signatureTextTable.addCell(new Paragraph(new Chunk(GetPKCS12.atEgovOID, new Font(Font.FontFamily.COURIER, 10))));
                }
                signatureTextTable.addCell(new Paragraph(new Chunk(urn, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                signatureTextTable.addCell(new Paragraph(new Chunk(urnvalue, new Font(Font.FontFamily.COURIER, 10))));
                signatureTextTable.setTotalWidth(cellsize);
                System.err.println("signatureTextTable Width: " + cellsize[0] * ptToCm + " " + cellsize[1] * ptToCm);
                // inner table end
                signatureBlockCompleteTable.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                Image logo;
                //                     System.out.println("Logo:" + sigLogo + ":");
                if (sigLogo == null || "".equals(sigLogo)) {
                    logo = Image.getInstance(getClass().getResource("/net/pflaeging/PortableSigner/SignatureLogo.png"));
                } else {
                    logo = Image.getInstance(sigLogo);
                }
                PdfPCell logocell = new PdfPCell();
                logocell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                logocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                logocell.setImage(logo);
                signatureBlockCompleteTable.addCell(logocell);
                PdfPCell incell = new PdfPCell(signatureTextTable);
                incell.setBorderWidth(0f);
                signatureBlockCompleteTable.addCell(incell);
                PdfPCell commentcell = new PdfPCell(new Paragraph(new Chunk(sigComment, new Font(Font.FontFamily.HELVETICA, 10))));
                PdfPCell notecell = new PdfPCell(new Paragraph(new Chunk(note, new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD))));
                // commentcell.setBorderWidth(0f);
                if (!sigComment.equals("")) {
                    signatureBlockCompleteTable.addCell(notecell);
                    signatureBlockCompleteTable.addCell(commentcell);
                }
                float[] cells = { 70, cellsize[0] + cellsize[1] };
                signatureBlockCompleteTable.setTotalWidth(cells);
                System.err.println("signatureBlockCompleteTable Width: " + cells[0] * ptToCm + " " + cells[1] * ptToCm);
                signatureBlockCompleteTable.writeSelectedRows(0, 4 + specialcount, leftMarginPT, verticalPositionPT, content);
                System.err.println("signatureBlockCompleteTable Position " + 30 * ptToCm + " " + (topy - 20) * ptToCm);
                signatureBlock = new Rectangle(30 + signatureBlockCompleteTable.getTotalWidth() - 20, topy - 20 - 20, 30 + signatureBlockCompleteTable.getTotalWidth(), topy - 20);
            //                    //////
            //                    AcroFields af = reader.getAcroFields();
            //                    ArrayList names = af.getSignatureNames();
            //                    for (int k = 0; k < names.size(); ++k) {
            //                        String name = (String) names.get(k);
            //                        System.out.println("Signature name: " + name);
            //                        System.out.println("\tSignature covers whole document: " + af.signatureCoversWholeDocument(name));
            //                        System.out.println("\tDocument revision: " + af.getRevision(name) + " of " + af.getTotalRevisions());
            //                        PdfPKCS7 pk = af.verifySignature(name);
            //                        X509Certificate tempsigner = pk.getSigningCertificate();
            //                        Calendar cal = pk.getSignDate();
            //                        Certificate pkc[] = pk.getCertificates();
            //                        java.util.ResourceBundle tempoid =
            //                                java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/SpecialOID");
            //                        String tmpEgovOID = "";
            //
            //                        for (Enumeration<String> o = tempoid.getKeys(); o.hasMoreElements();) {
            //                            String element = o.nextElement();
            //                            // System.out.println(element + ":" + oid.getString(element));
            //                            if (tempsigner.getNonCriticalExtensionOIDs().contains(element)) {
            //                                if (!tmpEgovOID.equals("")) {
            //                                    tmpEgovOID += ", ";
            //                                }
            //                                tmpEgovOID += tempoid.getString(element) + " (OID=" + element + ")";
            //                            }
            //                        }
            //                        //System.out.println("\tSigniert von: " + PdfPKCS7.getSubjectFields(pk.getSigningCertificate()));
            //                        System.out.println("\tSigniert von: " + tempsigner.getSubjectX500Principal().toString());
            //                        System.out.println("\tDatum: " + cal.getTime().toString());
            //                        System.out.println("\tAusgestellt von: " + tempsigner.getIssuerX500Principal().toString());
            //                        System.out.println("\tSeriennummer: " + tempsigner.getSerialNumber());
            //                        if (!tmpEgovOID.equals("")) {
            //                            System.out.println("\tVerwaltungseigenschaft: " + tmpEgovOID);
            //                        }
            //                        System.out.println("\n");
            //                        System.out.println("\tDocument modified: " + !pk.verify());
            ////                Object fails[] = PdfPKCS7.verifyCertificates(pkc, kall, null, cal);
            ////                if (fails == null) {
            ////                    System.out.println("\tCertificates verified against the KeyStore");
            ////                } else {
            ////                    System.out.println("\tCertificate failed: " + fails[1]);
            ////                }
            //                    }
            //
            //                //////
            } else {
                // fake definition
                signatureBlock = new Rectangle(0, 0, 0, 0);
            }
            PdfSignatureAppearance sap = stp.getSignatureAppearance();
            //                sap.setCrypto(GetPKCS12.privateKey, GetPKCS12.certificateChain, null,
            //                        PdfSignatureAppearance.WINCER_SIGNED );
            sap.setCrypto(GetPKCS12.privateKey, GetPKCS12.certificateChain, null, null);
            sap.setReason(signReason);
            sap.setLocation(signLocation);
            //                }
            if (finalize) {
                sap.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);
            } else {
                sap.setCertificationLevel(PdfSignatureAppearance.NOT_CERTIFIED);
            }
            stp.close();
        /* MODIFY BY: Denis Torresan
                Main.setResult(
		                java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n").getString("IsGeneratedAndSigned"),
		                false,
		                "");
								*/
        } catch (Exception e) {
            throw new PDFSignerException(java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n").getString("ErrorWhileSigningFile"), true, e.getLocalizedMessage());
        }
    } catch (KeyStoreException kse) {
        throw new PDFSignerException(java.util.ResourceBundle.getBundle("net/pflaeging/PortableSigner/i18n").getString("ErrorCreatingKeystore"), true, kse.getLocalizedMessage());
    }
}
Example 93
Project: spring-js-master  File: ResourceBundleMessageSource.java View source code
/**
	 * Resolves the given message code as key in the registered resource bundles,
	 * returning the value found in the bundle as-is (without MessageFormat parsing).
	 */
@Override
protected String resolveCodeWithoutArguments(String code, Locale locale) {
    String result = null;
    for (int i = 0; result == null && i < this.basenames.length; i++) {
        ResourceBundle bundle = getResourceBundle(this.basenames[i], locale);
        if (bundle != null) {
            result = getStringOrNull(bundle, code);
        }
    }
    return result;
}
Example 94
Project: AndroidDevToolbox-master  File: Main.java View source code
@Override
public void start(Stage primaryStage) throws Exception {
    setUserAgentStylesheet(STYLESHEET_CASPIAN);
    FXMLLoader fxmlLoader = new FXMLLoader();
    ResourceBundle resourceBundle = ResourceBundle.getBundle("bundles.Bundle", LocaleHelper.getLocale());
    Parent root = fxmlLoader.load(FileHelper.getFxmlUrl(getClass(), "MainScreen.fxml"), resourceBundle);
    Scene scene = new Scene(root);
    String cssURL = getClass().getClassLoader().getResource(AppConfig.APP_CSS_PATH).toExternalForm();
    scene.getStylesheets().add(cssURL);
    String appURL = getClass().getClassLoader().getResource(AppConfig.APP_ICON_PATH).toExternalForm();
    primaryStage.setTitle(resourceBundle.getString("AppName"));
    primaryStage.getIcons().add(new Image(appURL));
    primaryStage.setScene(scene);
    primaryStage.setResizable(false);
    primaryStage.setMinWidth(850);
    primaryStage.setMinHeight(750);
    primaryStage.show();
}
Example 95
Project: archiv-editor-master  File: Messages.java View source code
/**
     * Returns the language-specific string for the given key,
     * or the key itself if not found.
     */
public static String getString(String key) {
    if (resources == null) {
        //$NON-NLS-1$
        resources = ResourceBundle.getBundle("net.sf.vex.editor.messages");
    }
    try {
        return resources.getString(key);
    } catch (MissingResourceException ex) {
        String message = Messages.getString("Messages.cantFindResource");
        VexPlugin.getInstance().log(IStatus.WARNING, MessageFormat.format(message, new Object[] { key }));
        return key;
    }
}
Example 96
Project: atom-game-framework-sdk-master  File: AssetsPropertiesPanelProvider.java View source code
@Override
public Category createCategory(Lookup lkp) {
    ResourceBundle bundle = NbBundle.getBundle(AssetsPropertiesPanelProvider.class);
    ProjectCustomizer.Category toReturn = null;
    project = lkp.lookup(Project.class);
    if (project == null) {
        return toReturn;
    }
    toReturn = ProjectCustomizer.Category.create("assets", bundle.getString("LBL_Config_assets"), null);
    return toReturn;
}
Example 97
Project: bazel-master  File: PathConverter.java View source code
private String message(String errorKey, String value) {
    ResourceBundle bundle = ResourceBundle.getBundle("joptsimple.ExceptionMessages");
    Object[] arguments = new Object[] { value, valuePattern() };
    String template = bundle.getString(PathConverter.class.getName() + "." + errorKey + ".message");
    return new MessageFormat(template).format(arguments);
}
Example 98
Project: biobank-master  File: Messages.java View source code
private String getString(String key) {
    try {
        String baseName = Messages.class.getName().toLowerCase();
        ResourceBundle bundle = ResourceBundle.getBundle(baseName);
        return bundle.getString(key);
    } catch (MissingResourceException caught) {
        String message = MessageFormat.format(VALUE_NOT_FOUND, getClass().getName(), name(), key, BUNDLE_NAME);
        throw new RuntimeException(message, caught);
    }
}
Example 99
Project: Bootstrap.jsp-master  File: Message.java View source code
@Override
public void doTag() throws JspException, IOException {
    final String value = super.getValue();
    final PageContext pageContext = (PageContext) super.getJspContext();
    final String key = value.trim().replace(' ', '_').toLowerCase();
    if (key.length() > 0) {
        final Locale locale = pageContext.getRequest().getLocale();
        try {
            final ResourceBundle messages = ResourceBundle.getBundle(LABELS, locale);
            if (messages.containsKey(key)) {
                final String message = messages.getString(key);
                pageContext.getOut().print(message);
                return;
            }
        } catch (MissingResourceException e) {
        }
    }
    super.doTag();
}
Example 100
Project: brigen-base-master  File: PropertyBundleBuilderTest.java View source code
@Test
public void test() throws IOException {
    PropertyResourceBundleBuilder builder = PropertyResourceBundleBuilder.create();
    builder.parentKey("extends");
    {
        InputStream is = PropertyBundleBuilderTest.class.getResourceAsStream("C.properties");
        assertNotNull(is);
        ResourceBundle rb = builder.build(is);
        assertEquals("hoge-c", rb.getString("hoge"));
        assertEquals("foo-b", rb.getString("foo"));
        assertEquals("bar-a", rb.getString("bar"));
        try {
            rb.getString("hello");
            fail();
        } catch (MissingResourceException e) {
        }
    }
    {
        InputStream isA = PropertyBundleBuilderTest.class.getResourceAsStream("A.properties");
        InputStream isB = PropertyBundleBuilderTest.class.getResourceAsStream("B.properties");
        InputStream isC = PropertyBundleBuilderTest.class.getResourceAsStream("C.properties");
        assertNotNull(isA);
        assertNotNull(isB);
        assertNotNull(isC);
        ResourceBundle rb = builder.build(isB, isC, isA);
        assertEquals("", rb.getString("hoge"));
        assertEquals("foo-b", rb.getString("foo"));
        assertEquals("bar-a", rb.getString("bar"));
        try {
            rb.getString("hello");
            fail();
        } catch (MissingResourceException e) {
        }
    }
}
Example 101
Project: calopsita-master  File: LocalDateConverter.java View source code
public LocalDate convert(String value, Class<? extends LocalDate> type, ResourceBundle bundle) {
    if (value == null || value.equals("")) {
        return null;
    }
    Locale locale = request.getRequest().getLocale();
    SimpleDateFormat format = DateFormat.valueFor(locale).getFormat();
    try {
        return LocalDate.fromDateFields(format.parse(value));
    } catch (ParseException e) {
        throw new ConversionError("bad.date.format");
    }
}