当前位置: 首页>>代码示例>>Java>>正文


Java ResourceBundle.getString方法代码示例

本文整理汇总了Java中java.util.ResourceBundle.getString方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceBundle.getString方法的具体用法?Java ResourceBundle.getString怎么用?Java ResourceBundle.getString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.ResourceBundle的用法示例。


在下文中一共展示了ResourceBundle.getString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMCRUnits

import java.util.ResourceBundle; //导入方法依赖的package包/类
@Override
public String getMCRUnits(Locale locale) {
  ResourceBundle messages = Resources.get().getBundle("Messages", locale);
  ResourceBundle jsMessages = Resources.get().getBundle("JSMessages", locale);
  Long domainId = this.getDomainId();
  DomainConfig dc = DomainConfig.getInstance(domainId);
  InventoryConfig ic = dc.getInventoryConfig();

  boolean allowManualConsumptionRates = (ic != null && ic.getManualCRFreq() != null);
  String
      manualCrUnits =
      (allowManualConsumptionRates ? InventoryConfig
          .getFrequencyDisplay(ic.getManualCRFreq(), false, locale) : null);
  if (manualCrUnits == null || manualCrUnits.isEmpty() || manualCrUnits
      .equalsIgnoreCase(messages.getString("days"))) {
    manualCrUnits =
        jsMessages.getString("daysofstock"); // Default the manual consumption rate units to Days.
  } else if (manualCrUnits.equalsIgnoreCase(messages.getString("weeks"))) {
    manualCrUnits = jsMessages.getString("weeksofstock");
  } else if (manualCrUnits.equalsIgnoreCase(messages.getString("months"))) {
    manualCrUnits = jsMessages.getString("monthsofstock");
  }
  return manualCrUnits;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:25,代码来源:Invntry.java

示例2: getMessage

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Overrides this method to get the formatted&localized error message.
 *
 * REVISIT: the system locale is used to load the property file.
 *          do we want to allow the appilcation to specify a
 *          different locale?
 */
public String getMessage() {
    ResourceBundle resourceBundle = null;
    resourceBundle = SecuritySupport.getResourceBundle("com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages");
    if (resourceBundle == null)
        throw new MissingResourceException("Property file not found!", "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key);

    String msg = resourceBundle.getString(key);
    if (msg == null) {
        msg = resourceBundle.getString("BadMessageKey");
        throw new MissingResourceException(msg, "com.sun.org.apache.xerces.internal.impl.msg.XMLSchemaMessages", key);
    }

    if (args != null) {
        try {
            msg = java.text.MessageFormat.format(msg, args);
        } catch (Exception e) {
            msg = resourceBundle.getString("FormatFailed");
            msg += " " + resourceBundle.getString(key);
        }
    }

    return msg;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:DatatypeException.java

示例3: initialize

import java.util.ResourceBundle; //导入方法依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
    this.title = resources.getString(R.Translate.ITEM_TYPE_ARMOR);
    this.imageChooserTitle = resources.getString(R.Translate.ITEM_IMAGE_CHOOSE_DIALOG);

    txtName.textProperty().bindBidirectional(model.name);
    txtDescription.textProperty().bindBidirectional(model.description);

    FormUtils.initTextFormater(txtDefenceNumber, model.defence);
    FormUtils.initTextFormater(txtMiniumStrength, model.minimumStrength);
    FormUtils.initTextFormater(txtWeightA, model.weightA);
    FormUtils.initTextFormater(txtWeightB, model.weightB);
    FormUtils.initTextFormater(txtWeightC, model.weightC);

    lblPriceA.textProperty().bind(model.priceA.text);
    lblPriceB.textProperty().bind(model.priceB.text);
    lblPriceC.textProperty().bind(model.priceC.text);

    imageView.imageProperty().bindBidirectional(model.image);
}
 
开发者ID:stechy1,项目名称:drd,代码行数:21,代码来源:ItemArmorController.java

示例4: getString

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * get message from a resource file (.properties).
 * 
 * @param messageSourceSupplier
 * @param keys
 * @param keysValues
 * @param locale
 * @return
 */
public static String getString(SourceSupplier messageSourceSupplier, String[] keys, String[] keysValues,
		Locale locale) {
	try {
		if (keys == null) {
			throw new IllegalArgumentException("No keys have been specified and they're mandatory.");
		}
		String resFile = messageSourceSupplier.getResourceFile();
		String message = null;
		ResourceBundle bundle = MowerRessourceBundle.getBundle(resFile, locale);
		if (bundle == null) {
			message = keys[(keys.length - 1)];
		} else {
			message = bundle.getString(copmoseKey(keys));
			MessageFormat msgFormat = new MessageFormat((String) message, locale);
			message = msgFormat.format(keysValues == null ? new String[] { "''" } : keysValues);
		}
		return message;
	} catch (Exception e) {
		throw new MowerException(e);
	}
}
 
开发者ID:camy2408,项目名称:automatic-mower,代码行数:31,代码来源:MessageServiceManager.java

示例5: main

import java.util.ResourceBundle; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    int errors = 0;
    for (String loctag : args) {
        Locale locale = Locale.forLanguageTag(loctag);
        if (locale.equals(Locale.ROOT)) {
            continue;
        }
        ResourceBundle rb = ResourceBundle.getBundle("jdk.test.resources.MyResources",
                                                     locale);
        String tag = locale.toLanguageTag(); // normalized
        String value = rb.getString("key");
        System.out.println("locale = " + tag + ", value = " + value);
        if (!value.startsWith(tag + ':')) {
            System.out.println("ERROR: " + value + " expected: " + tag);
            errors++;
        }
    }
    if (errors > 0) {
        throw new RuntimeException(errors + " errors");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:Main.java

示例6: getLocalizedString

import java.util.ResourceBundle; //导入方法依赖的package包/类
private static String getLocalizedString(List<ResourceBundle> bundles,
                                         String key,
                                         Object... args) {
   String msg = null;
   for (List<ResourceBundle> l = bundles; l.nonEmpty() && msg == null; l = l.tail) {
       ResourceBundle rb = l.head;
       try {
           msg = rb.getString(key);
       }
       catch (MissingResourceException e) {
           // ignore, try other bundles in list
       }
   }
   if (msg == null) {
       msg = "compiler message file broken: key=" + key +
           " arguments={0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}";
   }
   return MessageFormat.format(msg, args);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:JavacMessages.java

示例7: getMessage

import java.util.ResourceBundle; //导入方法依赖的package包/类
/** 国际化信息 */
public static String getMessage(String key, Object... params) {
    Locale locale = LocaleContextHolder.getLocale();
    ResourceBundle message = MESSAGES.get(locale.getLanguage());
    if (message == null) {
        synchronized (MESSAGES) {
            message = MESSAGES.get(locale.getLanguage());
            if (message == null) {
                message = ResourceBundle.getBundle("i18n/messages", locale);
                MESSAGES.put(locale.getLanguage(), message);
            }
        }
    }
    if (params != null && params.length > 0) {
        return String.format(message.getString(key), params);
    }
    return message.getString(key);
}
 
开发者ID:babymm,项目名称:mumu,代码行数:19,代码来源:Resources.java

示例8: downloadFile

import java.util.ResourceBundle; //导入方法依赖的package包/类
@RequestMapping(value = "/download", method = RequestMethod.GET)
public
@ResponseBody
void downloadFile(@RequestParam String key, @RequestParam(required = false) boolean isBlobKey,
                  @RequestParam(required = false) String fileName, HttpServletRequest request,
                  HttpServletResponse response) {
  SecureUserDetails sUser = SecurityUtils.getUserDetails(request);
  Locale locale = sUser.getLocale();
  ResourceBundle backendMessages = Resources.get().getBundle("BackendMessages", locale);
  if (key == null || key.isEmpty()) {
    throw new BadRequestException(backendMessages.getString("file.download.error"));
  }
  try {
    String blobKeyStr;
    String downloadFileName;
    if(!isBlobKey) {
      UploadService us = Services.getService(UploadServiceImpl.class);
      IUploaded uploaded = us.getUploaded(key);
       blobKeyStr = uploaded.getBlobKey();
      downloadFileName = uploaded.getFileName();
    } else {
      blobKeyStr = key;
      downloadFileName = fileName;
    }
    response.addHeader("Content-Disposition", "attachment; filename=" + downloadFileName);
    response.setBufferSize(32*1024);
    if (blobKeyStr != null) {
      AppFactory.get().getBlobstoreService().serve(blobKeyStr, response);
    }
    response.flushBuffer();
  } catch (ServiceException | ObjectNotFoundException | IOException e) {
    xLogger.warn("Error in downloading file", e);
    throw new InvalidServiceException(backendMessages.getString("file.download.error"));
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:36,代码来源:ExportController.java

示例9: getMessage

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Returns a message if found or the key if not found. Arguments <b>can</b> be specified which
 * will be used to format the String. In the {@link ResourceBundle} the String '{0}' (without ')
 * will be replaced by the first argument, '{1}' with the second and so on.
 *
 * Catches the exception thrown by ResourceBundle in the latter case.
 **/
public static String getMessage(ResourceBundle bundle, String key, Object... arguments) {
	try {

		if (arguments == null || arguments.length == 0) {
			return bundle.getString(key);
		} else {
			String message = bundle.getString(key);
			if (message != null) {
				return MessageFormat.format(message, arguments);
			} else {
				return key;
			}
		}

	} catch (MissingResourceException e) {
		LogService.getRoot().log(Level.FINE, "com.rapidminer.tools.I18N.missing_key", key);
		return key;
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:27,代码来源:I18N.java

示例10: getMessage

import java.util.ResourceBundle; //导入方法依赖的package包/类
public static String getMessage(String key, Object[] args) {
    ResourceBundle rb = null;
    
    //  Find the resource bundle if it is not loaded yet
    if (rb == null) {
        try {
            rb = ResourceBundle.getBundle(rbName, Locale.getDefault(),
                                                 (Common.class).getClassLoader());
        } catch(MissingResourceException e) {
            //  Do without bundle
            System.err.println("Couldn't find the bundle " + rbName + // NOI18N
                               " for the locale " + Locale.getDefault()); // NOI18N
        }
    }
	
    //  Get and format the message...
    if (rb != null) {
        //  ...using the resource bundle
        if (args != null) {
            return MessageFormat.format(rb.getString(key), args);
        } else {
            return rb.getString(key);
        }
    } else {
        //	...without the resource bundle
        String p = " "; // NOI18N
        if (args != null) {
            for (int i=0; i<args.length; i++) {
                if (args[i] != null) {
                    p += (args[i].toString() + " "); // NOI18N
                } else {
                    p += "null "; // NOI18N
                }
            }
        }
        return key + p;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:Common.java

示例11: getPropSet

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Returns property sheet associated with node representing this source.
 * TODO move it to the node?
 * @return property sheet associated with node representing this source.
 */
public Sheet.Set getPropSet() {
    Sheet.Set props = Sheet.createPropertiesSet();

    final ResourceBundle bundle = NbBundle.getBundle(LogRecordsSource.class);

    class RegexpFilterProp extends PropertySupport.ReadWrite {
        //Pattern tempPat = Pattern.compile("");
        public RegexpFilterProp() {
            super("regexpFilterProp", Pattern.class,
                    bundle.getString("PROP_RegexpFilter"),
                    bundle.getString("HINT_RegexpFilter"));
        }

        public Object getValue() {
            if (regexpFilter == null) {
                return null;
            } else {
                return regexpFilter.pattern;
            }
        }

        public void setValue(Object object) throws IllegalAccessException, IllegalArgumentException {
            setRegexpFilterPatter((Pattern) object);
        }
    }

    props.put(new RegexpFilterProp());

    return props;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:36,代码来源:LogRecordsSource.java

示例12: enableDisableUser

import java.util.ResourceBundle; //导入方法依赖的package包/类
@RequestMapping(value = "/userstate/", method = RequestMethod.GET)
public
@ResponseBody
String enableDisableUser(@RequestParam String userId, @RequestParam String action,
                         HttpServletRequest request) {
  SecureUserDetails sUser = SecurityUtils.getUserDetails(request);
  Long domainId = SessionMgr.getCurrentDomain(request.getSession(), sUser.getUsername());
  Locale locale = sUser.getLocale();
  ResourceBundle backendMessages = Resources.get().getBundle("BackendMessages", locale);
  try {
    UsersService as = Services.getService(UsersServiceImpl.class, locale);
    AuthenticationService aus = Services.getService(AuthenticationServiceImpl.class);
    IUserAccount ua = as.getUserAccount(userId);
    if (GenericAuthoriser.authoriseUser(request, userId)) {
      if ("e".equals(action)) {
        as.enableAccount(userId);
        xLogger.info("AUDITLOG \t {0} \t {1} \t USER \t " +
            "ENABLE \t {2} \t {3}", domainId, sUser.getUsername(), userId, ua.getFullName());
        return backendMessages.getString("user.account.enabled") + " " + MsgUtil.bold(userId);
      } else {
        as.disableAccount(userId);
        aus.updateUserSession(userId, null);
        xLogger.info("AUDITLOG \t {0} \t {1} \t USER \t " +
            "DISABLE \t {2} \t {3}", domainId, sUser.getUsername(), userId, ua.getFullName());
        return backendMessages.getString("user.account.disabled") + " " + MsgUtil.bold(userId);
      }
    } else {
      throw new UnauthorizedException(backendMessages.getString("permission.denied"));
    }
  } catch (ServiceException | ObjectNotFoundException se) {
    xLogger.warn("Error Updating User password for " + userId, se);
    throw new InvalidServiceException(
        backendMessages.getString("user.password.update.error") + " " + userId);
  }
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:36,代码来源:UsersController.java

示例13: createColoring

import java.util.ResourceBundle; //导入方法依赖的package包/类
static SimpleAttributeSet createColoring(Feature f, ResourceBundle bundle) {
    String colorName = (String) f.getValue("color_name");
    String displayName = null;
    if (colorName == null)
        colorName = f.getSelector().getAsString();
    if (bundle != null) {
        try {
            displayName = bundle.getString(colorName);
        } catch (MissingResourceException e) {
        }
    }
    if (displayName == null) {
        displayName = colorName;
    }
    return createColoring(
            colorName,
            displayName,
            (String) f.getValue("default_coloring"),
            (String) f.getValue("foreground_color"),
            (String) f.getValue("background_color"),
            (String) f.getValue("underline_color"),
            (String) f.getValue("wave_underline_color"),
            (String) f.getValue("strike_through_color"),
            (String) f.getValue("font_name"),
            (String) f.getValue("font_type")
            );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:ColorsManager.java

示例14: getCSVHeader

import java.util.ResourceBundle; //导入方法依赖的package包/类
@Override
public String getCSVHeader(Locale locale, DomainConfig dc, String type) {
  xLogger.fine("Entering getCSVHeader. locale: {0}", locale);
  ResourceBundle messages = Resources.get().getBundle("Messages", locale);
  ResourceBundle jsMessages = Resources.get().getBundle("JSMessages", locale);
  String
      header =
      messages.getString("kiosk") + CharacterConstants.SPACE + jsMessages.getString("id")
          + CharacterConstants.COMMA +
          messages.getString("customid.entity") + CharacterConstants.COMMA +
          messages.getString("kiosk.name") + CharacterConstants.COMMA +
          messages.getString("material") + CharacterConstants.SPACE + jsMessages.getString("id")
          + CharacterConstants.COMMA +
          messages.getString("customid.material") + CharacterConstants.COMMA +
          messages.getString("material.name") + CharacterConstants.COMMA +
          messages.getString("inventory.currentstock") + "," + messages.getString("lastupdated")
          + "," +
          messages.getString("inventory.reorderlevel") + "," +
          messages.getString("max") + "," +
          messages.getString("config.consumptionrates") + "/" + messages.getString("day") + "," +
          messages.getString("config.consumptionrates") + "/" + messages.getString("week") + "," +
          messages.getString("config.consumptionrates") + "/" + messages.getString("month") + ","
          +
          messages.getString("demandforecast") + "," +
          messages.getString("inventory.safetystock") + " (computed)" + "," +
          messages.getString("order.optimalorderquantity") + "," +
          messages.getString("inventory.policy") + "," + messages
          .getString("inventory.servicelevel") + "," +
          messages.getString("kiosk") + CharacterConstants.SPACE +
          jsMessages.getString("tags.lower") + CharacterConstants.COMMA +
          messages.getString("material") + CharacterConstants.SPACE +
          jsMessages.getString("tags.lower") + CharacterConstants.COMMA +
          messages.getString("country") + "," + messages.getString("state") + "," +
          messages.getString("district") + "," + messages.getString("taluk") + "," +
          messages.getString("zipcode") + "," + messages.getString("village");
  xLogger.fine("Exiting getCSVHeader");
  return header;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:39,代码来源:InventrySnapshotExportHandler.java

示例15: getDisplayName

import java.util.ResourceBundle; //导入方法依赖的package包/类
public static String getDisplayName(String transType, String transNaming, Locale locale) {
  String name = "";
  // Get the resource bundle
  ResourceBundle messages = Resources.get().getBundle("Messages", locale);
  if (messages == null) {
    return "";
  }
  if (ITransaction.TYPE_ISSUE.equals(transType)) {
    name =
        DomainConfig.TRANSNAMING_ISSUESRECEIPTS.equals(transNaming) ? messages
            .getString("transactions.issue") : messages.getString("transactions.sale");
  } else if (ITransaction.TYPE_RECEIPT.equals(transType)) {
    name =
        DomainConfig.TRANSNAMING_ISSUESRECEIPTS.equals(transNaming) ? messages
            .getString("transactions.receipt") : messages.getString("transactions.purchase");
  } else if (ITransaction.TYPE_PHYSICALCOUNT.equals(transType)) {
    name = messages.getString("transactions.stockcount");
  } else if (ITransaction.TYPE_ORDER.equals(transType)) {
    name = messages.getString("transactions.order");
  } else if (ITransaction.TYPE_REORDER.equals(transType)) {
    name = messages.getString("transactions.reorder");
  } else if (ITransaction.TYPE_WASTAGE.equals(transType)) {
    name = messages.getString("transactions.wastage");
  } else if (ITransaction.TYPE_RETURN.equals(transType)) {
    name = messages.getString("transactions.return");
  } else if (ITransaction.TYPE_TRANSFER.equals(transType)) {
    name = messages.getString("transactions.transfer");
  }
  return name;
}
 
开发者ID:logistimo,项目名称:logistimo-web-service,代码行数:31,代码来源:TransactionUtil.java


注:本文中的java.util.ResourceBundle.getString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。