List of usage examples for java.text MessageFormat MessageFormat
public MessageFormat(String pattern)
From source file:at.ac.tuwien.infosys.jcloudscale.datastore.util.URLUtil.java
private static String formatMessage(String message, Object... args) { MessageFormat messageFormat = new MessageFormat(message); return messageFormat.format(args); }
From source file:es.urjc.mctwp.service.Command.java
/** * This method get the appropriate message template and applies arguments to * generate a valid localized message.//from w w w .j a va 2 s . c om * * @param arguments * @param template */ protected void createLogComment(String template, Object... arguments) { MessageFormat formatter = new MessageFormat(""); formatter.applyPattern(messages.getString(template)); logComment = formatter.format(arguments); }
From source file:org.protempa.Executor.java
Executor(Query query, Destination resultsHandlerFactory, QuerySession querySession, ExecutorStrategy strategy, AbstractionFinder abstractionFinder) throws QueryException { this.abstractionFinder = abstractionFinder; assert query != null : "query cannot be null"; assert resultsHandlerFactory != null : "resultsHandlerFactory cannot be null"; assert abstractionFinder != null : "abstractionFinder cannot be null"; if (abstractionFinder.isClosed()) { throw new QueryException(query.getName(), new ProtempaAlreadyClosedException()); }//from w w w .j a v a2 s . co m this.keyIds = Arrays.asSet(query.getKeyIds()); this.propIds = Arrays.asSet(query.getPropositionIds()); this.termIds = Arrays.asSet(query.getTermIds()); this.filters = query.getFilters(); this.propDefs = query.getPropositionDefinitions(); if (propDefs != null && propDefs.length > 0) { ks = new KnowledgeSourceImplWrapper(abstractionFinder.getKnowledgeSource(), propDefs); } else { ks = abstractionFinder.getKnowledgeSource(); } this.query = query; this.qs = querySession; this.derivationsBuilder = new DerivationsBuilder(); this.strategy = strategy; this.destination = resultsHandlerFactory; this.exceptions = Collections.synchronizedList(new ArrayList<QueryException>()); this.logMessageFormat = new MessageFormat("Query " + this.query.getName() + ": {0}"); }
From source file:gov.nih.nci.firebird.common.ValidationFailure.java
/** * Creates a new failure instance (non-field level). * * @param resources contains the failure messages * @param messageKey the key to the specific failure * @param arguments parameter values to be inserted into the failure message * @return the failure/*from w w w. jav a 2 s .c om*/ */ public static ValidationFailure create(ResourceBundle resources, String messageKey, Object... arguments) { MessageFormat format = new MessageFormat(resources.getString(messageKey)); String message = format.format(arguments, new StringBuffer(), new FieldPosition(0)).toString(); return new ValidationFailure(message); }
From source file:org.phenotips.vocabulary.internal.solr.HumanPhenotypeOntology.java
private SolrQuery addDynamicQueryParameters(String originalQuery, Integer rows, String sort, String customFq, boolean isId, SolrQuery query) { String queryString = originalQuery.trim(); String escapedQuery = ClientUtils.escapeQueryChars(queryString); if (isId) {/*from www . j av a2 s .com*/ query.setFilterQueries(StringUtils.defaultIfBlank(customFq, new MessageFormat("id:{0} alt_id:{0}").format(new String[] { escapedQuery }))); } else { query.setFilterQueries(StringUtils.defaultIfBlank(customFq, "term_category:HP\\:0000118")); } query.setQuery(escapedQuery); query.set(SpellingParams.SPELLCHECK_Q, queryString); query.setRows(rows); if (StringUtils.isNotBlank(sort)) { for (String sortItem : sort.split("\\s*,\\s*")) { query.addSort(StringUtils.substringBefore(sortItem, " "), sortItem.endsWith(" desc") || sortItem.startsWith("-") ? ORDER.desc : ORDER.asc); } } return query; }
From source file:org.languagetool.rules.patterns.FalseFriendRuleLoader.java
public FalseFriendRuleHandler(final Language textLanguage, final Language motherTongue) { messages = ResourceBundle.getBundle(JLanguageTool.MESSAGE_BUNDLE, motherTongue.getLocale()); formatter = new MessageFormat(""); formatter.setLocale(motherTongue.getLocale()); this.textLanguage = textLanguage; this.motherTongue = motherTongue; }
From source file:com.taobao.tddl.common.ConfigServerHelper.java
/** * /*from w w w .j a v a2s.c o m*/ */ public static Object subscribeSyncLogDbWeight(String syncServerID, DataListener listener) { if (syncServerID == null || syncServerID.length() == 0) { throw new IllegalStateException("IDsyncServerID"); } String dataId = new MessageFormat(DATA_ID_SYNCLOG_DBWEIGHT).format(new Object[] { syncServerID }); return ConfigServerHelper.subscribePersistentData(getCallerClassName(), dataId, listener); }
From source file:de.kaiserpfalzEdv.vaadin.i18n.impl.I18NHandlerImpl.java
@Override public String get(final String key, final Object[] parameters) { MessageFormat message = new MessageFormat(get(key)); message.setLocale(locale);/*from www . j a va 2s. c om*/ LOG.trace("Translating {}='{}' with parameters: {} ...", key, get(key), parameters); return message.format(parameters); }
From source file:com.dbschools.quickquiz.client.taker.MainWindow.java
private void processQuestionMsg(QuestionMsg questionMsg) { final String question = questionMsg.getQuestion(); final Integer timeLimit = questionMsg.getTimeLimitSeconds(); lblQuestion.setText(question);// ww w. j a v a 2 s . com messagesModel.add(new MessageFormat(Resources.getString("questionReceived")) .format(new Object[] { questionMsg.getCreationTime(), timeLimit, question })); /* Configure input controls */ txtAnswer.requestFocus(); btnSubmit.setEnabled(true); btnSendChatLine.setEnabled(false); /* Start countdown meter */ if (timeLimit != null && timeLimit > 0) { countdownMeter.countDown(timeLimit); } /* Blink the QA panel title */ new TitleBlinker(pnlQA).blink(); }
From source file:es.urjc.mctwp.service.Command.java
/** * This method get the appropriate message template and applies arguments to * generate a valid localized message.// w w w . ja v a2 s . c o m * * @param arguments * @param template */ protected void createUserComment(String template, Object... arguments) { MessageFormat formatter = new MessageFormat(""); formatter.applyPattern(messages.getString(template)); userComment = formatter.format(arguments); }