Java Code Examples for java.util.MissingResourceException

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project core_4, under directory /api/src/main/java/org/richfaces/l10n/.

Source file: BundleLoader.java

  33 
vote

public ResourceBundle getApplicationBundle(FacesContext facesContext,Enum<?> messageKey,Locale locale) throws MissingResourceException {
  if (facesContext == null) {
    throw new MissingResourceException("FacesContext is null",getClass().getName(),messageKey.toString());
  }
  Application application=facesContext.getApplication();
  if (application == null || application.getMessageBundle() == null) {
    throw new MissingResourceException("Cannot read message bundle name from application",getClass().getName(),messageKey.toString());
  }
  return ResourceBundle.getBundle(application.getMessageBundle(),locale,getClassLoader());
}
 

Example 2

From project harmony, under directory /harmony.common.utils/src/main/java/org/opennaas/core/utils/.

Source file: Config.java

  31 
vote

/** 
 * @param propertyFile
 * @param key
 * @return
 */
private static String getStringFromBundle(final String propertyFile,final String key){
  final ResourceBundle bundle=ResourceBundle.getBundle(Config.PROPERTIES_DIR + propertyFile);
  try {
    return bundle.getString(key).trim();
  }
 catch (  MissingResourceException exception) {
    throw new MissingResourceException("Could not find '" + key + "' in '"+ propertyFile+ "'. Details: "+ exception.getMessage(),exception.getClassName(),exception.getKey());
  }
}
 

Example 3

From project jsword, under directory /src/main/java/org/crosswire/common/util/.

Source file: ResourceUtil.java

  31 
vote

/** 
 * Generic resource URL fetcher. One way or the other we'll find it! Either as a relative or an absolute reference.
 * @param clazz The resource to find
 * @return The requested resource
 * @throws MissingResourceException if the resource can not be found
 */
public static <T>URL getResource(Class<T> clazz,String resourceName) throws MissingResourceException {
  URL resource=CWClassLoader.instance(clazz).findResource(resourceName);
  if (resource == null) {
    throw new MissingResourceException(JSOtherMsg.lookupText("Cannot find resource: {0}",resourceName),clazz.getName(),resourceName);
  }
  return resource;
}
 

Example 4

From project empire-db, under directory /empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/.

Source file: TextResolver.java

  30 
vote

public String resolveKey(String key){
  try {
    String res=resBundle.getString(key);
    if (res == null)     throw new MissingResourceException("Message Key not found.",String.class.getSimpleName(),key);
    return res;
  }
 catch (  MissingResourceException e) {
    log.error("Message key missing '{}'.",key);
    return "[" + key + "]";
  }
catch (  Exception e) {
    log.error("Error resolving text: {}",e);
    return "[" + key + "]";
  }
}
 

Example 5

From project ExperienceMod, under directory /ExperienceMod/src/com/comphenix/xp/.

Source file: ExperienceMod.java

  30 
vote

public YamlConfiguration loadConfig(String name,String createMessage) throws IOException {
  File savedFile=new File(getDataFolder(),name);
  File directory=savedFile.getParentFile();
  if (!savedFile.exists()) {
    InputStream input=null;
    OutputStream output=null;
    try {
      input=ExperienceMod.class.getResourceAsStream("/" + name);
      if (input == null) {
        throw new MissingResourceException("Cannot find built in resource file.","ExperienceMod",name);
      }
      if (!directory.exists()) {
        directory.mkdirs();
        if (!directory.exists())         throw new IOException("Could not create the directory " + directory.getAbsolutePath());
      }
      output=new FileOutputStream(savedFile);
      copyLarge(input,output);
    }
 catch (    IOException e) {
      throw e;
    }
 finally {
      if (input != null)       input.close();
      if (output != null)       output.close();
    }
  }
  return YamlConfiguration.loadConfiguration(savedFile);
}
 

Example 6

From project jboss-jstl-api_spec, under directory /src/main/java/org/apache/taglibs/standard/lang/jstl/.

Source file: Constants.java

  30 
vote

/** 
 */
public static String getStringResource(String pResourceName) throws MissingResourceException {
  try {
    String ret=sResources.getString(pResourceName);
    if (ret == null) {
      String str="ERROR: Unable to load resource " + pResourceName;
      System.err.println(str);
      throw new MissingResourceException(str,"org.apache.taglibs.standard.lang.jstl.Constants",pResourceName);
    }
 else {
      return ret;
    }
  }
 catch (  MissingResourceException exc) {
    System.err.println("ERROR: Unable to load resource " + pResourceName + ": "+ exc);
    throw exc;
  }
}
 

Example 7

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala.editor/src-gen/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/model/scala/presentation/.

Source file: ScalaModelWizard.java

  29 
vote

/** 
 * Returns the label for the specified type name. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected String getLabel(String typeName){
  try {
    return ScalaEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type");
  }
 catch (  MissingResourceException mre) {
    ScalaEditorPlugin.INSTANCE.log(mre);
  }
  return typeName;
}
 

Example 8

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.webapp.editor/src-gen/org/eclipse/acceleo/tutorial/webapp/presentation/.

Source file: WebappModelWizard.java

  29 
vote

/** 
 * Returns the label for the specified type name. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected String getLabel(String typeName){
  try {
    return WebappEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type");
  }
 catch (  MissingResourceException mre) {
    WebappEditorPlugin.INSTANCE.log(mre);
  }
  return typeName;
}
 

Example 9

From project agile, under directory /agile-framework/src/main/java/org/apache/naming/.

Source file: StringManager.java

  29 
vote

/** 
 * Get a string from the underlying resource bundle.
 * @param key 
 */
public String getString(String key){
  if (key == null) {
    String msg="key is null";
    throw new NullPointerException(msg);
  }
  String str=null;
  try {
    str=bundle.getString(key);
  }
 catch (  MissingResourceException mre) {
    str="Cannot find message associated with key '" + key + "'";
  }
  return str;
}
 

Example 10

From project agorava-core, under directory /agorava-core-impl/src/main/java/org/agorava/core/oauth/scribe/.

Source file: OAuthProviderScribe.java

  29 
vote

/** 
 * This methods tries to get Scribe  {@link Api} class from Social Media NameIt tries first to open a bundle with the provided name to look for an apiClass key. <p/> If it doesn't found this bundle or key it will try to build class name with the scribe package name for API as prefix and Api as suffix. <p/> If none of the above solution works the method throws an exception
 * @param serviceName name of the Social Media
 * @return Scribe API class
 * @throws AgoravaException if the class cannot be found
 */
@SuppressWarnings("unchecked") protected Class<? extends Api> getApiClass(String serviceName){
  String className;
  try {
    ResourceBundle rb=ResourceBundle.getBundle(serviceName);
    className=rb.getString(API_CLASS);
  }
 catch (  MissingResourceException e) {
    logger.info("Found no bundle for service {}",serviceName);
    className=SCRIBE_API_PREFIX + serviceName + SCRIBE_API_SUFFIX;
  }
  try {
    return (Class<? extends Api>)Class.forName(className);
  }
 catch (  ClassNotFoundException e) {
    throw new AgoravaException("There no such Scribe Api class " + className,e);
  }
}
 

Example 11

From project ajah, under directory /ajah-util/src/main/java/com/ajah/util/text/.

Source file: LocaleUtils.java

  29 
vote

/** 
 * Returns the locale matching the specified search criteria.
 * @see Locale#getISO3Country()
 * @see Locale#getDisplayName()
 * @param code The code or name of the Locale
 * @return The matching Locale, or null if no matches are found.
 */
public static Locale getLocale(final String code){
  AjahUtils.requireParam(code,"code");
  final String upperCode=code.toUpperCase();
  for (  final Locale locale : Locale.getAvailableLocales()) {
    try {
      if (upperCode.equals(locale.getISO3Country())) {
        return locale;
      }
      if (upperCode.equals(locale.getDisplayName())) {
        return locale;
      }
    }
 catch (    final MissingResourceException e) {
      log.log(Level.WARNING,e.getMessage(),e);
    }
  }
  return null;
}
 

Example 12

From project alg-vis, under directory /src/algvis/internationalization/.

Source file: Languages.java

  29 
vote

public static String getString(String s){
  try {
    return all_msgs[current_lang].getString(s);
  }
 catch (  MissingResourceException e) {
    System.err.println(e.getMessage() + ": " + s);
    return "???";
  }
}
 

Example 13

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/mysql/jdbc/.

Source file: Messages.java

  29 
vote

/** 
 * Returns the localized message for the given message key
 * @param key the message key
 * @return The localized message for the key
 */
public static String getString(String key){
  if (RESOURCE_BUNDLE == null) {
    throw new RuntimeException("Localized messages from resource bundle '" + BUNDLE_NAME + "' not loaded during initialization.");
  }
  try {
    if (key == null) {
      throw new IllegalArgumentException("Message key can not be null");
    }
    String message=RESOURCE_BUNDLE.getString(key);
    if (message == null) {
      message="Missing error message for key '" + key + "'";
    }
    return message;
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 14

From project and-bible, under directory /jsword-tweaks/src/main/java/jsword/org/crosswire/common/util/.

Source file: Languages.java

  29 
vote

/** 
 * Determine whether the language code is valid. The code is valid if it is null or empty. The code is valid if it is in iso639.properties. If a locale is used for the iso639Code, it will use the part before the '_'. Thus, this code does not support dialects, except as found in the iso639.
 * @param iso639Code
 * @return true if the language is valid.
 */
public static boolean isValidLanguage(String iso639Code){
  try {
    String code=getLanguageCode(iso639Code);
    if (DEFAULT_LANG_CODE.equals(code) || UNKNOWN_LANG_CODE.equals(code)) {
      return true;
    }
    commonLangs.getString(code);
    return true;
  }
 catch (  MissingResourceException e) {
    return false;
  }
}
 

Example 15

From project Archimedes, under directory /br.org.archimedes.offset/src/br/org/archimedes/offset/.

Source file: Messages.java

  29 
vote

public static String getString(String key){
  try {
    return RESOURCE_BUNDLE.getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 16

From project Arecibo, under directory /agent/src/main/java/com/ning/arecibo/agent/guice/.

Source file: AgentConfig.java

  29 
vote

@Config("arecibo.tools.coremonitor.http_user_agent") public String getHTTPUserAgent(){
  try {
    ResourceBundle bundle=ResourceBundle.getBundle("user-agent");
    String userAgent=bundle.getString("user_agent");
    return userAgent;
  }
 catch (  MissingResourceException mrEx) {
    throw new RuntimeException(mrEx);
  }
}
 

Example 17

From project asterisk-java, under directory /src/main/java/org/asteriskjava/fastagi/.

Source file: DefaultAgiServer.java

  29 
vote

private void loadConfig(){
  final ResourceBundle resourceBundle;
  try {
    resourceBundle=ResourceBundle.getBundle(configResourceBundleName);
  }
 catch (  MissingResourceException e) {
    return;
  }
  try {
    String portString;
    try {
      portString=resourceBundle.getString("port");
    }
 catch (    MissingResourceException e) {
      portString=resourceBundle.getString("bindPort");
    }
    port=Integer.parseInt(portString);
  }
 catch (  Exception e) {
  }
  try {
    setPoolSize(Integer.parseInt(resourceBundle.getString("poolSize")));
  }
 catch (  Exception e) {
  }
  try {
    setMaximumPoolSize(Integer.parseInt(resourceBundle.getString("maximumPoolSize")));
  }
 catch (  Exception e) {
  }
}
 

Example 18

From project b3log-latke, under directory /latke/src/main/java/org/b3log/latke/service/.

Source file: LangPropsService.java

  29 
vote

/** 
 * Gets all language properties as a map by the specified locale.
 * @param locale the specified locale
 * @return a map of language configurations
 */
public Map<String,String> getAll(final Locale locale){
  Map<String,String> ret=LANGS.get(locale);
  if (null == ret) {
    ret=new HashMap<String,String>();
    ResourceBundle langBundle=null;
    try {
      langBundle=ResourceBundle.getBundle(Keys.LANGUAGE,locale);
    }
 catch (    final MissingResourceException e) {
      LOGGER.log(Level.WARNING,"{0}, using default locale[{1}] instead",new Object[]{e.getMessage(),Latkes.getLocale()});
      try {
        langBundle=ResourceBundle.getBundle(Keys.LANGUAGE,Latkes.getLocale());
      }
 catch (      final MissingResourceException ex) {
        LOGGER.log(Level.WARNING,"{0}, using default lang.properties instead",new Object[]{e.getMessage()});
        langBundle=ResourceBundle.getBundle(Keys.LANGUAGE);
      }
    }
    final Enumeration<String> keys=langBundle.getKeys();
    while (keys.hasMoreElements()) {
      final String key=keys.nextElement();
      final String value=langBundle.getString(key);
      ret.put(key,value);
    }
    LANGS.put(locale,ret);
  }
  return ret;
}
 

Example 19

From project basiclti-portlet, under directory /src/main/java/au/edu/anu/portal/portlets/basiclti/utils/.

Source file: Messages.java

  29 
vote

private static String getMessage(String key){
  try {
    return ResourceBundle.getBundle(BUNDLE_NAME,Locale.getDefault()).getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 20

From project blog_1, under directory /stat4j/src/net/sourceforge/stat4j/util/.

Source file: Util.java

  29 
vote

public static String getValue(String key){
  try {
    return bundle.getString(key);
  }
 catch (  MissingResourceException e) {
    return null;
  }
}
 

Example 21

From project bpelunit, under directory /net.bpelunit.framework.client.command/src/main/java/net/bpelunit/framework/ui/command/.

Source file: Messages.java

  29 
vote

public static String getString(String key){
  try {
    return RESOURCE_BUNDLE.getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 22

From project ceylon-ide-eclipse, under directory /plugins/com.redhat.ceylon.eclipse.ui/src/com/redhat/ceylon/eclipse/code/editor/.

Source file: FoldingMessages.java

  29 
vote

/** 
 * Returns the resource string associated with the given key in the resource bundle. If there isn't  any value under the given key, the key is returned.
 * @param key the resource key
 * @return the string
 */
public static String getString(String key){
  try {
    return RESOURCE_BUNDLE.getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 23

From project Chess_1, under directory /src/chess/gui/.

Source file: WorldFrame.java

  29 
vote

/** 
 * Displays an error message
 * @param t the throwable that describes the error
 * @param resource the resource whose .text/.title strings should be used in the dialog
 */
public void showError(Throwable t,String resource){
  String text;
  try {
    text=resources.getString(resource + ".text");
  }
 catch (  MissingResourceException e) {
    text=resources.getString("error.text");
  }
  String title;
  try {
    title=resources.getString(resource + ".title");
  }
 catch (  MissingResourceException e) {
    title=resources.getString("error.title");
  }
  String reason=resources.getString("error.reason");
  String message=text + "\n" + MessageFormat.format(reason,new Object[]{t});
  JOptionPane.showMessageDialog(this,message,title,JOptionPane.ERROR_MESSAGE);
}
 

Example 24

From project cipango, under directory /cipango-console/src/main/java/org/cipango/console/util/.

Source file: PrinterUtil.java

  29 
vote

private static String[] getValueSplit(String name){
  try {
    return PARAMETERS.getString(name).split("\\p{Space}*,\\p{Space}*");
  }
 catch (  MissingResourceException e) {
    return null;
  }
}
 

Example 25

From project CIShell, under directory /templates/org.cishell.templates.wizards/src/org/cishell/templates/wizards/.

Source file: Activator.java

  29 
vote

/** 
 * The constructor
 */
public Activator(){
  plugin=this;
  try {
    resourceBundle=ResourceBundle.getBundle(Activator.class.getName());
  }
 catch (  MissingResourceException x) {
    resourceBundle=null;
  }
}
 

Example 26

From project coala, under directory /modules/coala-ipf/coala-ipf-xds/src/main/java/org/openehealth/coala/xds/.

Source file: XDSTransactorImpl.java

  29 
vote

private SubmissionSet createSubmissionSet(Identifiable patientID,Author author) throws XDSConfigurationErrorException {
  try {
    SubmissionSet submissionSet=new SubmissionSet();
    submissionSet.getAuthors().add(author);
    submissionSet.setAvailabilityStatus(AvailabilityStatus.APPROVED);
    String langCode=xdsConfiguration.getConsentLanguageCode();
    Code code=new Code(xdsConfiguration.getConsentDocumentTypeCodeCode(),new LocalizedString(xdsConfiguration.getConsentDocumentTypeCodeDisplayname(),langCode,encoding),xdsConfiguration.getConsentDocumentTypeCodeSchemename());
    submissionSet.setContentTypeCode(code);
    submissionSet.setEntryUuid("submissionSet" + submissionSetCounter);
    submissionSetCounter++;
    submissionSet.setPatientId(patientID);
    submissionSet.setSourceId(xdsConfiguration.getDocumentsourceOid());
    submissionSet.setSubmissionTime(pxsDateConverter.DateToString(new Date()));
    submissionSet.setTitle(new LocalizedString(xdsConfiguration.getDefaultSubmissionSetTitle(),langCode,encoding));
    String uniqueSubId=xdsConfiguration.getSubmissionSetBaseUniqueId();
    uniqueSubId+="." + patientID.getId() + "."+ pxsDateConverter.DateToString(new Date());
    submissionSet.setUniqueId(uniqueSubId);
    return submissionSet;
  }
 catch (  MissingResourceException e) {
    throw new XDSConfigurationErrorException("Configuration file seems to be corrupted. Check for missing properties.",e);
  }
catch (  ClassCastException e2) {
    throw new XDSConfigurationErrorException("Configuration file seems to be corrupted. Check for missing properties.",e2);
  }
}
 

Example 27

From project cp-common-utils, under directory /src/com/clarkparsia/common/base/.

Source file: FormattingResourceBundle.java

  29 
vote

/** 
 * Return the string from the  {@link ResourceBundle}, optionally applying the provided args to the message via  {@link String#format}.
 * @param theKey the message key
 * @param theArgs the optiona list of args to apply to the message
 * @return the message or null if a value w/ the key does not exist
 */
public String get(final String theKey,final Object... theArgs){
  try {
    String aMsg=mResourceBundle.getString(theKey);
    if (aMsg == null) {
      return theKey;
    }
 else     if (theArgs != null && theArgs.length > 0) {
      return new MessageFormat(aMsg).format(theArgs);
    }
 else {
      return aMsg;
    }
  }
 catch (  MissingResourceException e) {
    return theKey;
  }
}
 

Example 28

From project data-access, under directory /src/org/pentaho/platform/dataaccess/datasource/wizard/service/messages/.

Source file: Messages.java

  29 
vote

public static String getString(final String key){
  try {
    return Messages.getBundle().getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 29

From project Database-Designer, under directory /plugins/org.obeonetwork.dsl.database.editor/src/org/obeonetwork/dsl/database/presentation/.

Source file: DatabaseModelWizard.java

  29 
vote

/** 
 * Returns the label for the specified type name. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected String getLabel(String typeName){
  try {
    return DatabaseEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type");
  }
 catch (  MissingResourceException mre) {
    DatabaseEditorPlugin.INSTANCE.log(mre);
  }
  return typeName;
}
 

Example 30

From project dawn-isenciaui, under directory /com.teaminabox.eclipse.wiki/src/com/teaminabox/eclipse/wiki/.

Source file: WikiPlugin.java

  29 
vote

private void initialiseResourceBundle(){
  try {
    resourceBundle=ResourceBundle.getBundle(WikiPlugin.RESOURCE_BUNDLE);
  }
 catch (  MissingResourceException e) {
    logAndReport("Error","The Resource Bundle is missing!!",e);
  }
}
 

Example 31

From project db2triples, under directory /src/main/java/net/antidot/semantic/rdf/model/tools/.

Source file: RDFDataValidator.java

  29 
vote

/** 
 * TODO
 * @param languageTag
 * @return
 */
public static boolean isValidLanguageTag(String languageTag){
  try {
    String[] split=languageTag.split("-");
    if (split.length > 2)     return false;
 else {
      if (split.length == 1) {
        Locale l=new Locale(languageTag);
        l.getISO3Language();
      }
 else {
        String languageCode=split[0];
        String countryCode=split[1];
        Locale l=new Locale(languageCode,countryCode);
        l.getISO3Language();
        l.getISO3Country();
      }
    }
  }
 catch (  MissingResourceException e) {
    return false;
  }
  return true;
}
 

Example 32

From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/.

Source file: Category.java

  29 
vote

/** 
 * Returns the string resource coresponding to <code>key</code> in this category's inherited resource bundle. See also  {@link #getResourceBundle}. <p>If the resource cannot be found, then an  {@link #error error}message will be logged complaining about the missing resource.
 */
protected String getResourceBundleString(String key){
  ResourceBundle rb=getResourceBundle();
  if (rb == null) {
    return null;
  }
 else {
    try {
      return rb.getString(key);
    }
 catch (    MissingResourceException mre) {
      error("No resource is associated with key \"" + key + "\".");
      return null;
    }
  }
}
 

Example 33

From project dolphin, under directory /com.sysdeo.eclipse.tomcat/src/com/sysdeo/eclipse/tomcat/.

Source file: TomcatLauncherPlugin.java

  29 
vote

/** 
 * The constructor.
 */
public TomcatLauncherPlugin(IPluginDescriptor descriptor){
  super(descriptor);
  plugin=this;
  try {
    resourceBundle=PropertyResourceBundle.getBundle("resources");
  }
 catch (  MissingResourceException x) {
    resourceBundle=null;
  }
  this.getWorkspace().addResourceChangeListener(new TomcatProjectChangeListener(),IResourceChangeEvent.PRE_DELETE);
}
 

Example 34

From project dozer, under directory /eclipse-plugin/net.sf.dozer.eclipse.plugin/src/org/dozer/eclipse/plugin/.

Source file: DozerPlugin.java

  29 
vote

/** 
 * The constructor.
 */
public DozerPlugin(){
  plugin=this;
  try {
    resourceBundle=ResourceBundle.getBundle("org.dozer.eclipse.plugin.DozerPluginResources");
  }
 catch (  MissingResourceException x) {
    resourceBundle=null;
  }
}
 

Example 35

From project droolsjbpm-tools, under directory /drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/.

Source file: DroolsEclipsePlugin.java

  29 
vote

/** 
 * Returns the string from the plugin's resource bundle, or 'key' if not found.
 */
public static String getResourceString(String key){
  ResourceBundle bundle=DroolsEclipsePlugin.getDefault().getResourceBundle();
  try {
    return (bundle != null) ? bundle.getString(key) : key;
  }
 catch (  MissingResourceException e) {
    return key;
  }
}
 

Example 36

From project echo2, under directory /src/exampleapp/chatclient/src/java/echo2example/chatclient/.

Source file: Messages.java

  29 
vote

/** 
 * Returns localized text.
 * @param key the key of the text to be returned
 * @return the appropriate localized text (if the key is not defined, the string "!key!" is returned)
 */
public static String getString(String key){
  try {
    Locale locale=ApplicationInstance.getActive().getLocale();
    ResourceBundle resource=ResourceBundle.getBundle(BUNDLE_NAME,locale);
    return resource.getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 37

From project echo3, under directory /src/server-java-examples/chatclient/src/java/chatclient/.

Source file: Messages.java

  29 
vote

/** 
 * Returns localized text.
 * @param key the key of the text to be returned
 * @return the appropriate localized text (if the key is not defined, the string "!key!" is returned)
 */
public static String getString(String key){
  try {
    Locale locale=ApplicationInstance.getActive().getLocale();
    ResourceBundle resource=ResourceBundle.getBundle(BUNDLE_NAME,locale);
    return resource.getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 38

From project eclim, under directory /org.eclim/java/org/eclim/.

Source file: Services.java

  29 
vote

/** 
 * Retrieves and optionally formats a message for the supplied message key.
 * @param key The message key.
 * @param args Optional message args used when formatting the message.
 * @return The formatted message.
 */
public static String getMessage(String key,Object... args){
  for (  PluginResources resources : pluginResources.values()) {
    try {
      String message=resources.getMessage(key,args);
      return message;
    }
 catch (    MissingResourceException nsme) {
    }
  }
  return key;
}
 

Example 39

From project eclipse.platform.runtime, under directory /bundles/org.eclipse.e4.core.services/src/org/eclipse/e4/core/internal/services/.

Source file: BundleTranslationProvider.java

  29 
vote

public String getResourceString(String value,ResourceBundle resourceBundle){
  String s=value.trim();
  if (!s.startsWith(KEY_PREFIX,0))   return s;
  if (s.startsWith(KEY_DOUBLE_PREFIX,0))   return s.substring(1);
  int ix=s.indexOf(' ');
  String key=ix == -1 ? s : s.substring(0,ix);
  String dflt=ix == -1 ? s : s.substring(ix + 1);
  if (resourceBundle == null)   return dflt;
  try {
    return resourceBundle.getString(key.substring(1));
  }
 catch (  MissingResourceException e) {
    return dflt;
  }
}
 

Example 40

From project eclipsefp, under directory /net.sf.eclipsefp.haskell.scion.client/src/net/sf/eclipsefp/haskell/scion/client/.

Source file: ScionPlugin.java

  29 
vote

public static String getStringResource(String key){
  ScionPlugin p=getDefault();
  if (p != null) {
    try {
      return p.resourceBundle.getString(key);
    }
 catch (    MissingResourceException ex) {
      return key;
    }
  }
 else {
    return key;
  }
}
 

Example 41

From project EMF-IncQuery, under directory /tests/org.eclipse.viatra2.emf.incquery.snapshot.editor/src/org/eclipse/viatra2/emf/incquery/snapshot/EIQSnapshot/presentation/.

Source file: EIQSnapshotModelWizard.java

  29 
vote

/** 
 * Returns the label for the specified type name. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected String getLabel(String typeName){
  try {
    return EiqsnapshotEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type");
  }
 catch (  MissingResourceException mre) {
    EiqsnapshotEditorPlugin.INSTANCE.log(mre);
  }
  return typeName;
}
 

Example 42

From project eoit, under directory /EOITUtils/src/main/java/fr/eoit/util/dumper/property/.

Source file: RequestDefinitionParser.java

  29 
vote

public static List<RequestDefinitionBean> getRequests(){
  ResourceBundle bundle=ResourceBundle.getBundle(PROP_FILE);
  List<RequestDefinitionBean> result=new ArrayList<RequestDefinitionBean>();
  for (int id=1; id < MAX_REQS; id++) {
    RequestDefinitionBean request=new RequestDefinitionBean();
    request.id=id;
    try {
      if (bundle.getString("req" + id + ".name") != null) {
        request.name=bundle.getString("req" + id + ".name");
        request.sql=bundle.getString("req" + id + ".sql");
        request.fields=new ArrayList<String>();
        for (int i=0; i < MAX_FIELDS; i++) {
          try {
            String fieldName=bundle.getString("req" + id + ".field"+ i);
            if (fieldName != null) {
              request.fields.add(fieldName);
            }
          }
 catch (          MissingResourceException e) {
          }
        }
        request.table=bundle.getString("req" + id + ".table");
        request.fieldStrPos=getIntegerList(bundle.getString("req" + id + ".fieldStrPos"));
        request.copressedStrPos=getIntegerList(bundle.getString("req" + id + ".copressedStrPos"));
        result.add(request);
      }
    }
 catch (    MissingResourceException e) {
    }
  }
  return result;
}
 

Example 43

From project examples_1, under directory /helloworld/helloworld.blueprint/src/com/example/hello/impl/.

Source file: GreetingImpl.java

  29 
vote

public void setLanguage(String language){
  System.out.println("-------> Setting language to " + language);
  try {
    resources=ResourceBundle.getBundle(RESOURCE_BASE,new Locale(language),GreetingImpl.class.getClassLoader());
  }
 catch (  MissingResourceException e) {
    System.err.println("-------> No greeting available for language: " + language);
  }
}
 

Example 44

From project faces, under directory /Proyectos/upcdew-deportivoapp/src/java/com/upc/deportivo/util/.

Source file: FacesUtils.java

  29 
vote

public static String getMessageResourceString(String key,Object params[]){
  Locale locale=Locale.getDefault();
  String text=null;
  String bundleName=FacesContext.getCurrentInstance().getApplication().getMessageBundle();
  ResourceBundle bundle=null;
  if (params == null) {
    bundle=ResourceBundle.getBundle(bundleName,locale);
  }
 else {
    bundle=ResourceBundle.getBundle(bundleName,locale,getCurrentClassLoader(params));
  }
  try {
    text=bundle.getString(key);
  }
 catch (  MissingResourceException e) {
    text="?? key " + key + " not found ??";
  }
  if (params != null) {
    MessageFormat mf=new MessageFormat(text,locale);
    text=mf.format(params,new StringBuffer(),null).toString();
  }
  return text;
}
 

Example 45

From project formic, under directory /src/java/org/formic/.

Source file: Installer.java

  29 
vote

/** 
 * Gets the value for the supplied resource key.
 * @param key The key.
 * @return The value or null if not found.
 */
public static String getString(String key){
  try {
    return key != null ? getResourceBundle().getString(key) : null;
  }
 catch (  MissingResourceException mre) {
    return null;
  }
}
 

Example 46

From project fr.obeo.performance, under directory /fr.obeo.performance.editor/src-gen/fr/obeo/performance/presentation/.

Source file: PerformanceModelWizard.java

  29 
vote

/** 
 * Returns the label for the specified type name. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected String getLabel(String typeName){
  try {
    return PerformanceEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type");
  }
 catch (  MissingResourceException mre) {
    PerformanceEditorPlugin.INSTANCE.log(mre);
  }
  return typeName;
}
 

Example 47

From project framework, under directory /impl/core/src/main/java/br/gov/frameworkdemoiselle/util/.

Source file: ResourceBundle.java

  29 
vote

private java.util.ResourceBundle getDelegate(){
  if (delegate == null) {
    try {
      ClassLoader classLoader=Thread.currentThread().getContextClassLoader();
      delegate=ResourceBundle.getBundle(baseName,locale,classLoader);
    }
 catch (    MissingResourceException mre) {
      delegate=ResourceBundle.getBundle(baseName,locale);
    }
  }
  return delegate;
}
 

Example 48

From project gast-lib, under directory /JJIL-Android/src/jjil/android/.

Source file: Messages.java

  29 
vote

public static String getString(String key){
  try {
    return RESOURCE_BUNDLE.getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 49

From project gatein-common, under directory /common/src/main/java/org/gatein/common/i18n/.

Source file: ResourceBundleManager.java

  29 
vote

/** 
 * Return a localized value constructed from the various resource bundles. The supported locales of the manager are used in combination with the specified key. The default value is used if no value is found for the <code>Locale.ENGLISH</code>. Two successive calls to this method may not return identical results since the returned <code>LocalizedString</code> is built using the bundles known by the manager.
 * @param key          the key to lookup in the bundles
 * @param defaultValue the default value
 * @return the localized string
 * @throws IllegalArgumentException if the key of the default value is null
 */
public LocalizedString getLocalizedValue(String key,String defaultValue) throws IllegalArgumentException {
  if (key == null) {
    throw new IllegalArgumentException("No null key accepted");
  }
  if (defaultValue == null) {
    throw new IllegalArgumentException("No null default value accepted");
  }
  Map<Locale,String> m=new HashMap<Locale,String>();
  for (  Map.Entry<Locale,BundleRef> entry : localeBundles.entrySet()) {
    try {
      Locale locale=entry.getKey();
      ResourceBundle container=entry.getValue().bundle;
      if (container != null) {
        String localizedDisplayName=container.getString(key);
        m.put(locale,localizedDisplayName);
      }
    }
 catch (    MissingResourceException ignore) {
    }
  }
  if (!m.containsKey(Locale.ENGLISH)) {
    m.put(Locale.ENGLISH,defaultValue);
  }
  return new LocalizedString(m,Locale.ENGLISH);
}
 

Example 50

From project griffon, under directory /subprojects/griffon-rt/src/main/groovy/org/codehaus/griffon/runtime/core/i18n/.

Source file: AbstractMessageSource.java

  29 
vote

public String getMessage(String key,Object[] args,Locale locale) throws NoSuchMessageException {
  if (null == args)   args=EMPTY_OBJECT_ARGS;
  if (null == locale)   locale=Locale.getDefault();
  try {
    String message=resolveMessage(key,locale);
    return formatMessage(message,args);
  }
 catch (  MissingResourceException e) {
    throw new NoSuchMessageException(key,locale);
  }
}
 

Example 51

From project hama, under directory /core/src/main/java/org/apache/hama/bsp/.

Source file: Counters.java

  29 
vote

Group(String groupName){
  try {
    bundle=getResourceBundle(groupName);
  }
 catch (  MissingResourceException neverMind) {
  }
  this.groupName=groupName;
  this.displayName=localize("CounterGroupName",groupName);
}
 

Example 52

From project hibernate-validator, under directory /engine/src/main/java/org/hibernate/validator/messageinterpolation/.

Source file: ResourceBundleMessageInterpolator.java

  29 
vote

private String resolveParameter(String parameterName,ResourceBundle bundle,Locale locale,boolean recurse){
  String parameterValue;
  try {
    if (bundle != null) {
      parameterValue=bundle.getString(removeCurlyBrace(parameterName));
      if (recurse) {
        parameterValue=replaceVariables(parameterValue,bundle,locale,recurse);
      }
    }
 else {
      parameterValue=parameterName;
    }
  }
 catch (  MissingResourceException e) {
    parameterValue=parameterName;
  }
  return parameterValue;
}
 

Example 53

From project Hphoto, under directory /src/java/com/hphoto/util/.

Source file: I18nUtil.java

  29 
vote

public static String getText(String id,String key,Locale locale,Object[] args){
  String message="";
  try {
    ResourceBundle resourceBundle=ResourceBundle.getBundle(id,locale);
    String text=resourceBundle.getString(key);
    message=MessageFormat.format(text,args);
  }
 catch (  MissingResourceException e) {
  }
  return message;
}
 

Example 54

From project I18N4Vaadin, under directory /Sources/I18N4Vaadin/src/com/github/peholmst/i18n4vaadin/.

Source file: ResourceBundleI18N.java

  29 
vote

/** 
 * Gets the resource bundle for the current locale.
 * @return the resource bundle (never <code>null</code>).
 * @throws MissingResourceException if the resource bundle could not be located.
 * @throws IllegalStateException if no current locale has been set.
 */
protected ResourceBundle getCurrentBundle() throws MissingResourceException, IllegalStateException {
  if (getCurrentLocale() == null) {
    throw new IllegalStateException("null currentLocale");
  }
  if (currentBundle == null) {
    if (classLoader == null) {
      currentBundle=ResourceBundle.getBundle(baseName,getCurrentLocale());
    }
 else {
      currentBundle=ResourceBundle.getBundle(baseName,getCurrentLocale(),classLoader);
    }
  }
  return currentBundle;
}
 

Example 55

From project incubator-deltaspike, under directory /deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/message/.

Source file: DefaultMessageResolver.java

  29 
vote

@Override public String getMessage(MessageContext messageContext,String messageTemplate,String category){
  if (messageTemplate.startsWith("{{")) {
    return messageTemplate.substring(1);
  }
  if (messageTemplate.startsWith("{") && messageTemplate.endsWith("}")) {
    String resourceKey=messageTemplate.substring(1,messageTemplate.length() - 1);
    List<String> messageSources=messageContext.getMessageSources();
    if (messageSources == null || messageSources.isEmpty()) {
      return null;
    }
    Iterator<String> messageSourceIterator=messageSources.iterator();
    String currentMessageSource;
    while (messageSourceIterator.hasNext()) {
      currentMessageSource=messageSourceIterator.next();
      try {
        Locale locale=messageContext.getLocale();
        ResourceBundle messageBundle=PropertyFileUtils.getResourceBundle(currentMessageSource,locale);
        if (category != null && category.length() > 0) {
          try {
            return messageBundle.getString(resourceKey + "." + category);
          }
 catch (          MissingResourceException e) {
            messageBundle.getString(resourceKey);
          }
        }
        return messageBundle.getString(resourceKey);
      }
 catch (      MissingResourceException e) {
        if (!messageSourceIterator.hasNext()) {
          return null;
        }
      }
    }
  }
  return messageTemplate;
}
 

Example 56

From project interactive-self-assessment, under directory /org.eclipse.ui.examples.javaeditor/javaeditorexamplesrc/org/eclipse/ui/examples/javaeditor/java/.

Source file: JavaEditorMessages.java

  29 
vote

public static String getString(String key){
  try {
    return fgResourceBundle.getString(key);
  }
 catch (  MissingResourceException e) {
    return "!" + key + "!";
  }
}
 

Example 57

From project ipdburt, under directory /iddb-web/src/main/java/jipdbs/web/.

Source file: MessageResource.java

  29 
vote

public static String getMessage(String key,Object... args){
  try {
    String s=bundle.getString(key);
    if (args.length > 0) {
      return String.format(s,args);
    }
    return s;
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 58

From project isohealth, under directory /Oauth/java/jmeter/jmeter/src/main/java/org/apache/jmeter/protocol/oauth/control/gui/.

Source file: OAuthSamplerGui.java

  29 
vote

private static String getResStringDefault(String key,String defaultValue){
  if (key == null) {
    return null;
  }
  key=key.replace(' ','_');
  key=key.toLowerCase(java.util.Locale.ENGLISH);
  String resString=null;
  try {
    resString=resources.getString(key);
  }
 catch (  MissingResourceException mre) {
    log.warn("ERROR! Resource string not found: [" + key + "]",mre);
    resString=defaultValue;
  }
  return resString;
}
 

Example 59

From project ivyde, under directory /org.apache.ivyde.eclipse/src/java/org/apache/ivyde/common/model/.

Source file: IvyTag.java

  29 
vote

public String getDoc(){
  if (doc == null) {
    try {
      doc=DOC_RESOURCE.getString(getId());
    }
 catch (    MissingResourceException ex) {
      doc="";
    }
  }
  return doc;
}
 

Example 60

From project janus-plugin, under directory /janus-plugin-integration-test/src/test/java/de/codecentric/janus/plugin/suite/.

Source file: Config.java

  29 
vote

public static String getString(String key){
  try {
    return RESOURCE_BUNDLE.getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 61

From project jbosgi-framework, under directory /core/src/main/java/org/jboss/osgi/framework/internal/.

Source file: AbstractBundleState.java

  29 
vote

@Override @SuppressWarnings("unchecked") public Dictionary<String,String> getHeaders(String locale){
  Dictionary<String,String> rawHeaders=getOSGiMetaData().getHeaders();
  if ("".equals(locale))   return rawHeaders;
  if (locale == null)   locale=Locale.getDefault().toString();
  String baseName=rawHeaders.get(Constants.BUNDLE_LOCALIZATION);
  if (baseName == null)   baseName=Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME;
  URL entryURL=getLocalizationEntry(baseName,locale);
  if (entryURL == null) {
    String defaultLocale=Locale.getDefault().toString();
    entryURL=getLocalizationEntry(baseName,defaultLocale);
  }
  ResourceBundle resBundle=null;
  if (entryURL != null) {
    try {
      resBundle=new PropertyResourceBundle(entryURL.openStream());
    }
 catch (    IOException ex) {
      throw MESSAGES.illegalStateCannotReadResourceBundle(ex,entryURL);
    }
  }
  Dictionary<String,String> locHeaders=new Hashtable<String,String>();
  Enumeration<String> e=rawHeaders.keys();
  while (e.hasMoreElements()) {
    String key=e.nextElement();
    String value=rawHeaders.get(key);
    if (value.startsWith("%"))     value=value.substring(1);
    if (resBundle != null) {
      try {
        value=resBundle.getString(value);
      }
 catch (      MissingResourceException ex) {
      }
    }
    locHeaders.put(key,value);
  }
  return new CaseInsensitiveDictionary(locHeaders);
}
 

Example 62

From project jboss-el-api_spec, under directory /src/main/java/javax/el/.

Source file: ELUtil.java

  29 
vote

public static String getExceptionMessageString(ELContext context,String messageId,Object[] params){
  String result="";
  Locale locale=null;
  if (null == context || null == messageId) {
    return result;
  }
  if (null == (locale=context.getLocale())) {
    locale=Locale.getDefault();
  }
  if (null != locale) {
    Map threadMap=getCurrentInstance();
    ResourceBundle rb=null;
    if (null == (rb=(ResourceBundle)threadMap.get(locale.toString()))) {
      rb=ResourceBundle.getBundle("javax.el.PrivateMessages",locale);
      threadMap.put(locale.toString(),rb);
    }
    if (null != rb) {
      try {
        result=rb.getString(messageId);
        if (null != params) {
          result=MessageFormat.format(result,params);
        }
      }
 catch (      IllegalArgumentException iae) {
        result="Can't get localized message: parameters to message appear to be incorrect.  Message to format: " + messageId;
      }
catch (      MissingResourceException mre) {
        result="Missing Resource in EL implementation: ???" + messageId + "???";
      }
catch (      Exception e) {
        result="Exception resolving message in EL implementation: ???" + messageId + "???";
      }
    }
  }
  return result;
}
 

Example 63

From project jboss-logging, under directory /src/main/java/org/jboss/logging/.

Source file: JDKLogger.java

  29 
vote

protected void doLogf(final Level level,final String loggerClassName,String format,final Object[] parameters,final Throwable thrown){
  if (isEnabled(level))   try {
    final ResourceBundle resourceBundle=logger.getResourceBundle();
    if (resourceBundle != null)     try {
      format=resourceBundle.getString(format);
    }
 catch (    MissingResourceException e) {
    }
    final String msg=parameters == null ? String.format(format) : String.format(format,parameters);
    final JBossLogRecord rec=new JBossLogRecord(translate(level),msg,loggerClassName);
    if (thrown != null)     rec.setThrown(thrown);
    rec.setLoggerName(getName());
    rec.setResourceBundleName(logger.getResourceBundleName());
    rec.setResourceBundle(null);
    rec.setParameters(null);
    logger.log(rec);
  }
 catch (  Throwable ignored) {
  }
}
 

Example 64

From project jboss-logmanager, under directory /src/main/java/org/jboss/logmanager/.

Source file: ExtLogRecord.java

  29 
vote

private String formatRecord(){
  final ResourceBundle bundle=getResourceBundle();
  String msg=getMessage();
  if (msg == null)   return null;
  if (bundle != null) {
    try {
      String locMsg=bundle.getString(msg);
      resourceKey=msg;
      msg=locMsg;
    }
 catch (    MissingResourceException ex) {
    }
  }
  final Object[] parameters=getParameters();
  if (parameters == null || parameters.length == 0) {
    return msg;
  }
switch (formatStyle) {
case PRINTF:
{
      return String.format(msg,parameters);
    }
case MESSAGE_FORMAT:
{
    return msg.indexOf('{') >= 0 ? MessageFormat.format(msg,parameters) : msg;
  }
}
return msg;
}
 

Example 65

From project jchempaint, under directory /src/main/org/openscience/jchempaint/.

Source file: GT.java

  29 
vote

private String getString(String string){
  if (!doTranslate || translationResourcesCount == 0)   return string;
  for (int bundle=0; bundle < translationResourcesCount; bundle++) {
    try {
      String trans=translationResources[bundle].getString(string);
      return trans;
    }
 catch (    MissingResourceException e) {
    }
  }
  logger.info("No trans, using default: " + string);
  return string;
}
 

Example 66

From project jDcHub, under directory /jdchub-core/src/main/java/ru/sincore/i18n/.

Source file: Messages.java

  29 
vote

/** 
 * Return string message by key in given localeString
 * @param key       string key
 * @param localeString    locate in forms like ru_RU, en_US or so on
 * @return          string message by key or key value if message does not found
 */
public static String get(String key,String localeString){
  String result;
  if (localeString == null || localeString.isEmpty()) {
    localeString=defaultLocale;
  }
  if (!resourcesMap.containsKey(localeString)) {
    try {
      loadResources(localeString);
    }
 catch (    MalformedURLException e) {
      e.printStackTrace();
      return key;
    }
  }
  ResourceBundle resourceBundle=resourcesMap.get(localeString);
  try {
    result=resourceBundle.getString(key);
  }
 catch (  MissingResourceException e) {
    e.printStackTrace();
    result=key;
  }
  return result;
}
 

Example 67

From project jftp, under directory /src/main/java/com/myjavaworld/util/.

Source file: ResourceLoader.java

  29 
vote

public static ResourceBundle getBundle(String baseName,Locale locale){
  try {
    return ResourceBundle.getBundle(baseName,locale);
  }
 catch (  MissingResourceException exp) {
    exp.printStackTrace();
    fireResourceNotFound(baseName,locale);
    return null;
  }
}
 

Example 68

From project JGlobus, under directory /gram/src/main/java/org/globus/gram/.

Source file: GramException.java

  29 
vote

public static String getMessage(int errorCode){
  if (errorCode == SUCCESS) {
    return "Success";
  }
 else {
    if (resources == null)     return "Error code: " + errorCode;
    try {
      return resources.getString(String.valueOf(errorCode));
    }
 catch (    MissingResourceException mre) {
      return "Error code: " + errorCode;
    }
  }
}
 

Example 69

From project jgraphx, under directory /src/com/mxgraph/util/.

Source file: mxResources.java

  29 
vote

/** 
 * Returns the value for <code>key</code> by searching the resource bundles in inverse order or <code>null</code> if no value can be found for <code>key</code>.
 */
protected static String getResource(String key){
  Iterator<ResourceBundle> it=bundles.iterator();
  while (it.hasNext()) {
    try {
      return it.next().getString(key);
    }
 catch (    MissingResourceException mrex) {
    }
  }
  return null;
}
 

Example 70

From project jmeter-amf, under directory /src/protocol/amf/org/apache/jmeter/protocol/amf/util/.

Source file: AmfResources.java

  29 
vote

public static String getResString(String key){
  if (resources == null) {
    resources=ResourceBundle.getBundle("org.apache.jmeter.protocol.amf.resources.messages",JMeterUtils.getLocale());
  }
  try {
    return resources.getString(key);
  }
 catch (  MissingResourceException e) {
    log.warn("Missing resource string [res_key=" + key + "]",e);
    return "[res_key=" + key + "]";
  }
}
 

Example 71

From project JoshEdit, under directory /org/lateralgm/joshedit/.

Source file: Bindings.java

  29 
vote

/** 
 * @param key The translation to look up.
 * @param def The default text when no translation is found, or null if it should be found.
 * @return The translation if it exists, the default string if it doesn't, or an error string if neither is non-null.
 */
public static String getString(String key,String def){
  String r;
  try {
    r=TRANSLATE.getString(key);
  }
 catch (  MissingResourceException e) {
    r=def == null ? '!' + key + '!' : def;
  }
  return PREFS.get(key,r);
}
 

Example 72

From project JRebirth, under directory /org.jrebirth/core/src/main/java/org/jrebirth/core/i18n/.

Source file: JRebirthMessageManager.java

  29 
vote

/** 
 * Return the internationalized message.
 * @param message the key of the message
 * @param parameter optional parameters used for format
 * @return the formatted internationalized message
 */
public String get(final MessageReady message,final Object... parameter){
  String res=null;
  try {
    res=RESOURCE_BUNDLE.getString(message.getSymbolicName());
  }
 catch (  final MissingResourceException e) {
    res='<' + message.getSymbolicName() + '>';
  }
  return res;
}
 

Example 73

From project jSite, under directory /src/main/java/de/todesbaum/jsite/i18n/.

Source file: I18n.java

  29 
vote

/** 
 * Retrieves a translated text for the given i18n key. If the resource bundle for the current locale does not have a translation for the given key, the default locale is tried. If that fails, the key is returned.
 * @param key The key to get the translation for
 * @return The translated value, or the key itself if not translation can befound
 */
public static String getMessage(String key){
  try {
    return getResourceBundle().getString(key);
  }
 catch (  MissingResourceException mre1) {
    try {
      return getResourceBundle(defaultLocale).getString(key);
    }
 catch (    MissingResourceException mre2) {
      return key;
    }
  }
}
 

Example 74

From project juel, under directory /modules/api/src/main/java/javax/el/.

Source file: ResourceBundleELResolver.java

  29 
vote

/** 
 * If the base object is an instance of ResourceBundle, the provided property will first be coerced to a String. The Object returned by getObject on the base ResourceBundle will be returned. If the base is ResourceBundle, the propertyResolved property of the ELContext object must be set to true by this resolver, before returning. If this property is not true after this method is called, the caller should ignore the return value.
 * @param context The context of this evaluation.
 * @param base The bundle to analyze. Only bases of type ResourceBundle are handled by this resolver.
 * @param property The name of the property to analyze. Will be coerced to a String.
 * @return If the propertyResolved property of ELContext was set to true, then null if propertyis null; otherwise the Object for the given key (property coerced to String) from the ResourceBundle. If no object for the given key can be found, then the String "???" + key + "???".
 * @throws NullPointerException if context is null.
 * @throws ELException if an exception was thrown while performing the property or variable resolution. The thrown exception must be included as the cause property of this exception, if available.
 */
@Override public Object getValue(ELContext context,Object base,Object property){
  if (context == null) {
    throw new NullPointerException("context is null");
  }
  Object result=null;
  if (isResolvable(base)) {
    if (property != null) {
      try {
        result=((ResourceBundle)base).getObject(property.toString());
      }
 catch (      MissingResourceException e) {
        result="???" + property + "???";
      }
    }
    context.setPropertyResolved(true);
  }
  return result;
}
 

Example 75

From project jupload, under directory /src/wjhk/jupload2/upload/.

Source file: FileUploadThreadFTP.java

  29 
vote

/** 
 * Will set the binary/ascii value based on the parameters to the applet. This could be done by file extension too but it is not implemented.
 * @param index The index of the file that we want to upload, in the arrayof files to upload.
 * @throws IOException if an error occurs while setting mode data
 */
private void setTransferType(@SuppressWarnings("unused") int index) throws IOException {
  try {
    String binVal=this.uploadPolicy.getString("binary");
    if (Boolean.getBoolean(binVal))     this.ftp.setFileType(FTP.BINARY_FILE_TYPE);
 else     this.ftp.setFileType(FTP.ASCII_FILE_TYPE);
  }
 catch (  MissingResourceException e) {
    this.ftp.setFileType(FTP.BINARY_FILE_TYPE);
  }
  try {
    String pasVal=this.uploadPolicy.getString("passive");
    if (Boolean.getBoolean(pasVal)) {
      this.ftp.enterRemotePassiveMode();
      this.ftp.enterLocalPassiveMode();
    }
 else {
      this.ftp.enterLocalActiveMode();
      this.ftp.enterRemoteActiveMode(InetAddress.getByName(this.host),Integer.parseInt(this.port));
    }
  }
 catch (  MissingResourceException e) {
    this.ftp.enterRemotePassiveMode();
    this.ftp.enterLocalPassiveMode();
  }
}
 

Example 76

From project kabeja, under directory /blocks/svg/src/main/java/dk/abj/svg/action/.

Source file: Messages.java

  29 
vote

public static String getString(String key){
  try {
    return RESOURCE_BUNDLE.getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 77

From project Kairos, under directory /src/java/org/apache/nutch/plugin/.

Source file: PluginDescriptor.java

  29 
vote

/** 
 * Returns a I18N'd resource string. The resource bundles could be stored in root directory of a plugin in the well know i18n file name conventions.
 * @param pKey
 * @param pLocale
 * @return String
 * @throws IOException
 */
public String getResourceString(String pKey,Locale pLocale) throws IOException {
  if (fMessages.containsKey(pLocale.toString())) {
    ResourceBundle bundle=(ResourceBundle)fMessages.get(pLocale.toString());
    try {
      return bundle.getString(pKey);
    }
 catch (    MissingResourceException e) {
      return '!' + pKey + '!';
    }
  }
  try {
    ResourceBundle res=ResourceBundle.getBundle("messages",pLocale,getClassLoader());
    return res.getString(pKey);
  }
 catch (  MissingResourceException x) {
    return '!' + pKey + '!';
  }
}
 

Example 78

From project LateralGM, under directory /org/lateralgm/main/.

Source file: Prefs.java

  29 
vote

public static String getString(String key,String def){
  String r;
  try {
    r=RESOURCE_BUNDLE.getString(key);
  }
 catch (  MissingResourceException e) {
    r=def == null ? '!' + key + '!' : def;
  }
  return PREFS.get(key,r);
}
 

Example 79

From project log4j, under directory /src/main/java/org/apache/log4j/.

Source file: Category.java

  29 
vote

/** 
 * Returns the string resource coresponding to <code>key</code> in this category's inherited resource bundle. See also  {@link #getResourceBundle}. <p>If the resource cannot be found, then an  {@link #error error}message will be logged complaining about the missing resource.
 */
protected String getResourceBundleString(String key){
  ResourceBundle rb=getResourceBundle();
  if (rb == null) {
    return null;
  }
 else {
    try {
      return rb.getString(key);
    }
 catch (    MissingResourceException mre) {
      error("No resource is associated with key \"" + key + "\".");
      return null;
    }
  }
}
 

Example 80

From project log4j-jboss-logmanager, under directory /src/main/java/org/apache/log4j/.

Source file: Category.java

  29 
vote

protected String getResourceBundleString(String key){
  ResourceBundle rb=getResourceBundle();
  if (rb == null) {
    return null;
  }
 else {
    try {
      return rb.getString(key);
    }
 catch (    MissingResourceException mre) {
      error("No resource is associated with key \"" + key + "\".");
      return null;
    }
  }
}
 

Example 81

From project log4jna, under directory /thirdparty/log4j/src/main/java/org/apache/log4j/.

Source file: Category.java

  29 
vote

/** 
 * Returns the string resource coresponding to <code>key</code> in this category's inherited resource bundle. See also  {@link #getResourceBundle}. <p>If the resource cannot be found, then an  {@link #error error}message will be logged complaining about the missing resource.
 */
protected String getResourceBundleString(String key){
  ResourceBundle rb=getResourceBundle();
  if (rb == null) {
    return null;
  }
 else {
    try {
      return rb.getString(key);
    }
 catch (    MissingResourceException mre) {
      error("No resource is associated with key \"" + key + "\".");
      return null;
    }
  }
}
 

Example 82

From project lyo.core, under directory /OSLC4J/src/org/eclipse/lyo/oslc4j/core/exception/.

Source file: MessageExtractor.java

  29 
vote

private static String getString(final Locale locale,final String key,final Object[] args){
  final ResourceBundle messages=getMessageBundle(locale);
  if (messages != null) {
    try {
      final String message=messages.getString(key);
      return formatMessage(locale,message,args);
    }
 catch (    final MissingResourceException missingResourceException) {
      logger.log(Level.SEVERE,missingResourceException.getMessage(),missingResourceException);
      return "???" + key + "???";
    }
  }
  logger.log(Level.SEVERE,"missing resource: " + key);
  return "???" + key + "???";
}
 

Example 83

From project lyo.rio, under directory /org.eclipse.lyo.rio.core/src/main/java/org/eclipse/lyo/rio/l10n/.

Source file: Messages.java

  29 
vote

public static String getString(String key){
  try {
    return RESOURCE_BUNDLE.getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 84

From project lyo.server, under directory /org.eclipse.lyo.samples.sharepoint/src/org/eclipse/lyo/samples/sharepoint/l10n/.

Source file: Messages.java

  29 
vote

public static String getString(String key){
  try {
    return RESOURCE_BUNDLE.getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 85

From project maple-ide, under directory /build/windows/launcher/launch4j/src/net/sf/launch4j/ant/.

Source file: Messages.java

  29 
vote

public static String getString(String key){
  try {
    return RESOURCE_BUNDLE.getString(key);
  }
 catch (  MissingResourceException e) {
    return '!' + key + '!';
  }
}
 

Example 86

From project mob, under directory /com.netappsid.mob.jndi/src/org/apache/naming/.

Source file: StringManager.java

  29 
vote

/** 
 * Get a string from the underlying resource bundle.
 * @param key 
 */
public String getString(String key){
  if (key == null) {
    String msg="key is null";
    throw new NullPointerException(msg);
  }
  String str=null;
  try {
    str=bundle.getString(key);
  }
 catch (  MissingResourceException mre) {
    str="Cannot find message associated with key '" + key + "'";
  }
  return str;
}
 

Example 87

From project mousefeed, under directory /com.mousefeed/src/com/mousefeed/client/.

Source file: Messages.java

  29 
vote

/** 
 * Returns the message for the defined key. If the object is provided with a class to retrieve messages for (e.g. is created with {@link #Messages(Class)}), this method tries to retrieve the message on a key composed with that class name and the provided key. If the message is not found, it finds the message using the provided key as is. If no class is provided, the method returns searches the message using the provided key.
 * @param key the message id. Not <code>null</code> or empty string.
 * @param arguments the message arguments when the message will be formatted by {@link MessageFormat#format}.
 * @return the message for the defined key. Never <code>null</code>.
 * @throws NullPointerException if the provided key is blank.
 * @throws MissingResourceException if the provided key is not found.
 */
public String get(final String key,final Object... arguments) throws NullPointerException, MissingResourceException {
  if (isBlank(key)) {
    throw new NullPointerException("Blank key was provided: '" + key + "'");
  }
  try {
    final String forClassKey=forClass.getSimpleName() + "." + key;
    return getFromBundle(forClassKey,arguments);
  }
 catch (  final MissingResourceException e) {
    return getFromBundle(key,arguments);
  }
}
 

Example 88

From project multibit, under directory /src/main/java/org/multibit/viewsystem/swing/action/.

Source file: MnemonicUtil.java

  29 
vote

/** 
 * get the mnemonic key code for the passed in internationalisation key
 * @param key
 * @return
 */
public int getMnemonic(String key){
  if (localiser != null) {
    try {
      return KeyStroke.getKeyStroke(localiser.getString(key)).getKeyCode();
    }
 catch (    NullPointerException npe) {
      return 0;
    }
catch (    ClassCastException cce) {
      return 0;
    }
catch (    MissingResourceException mre) {
      return 0;
    }
  }
 else {
    return 0;
  }
}
 

Example 89

From project mwe, under directory /plugins/org.eclipse.emf.mwe.ewm.editor/src/org/eclipse/emf/mwe/ewm/presentation/.

Source file: WorkflowModelWizard.java

  29 
vote

/** 
 * Returns the label for the specified type name. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected String getLabel(String typeName){
  try {
    return WorkflowEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type");
  }
 catch (  MissingResourceException mre) {
    WorkflowEditorPlugin.INSTANCE.log(mre);
  }
  return typeName;
}
 

Example 90

From project myfaces-extcdi, under directory /core/impl/src/main/java/org/apache/myfaces/extensions/cdi/core/impl/resource/bundle/.

Source file: DefaultResourceBundle.java

  29 
vote

/** 
 * {@inheritDoc}
 */
public String getValue(String key){
  if (key == null) {
    return null;
  }
  if (this.locale == null) {
    this.locale=Locale.getDefault();
  }
  if (this.bundleName == null) {
    if (ProjectStageProducer.getInstance().getProjectStage() == ProjectStage.Development) {
      Logger logger=Logger.getLogger(DefaultResourceBundle.class.getName());
      if (logger.isLoggable(Level.WARNING)) {
        logger.warning("no custom bundle name provided - the codi properties file " + "META-INF/myfaces-extcdi.properties is used as fallback");
      }
    }
    this.bundleName="META-INF/myfaces-extcdi.properties";
  }
  if (this.bundleName.contains("/")) {
    Properties properties=ConfigUtils.getProperties(this.bundleName);
    if (properties == null) {
      return null;
    }
    return properties.getProperty(key);
  }
  try {
    return java.util.ResourceBundle.getBundle(this.bundleName,this.locale).getString(key);
  }
 catch (  MissingResourceException e) {
    return null;
  }
}
 

Example 91

From project mylyn.context, under directory /org.eclipse.mylyn.context.ui/src/org/eclipse/mylyn/internal/context/ui/.

Source file: ContextUiPlugin.java

  29 
vote

/** 
 * Returns the string from the plugin's resource bundle, or 'key' if not found.
 */
@Deprecated public static String getResourceString(String key){
  ResourceBundle bundle=ContextUiPlugin.getDefault().getResourceBundle();
  try {
    return (bundle != null) ? bundle.getString(key) : key;
  }
 catch (  MissingResourceException e) {
    return key;
  }
}