Example usage for java.util ResourceBundle getString

List of usage examples for java.util ResourceBundle getString

Introduction

In this page you can find the example usage for java.util ResourceBundle getString.

Prototype

public final String getString(String key) 

Source Link

Document

Gets a string for the given key from this resource bundle or one of its parents.

Usage

From source file:edu.toronto.cs.phenotips.measurements.internal.DefaultMeasurementsChartConfigurationsFactory.java

/**
 * Read and return a setting from the configuration, falling back on the provided default value.
 * /*from w  w  w . ja v a 2  s.c  o  m*/
 * @param settingName the name of the setting to read
 * @param defaultValue the default value to use when there's no value specified in the configuration; can be
 *            {@code null} or the empty string
 * @param configuration the configuration bundle with all the settings
 * @return the configured value, if one is configured (even as an empty string), or the default value otherwise
 */
private String getStringSetting(String settingName, String defaultValue, ResourceBundle configuration) {
    String result = defaultValue;
    if (configuration.containsKey(settingName)) {
        result = configuration.getString(settingName);
    }
    return result;
}

From source file:net.sf.yal10n.analyzer.ExploratoryEncodingTest.java

/**
 * Test to load a reource bundle from a BOM encoded file.
 * @throws Exception any error//w w  w .ja  v  a2s .  c  o m
 */
@Test
public void testResourceBundleWithBOM() throws Exception {
    ResourceBundle bundle = PropertyResourceBundle.getBundle("UTF8BOM", Locale.ROOT);
    Assert.assertEquals(3, bundle.keySet().size());

    // Assert.assertEquals("first key", bundle.getString("testkey1"));
    // note: utf-8 bom read as iso-8859-1
    Assert.assertEquals("first key", bundle.getString("\u00ef\u00bb\u00bftestkey1"));

    Assert.assertEquals("second key", bundle.getString("testkey2"));
    // note: utf-8 read as iso-8859-1
    Assert.assertEquals("This file is encoded as UTF-8 with BOM \u00c3\u00a4.",
            bundle.getString("description"));
}

From source file:com.sunrun.crportal.util.CRPortalUtil.java

public static String getCRPortalProperty(String propertyKey) {
    LOG.debug("* ---------------------------------------------------------- *");
    LOG.debug("* getCRPortalProperty - Entering                             *");
    LOG.debug("* ---------------------------------------------------------- *");

    LOG.debug("   getCRPortalProperty - Property Key = " + propertyKey);

    ResourceBundle rb;
    String propertyValue = null;//from w  ww  .  j  av  a  2s .  com

    try {
        rb = ResourceBundle.getBundle("content/CRPortal");
        propertyValue = rb.getString(propertyKey);
    } catch (NullPointerException npe) {
        LOG.warn("Property not found: " + propertyKey + ". Using default: " + propertyValue);
        propertyValue = null;
    } catch (MissingResourceException mre) {
        LOG.warn("Property not found: " + propertyKey + ". Using default: " + propertyValue);
        propertyValue = null;
    }

    LOG.debug("   getCRPortalProperty - Property Value = " + propertyValue);
    LOG.debug("* ---------------------------------------------------------- *");
    LOG.debug("* getCRPortalProperty - Exiting                              *");
    LOG.debug("* ---------------------------------------------------------- *");
    return propertyValue;
}

From source file:es.pode.empaquetador.presentacion.avanzado.recursos.crear.archivos.CrearRecursoAvanzadoArchivosControllerImpl.java

public final java.lang.String selectAction(ActionMapping mapping,
        es.pode.empaquetador.presentacion.avanzado.recursos.crear.archivos.SelectActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    /*/*from w w w  .j av a2 s. co  m*/
    * Metodo de decision para el action. Analiza los parametros
    * actionSubmit (value de los botones submit) para redirigir al caso de uso
    * correspondiente. El actionSubmit llegara
    * internacionalizado, por lo que es necesario acceder al ResouceBundle
    * para obtener el valor correcto en la comparacion.
    */

    String result = null;
    String actionSubmit = form.getAction();
    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    if (form.getAction() == (null)) {
        throw new ValidatorException("{comunes.error.generico}");
    }

    else if (actionSubmit
            .equals(i18n.getString("presentacion.avanzado.recursos.crear.archivos.submit.seleccionar"))) {
        result = "Seleccionar";
    } else if (actionSubmit
            .equals(i18n.getString("presentacion.avanzado.recursos.crear.archivos.submit.cancelar"))) {
        result = "Cancelar";
    } else {
        Logger.getLogger(this.getClass())
                .error("El valor del submit no es correcto (actionSubmit = " + actionSubmit + ";");
    }
    return result;
}

From source file:ru.develgame.jflickrorganizer.LoginForm.java

/**
 * 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.//from w w  w .j a  va  2s  . co  m
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

    jLabelURL = new javax.swing.JLabel();
    jTextFieldURL = new javax.swing.JTextField();
    jLabelToken = new javax.swing.JLabel();
    jTextFieldToken = new javax.swing.JTextField();
    jButtonCancel = new javax.swing.JButton();
    jButtonOK = new javax.swing.JButton();
    jCheckBoxOfflineMode = new javax.swing.JCheckBox();
    jLabelLogin = new javax.swing.JLabel();
    jTextFieldLogin = new javax.swing.JTextField();
    jPassword = new javax.swing.JPasswordField();
    jLabelPassword = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("LoginForm"); // NOI18N
    setTitle(bundle.getString("LoginForm.title")); // NOI18N
    setName("Form"); // NOI18N
    setResizable(false);

    jLabelURL.setText(bundle.getString("LoginForm.jLabelURL.text")); // NOI18N
    jLabelURL.setName("jLabelURL"); // NOI18N

    org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
            org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jCheckBoxOfflineMode,
            org.jdesktop.beansbinding.ELProperty.create("${!selected}"), jLabelURL,
            org.jdesktop.beansbinding.BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);

    jTextFieldURL.setName("jTextFieldURL"); // NOI18N

    binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
            org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jCheckBoxOfflineMode,
            org.jdesktop.beansbinding.ELProperty.create("${!selected}"), jTextFieldURL,
            org.jdesktop.beansbinding.BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);

    jLabelToken.setText(bundle.getString("LoginForm.jLabelToken.text")); // NOI18N
    jLabelToken.setName("jLabelToken"); // NOI18N

    binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
            org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jCheckBoxOfflineMode,
            org.jdesktop.beansbinding.ELProperty.create("${!selected}"), jLabelToken,
            org.jdesktop.beansbinding.BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);

    jTextFieldToken.setName("jTextFieldToken"); // NOI18N

    binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
            org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jCheckBoxOfflineMode,
            org.jdesktop.beansbinding.ELProperty.create("${!selected}"), jTextFieldToken,
            org.jdesktop.beansbinding.BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);

    jButtonCancel.setText(bundle.getString("LoginForm.jButtonCancel.text")); // NOI18N
    jButtonCancel.setName("jButtonCancel"); // NOI18N
    jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonCancelActionPerformed(evt);
        }
    });

    jButtonOK.setText(bundle.getString("LoginForm.jButtonOK.text")); // NOI18N
    jButtonOK.setName("jButtonOK"); // NOI18N
    jButtonOK.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonOKActionPerformed(evt);
        }
    });

    jCheckBoxOfflineMode.setText(bundle.getString("LoginForm.jCheckBoxOfflineMode.text")); // NOI18N
    jCheckBoxOfflineMode.setName("jCheckBoxOfflineMode"); // NOI18N

    jLabelLogin.setText(bundle.getString("LoginForm.jLabelLogin.text")); // NOI18N
    jLabelLogin.setName("jLabelLogin"); // NOI18N

    binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
            org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jCheckBoxOfflineMode,
            org.jdesktop.beansbinding.ELProperty.create("${selected}"), jLabelLogin,
            org.jdesktop.beansbinding.BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);

    jTextFieldLogin.setText(bundle.getString("LoginForm.jTextFieldLogin.text")); // NOI18N
    jTextFieldLogin.setName("jTextFieldLogin"); // NOI18N

    binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
            org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jCheckBoxOfflineMode,
            org.jdesktop.beansbinding.ELProperty.create("${selected}"), jTextFieldLogin,
            org.jdesktop.beansbinding.BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);

    jPassword.setText(bundle.getString("LoginForm.jPassword.text")); // NOI18N
    jPassword.setName("jPassword"); // NOI18N

    binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
            org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jCheckBoxOfflineMode,
            org.jdesktop.beansbinding.ELProperty.create("${selected}"), jPassword,
            org.jdesktop.beansbinding.BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);

    jLabelPassword.setText(bundle.getString("LoginForm.jLabelPassword.text")); // NOI18N
    jLabelPassword.setName("jLabelPassword"); // NOI18N

    binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(
            org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jCheckBoxOfflineMode,
            org.jdesktop.beansbinding.ELProperty.create("${selected}"), jLabelPassword,
            org.jdesktop.beansbinding.BeanProperty.create("enabled"));
    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(jTextFieldURL)
                    .addComponent(jTextFieldToken)
                    .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jCheckBoxOfflineMode).addComponent(jLabelURL)
                                    .addComponent(jLabelToken))
                            .addGap(0, 230, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabelLogin).addComponent(jLabelPassword))
                            .addGap(73, 73, 73)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPassword).addComponent(jTextFieldLogin)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                            layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(jButtonOK)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jButtonCancel)))
                    .addContainerGap()));

    layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { jButtonCancel, jButtonOK });

    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabelURL)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jTextFieldURL, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jLabelToken)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jTextFieldToken, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jCheckBoxOfflineMode)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelLogin).addComponent(jTextFieldLogin,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jPassword, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelPassword))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButtonCancel).addComponent(jButtonOK))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    bindingGroup.bind();

    pack();
}

From source file:es.pode.administracion.presentacion.planificador.informeTrabajo.InformeControllerImpl.java

/**
 * Copiamos todos los campos de la tarea recibida y los metemos en la
 * nueva tarea cambiando la fecha a Date
 *//*www .  jav a 2s .  c  o m*/
private RegistroTareaEjecutadaDate cambiarFormatoRegistroTarea(RegistroTareaEjecutadaVO registroTarea,
        Long idTarea) {
    RegistroTareaEjecutadaDate registroTareaDate = new RegistroTareaEjecutadaDate();

    String descripcion = registroTarea.getDescripcion();

    /*
    * Sustituimos los tabuladores, saltos de linea y simbolos @ y > por
    * espacio
    */
    descripcion = descripcion.replace('\r', ' ');
    descripcion = descripcion.replace('\n', ' ');
    descripcion = descripcion.replace('\t', ' ');
    descripcion = descripcion.replace('>', '-');
    descripcion = descripcion.replace('@', '-');

    /* Limitamos el tamao de la descripcin del error */
    if (descripcion.length() > 300)
        descripcion = descripcion.substring(0, 300);

    // Se comprueba el valor del campo codigo para concatenarlo a la
    // descripcion

    if (registroTarea.getCodigo() != null) {
        Locale locale = new Locale(LdapUserDetailsUtils.getIdioma());
        ResourceBundle ficheroRecursos = this.getFicherRecursos(locale);
        String codigo;

        //Controlamos que el codigo no este en el fichero de internacionalizacion
        try {
            codigo = ficheroRecursos.getString(registroTarea.getCodigo());
            log.debug("El codigo de la tarea ejecutada es " + registroTarea.getCodigo());
        } catch (Exception e) {
            codigo = " ";
            log.debug("El codigo de la tarea ejecutada no esta internacionalizado");
        }
        registroTareaDate.setDescripcion(descripcion + ". " + codigo);
    } else {
        log.debug("El codigo de la tarea ejecutada es null");
        registroTareaDate.setDescripcion(descripcion);
    }
    registroTareaDate.setFecha(registroTarea.getFecha().getTime());
    // registroTareaDate.setId(registroTarea.getId());
    registroTareaDate.setId(idTarea);

    if (registroTarea.getEstado() != null) {
        if (registroTarea.getEstado().equals("OK"))
            registroTareaDate.setEstado(ficheroRecursos.getString("tareas.OK"));
        else
            registroTareaDate.setEstado(ficheroRecursos.getString("tareas.ERROR"));
    } else
        registroTareaDate.setEstado(" ");

    return registroTareaDate;
}

From source file:ispok.pres.bb.VisitorEdit.java

public void delete() {
    visitorService.deleteVisitor(selectedVisitor.getId());

    FacesContext fc = FacesContext.getCurrentInstance();
    Locale l = fc.getViewRoot().getLocale();
    ResourceBundle rb = ResourceBundle.getBundle("ispok/pres/inter/ispok", l);
    fc.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, rb.getString("visitor_delete_success"),
            selectedVisitor.getFirstName() + " " + selectedVisitor.getLastName()));

}

From source file:org.apache.sling.i18n.it.ResourceBundleProviderIT.java

private void assertMessages(final String key, final String deMessage, final String deDeMessage,
        final String frMessage) {
    new Retry(RETRY_TIMEOUT_MSEC) {
        @Override// www.  j a  va2 s.c  o m
        protected void exec() {
            {
                final ResourceBundle deDE = resourceBundleProvider.getResourceBundle(Locale.GERMANY); // this is the resource bundle for de_DE
                assertNotNull(deDE);
                assertEquals(deDeMessage, deDE.getString(key));
            }
            {
                final ResourceBundle de = resourceBundleProvider.getResourceBundle(Locale.GERMAN);
                assertNotNull(de);
                assertEquals(deMessage, de.getString(key));
            }
            {
                final ResourceBundle fr = resourceBundleProvider.getResourceBundle(Locale.FRENCH);
                assertNotNull(fr);
                assertEquals(frMessage, fr.getString(key));
            }
        }
    };
}

From source file:com.exlibris.dps.delivery.vpp.mirador.MiradorViewerPreProcessor.java

private void updateProgressBar(int index) throws Exception {
    if (index % 10 == 0) {
        if (this.progressBarMessage == null) {
            Locale locale = new Locale(SessionUtils.getSessionLanguage());
            ResourceBundle resourceBundle = CodeTablesResourceBundle.getDefaultBundle(locale);
            this.progressBarMessage = resourceBundle.getString("delivery.progressBar.bookReaderMessage");

        }/*from   www .j  a  v a  2  s. c o  m*/
        getAccess().updateProgressBar(getDvs(), this.progressBarMessage,
                Integer.valueOf(index * 100 / this.filesPid.size()).intValue());
    }
}

From source file:es.pode.empaquetador.presentacion.basico.asociar.archivos.AsociacionArchivosControllerImpl.java

/**
 * @see es.pode.empaquetador.presentacion.basico.asociar.archivos.AsociacionArchivosController#submit(org.apache.struts.action.ActionMapping, es.pode.empaquetador.presentacion.basico.asociar.archivos.SubmitForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *///ww  w. j a  v  a2 s .c om
public final java.lang.String submit(ActionMapping mapping,
        es.pode.empaquetador.presentacion.basico.asociar.archivos.SubmitForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);
    String accion = form.getAction();
    String resultado = null;

    if (accion.equals(i18n.getString("portalempaquetado.Aceptar"))) {
        resultado = "Aceptar";
    } else {
        resultado = "Cancelar";
    }
    return resultado;
}