public String getRawText(String key) { return propertiesResource.getString(key); }
@Override public String resolveText(String s, Serializable[] serializables) { return new MessageFormat(propertiesResource.getString(s)).format(serializables); }
public boolean resourceExists(String value) { if (bundle == null) return false; try { bundle.getString(value.trim().substring(1)); return true; } catch (MissingResourceException e) { return false; } }
protected Object handleGetObject(String key) { String value = (String) bundle.getString(key); if (value == null) return null; try { return new String(value.getBytes("ISO-8859-1"), "UTF-8"); } catch (UnsupportedEncodingException e) { // Shouldn't fail - but should we still add logging message? return null; } }
public boolean resourceExists(String value) { if (bundle == null) return false; try { bundle.getString(value.trim().substring(1)); return true; } catch (MissingResourceException e) { return false; } }
@Override protected Object handleGetObject(final String key) { final String value = bundle.getString(key); if (value == null) return null; try { return new String(value.getBytes(ISO_8859_1), UTF_8); } catch (final UnsupportedEncodingException e) { throw new RuntimeException("Encoding not supported", e); } } }
@BeforeClass public static void bootStrap() throws Exception { PropertyResourceBundle prop = (PropertyResourceBundle) ResourceBundle.getBundle(PROPERTIES); String username = prop.getString("fedora.admin.username"); String password = prop.getString("fedora.admin.password"); String fedoraUrl = prop.getString("fedora.url"); logger.debug("Initialising HttpUtils..."); httpUtils = new HttpUtils(fedoraUrl, username, password); }
@Override protected Object handleGetObject(final String key) { String value = innerBundle.getString(key); if (value == null) { return null; } try { // Do a no-brained Transcoding from the PropertyResourceBundle hard-coded encoding to UTF-8. return new String(value.getBytes(ISO_ENCODING), UTF_ENCODING); } catch (final UnsupportedEncodingException e) { throw new IllegalStateException("Could not transcode ISO-8859-1 to UTF-8", e); } } }
private String getString(String key, Object params[]) { try { if ((params != null) && (params.length > 0)) { return MessageFormat.format(RESOURCE_BUNDLE.getString(key), params).trim(); } else { return RESOURCE_BUNDLE.getString(key).trim(); } } catch (MissingResourceException e) { throw new MissingGUIPropertyException(key, actualBundleName); } catch (IllegalArgumentException ie) { throw ie; } }
private String getString(String key, Object params[]) { try { if ((params != null) && (params.length > 0)) { return MessageFormat.format(RESOURCE_BUNDLE.getString(key), params).trim(); } else { return RESOURCE_BUNDLE.getString(key).trim(); } } catch (MissingResourceException e) { throw new MissingGUIPropertyException(key, actualBundleName); } catch (IllegalArgumentException ie) { throw ie; } }
public static String getString(String propertyName, Object... obj) { String pluginString = PluginRes.getI18nRes(propertyName); String str = pluginString != null ? pluginString : prb.getString(propertyName); if (str == null) { return propertyName; } return MessageFormat.format(str, obj); }
@Override protected Object handleGetObject (final String sKey) { final String sValue = m_aBundle.getString (sKey); // This does the main trick of converting the String to UTF-8 return CharsetManager.getAsStringInOtherCharset (sValue, CCharset.CHARSET_ISO_8859_1_OBJ, CCharset.CHARSET_UTF_8_OBJ); } }
private String fetch(String name, String def) { if(vRes == null) return def; try { String s = vRes.getString(name); if(ok(s)) return s; } catch(Exception e) { // def is already set... } return def; }
@BeforeClass public static void bootStrap() throws Exception { PropertyResourceBundle prop = (PropertyResourceBundle) ResourceBundle.getBundle(PROPERTIES); String username = prop.getString("fedora.admin.username"); String password = prop.getString("fedora.admin.password"); logger.debug("Initialising HttpUtils..."); httpUtils = new HttpUtils(getBaseURL(), username, password); }
/** * COnstructor. * * @param configAsStream * stream with configuration contents * @throws IOException * thrown when I/O error occurs */ public PlayerConfig(InputStream configAsStream) throws IOException { super.init(); PropertyResourceBundle bundle = new PropertyResourceBundle(configAsStream); for (String key : bundle.keySet()) { properties.put(key, bundle.getString(key)); } }
public static String getString(String propertyName) { try { String pluginString = PluginRes.getI18nRes(propertyName); return pluginString != null ? pluginString : prb.getString(propertyName); } catch (Exception e) { Log.error(e); return propertyName; } }
private void loadPluginResources( String resourceName, ResourceType type ) { try { PropertyResourceBundle prbPlugin = (PropertyResourceBundle) ResourceBundle.getBundle( resourceName, Locale.getDefault(), classLoader ); for ( String key : prbPlugin.keySet() ) { PluginRes.putRes( key, prbPlugin.getString( key ), type ); } } catch ( Exception ex ) { Log.debug( resourceName + " is not overwritten in plugin " ); } }
public static void appendErrorAsString(StringBuffer messageBuilder, InputError error) { new MessageFormat(GENERAL_MESSAGE_BUNDLE.getString("error_as_string")).format(new Object[] { formatErrorCodeName(error.getErrorCode()), /* Error code/package */ getErrorMessage(error) /* Error Message */ }, messageBuilder, null); FrozenSlice errorSlice = error.getSlice(); if (errorSlice!=null) { appendSliceContext(messageBuilder, errorSlice); } }
public static void appendErrorAsString(StringBuffer messageBuilder, InputError error) { new MessageFormat(GENERAL_MESSAGE_BUNDLE.getString("error_as_string")).format(new Object[] { formatErrorCodeName(error.getErrorCode()), /* Error code/package */ getErrorMessage(error) /* Error Message */ }, messageBuilder, null); FrozenSlice errorSlice = error.getSlice(); if (errorSlice!=null) { appendSliceContext(messageBuilder, errorSlice); } }
public static void appendErrorAsString(StringBuffer messageBuilder, InputError error) { new MessageFormat(GENERAL_MESSAGE_BUNDLE.getString("error_as_string")).format(new Object[] { formatErrorCodeName(error.getErrorCode()), /* Error code/package */ getErrorMessage(error) /* Error Message */ }, messageBuilder, null); FrozenSlice errorSlice = error.getSlice(); if (errorSlice!=null) { appendSliceContext(messageBuilder, errorSlice); } }