List of usage examples for java.text MessageFormat format
public static String format(String pattern, Object... arguments)
From source file:net.nperkins.quizmaster3000.AskQuestionRunnable.java
@Override public void run() { if (timer <= 0) { Bukkit.getScheduler().cancelTask(id); plugin.sendPlayers(plugin.getMessages().getString("quiz.question.timeup")); plugin.sendPlayers(MessageFormat.format(plugin.getMessages().getString("quiz.question.answer"), StringUtils.join(/* w w w .j a va 2 s . com*/ Arrays.copyOfRange(plugin.getCurrentQuestion().getAnswer(), 0, plugin.getCurrentQuestion().getAnswer().length), plugin.getMessages().getString("quiz.answer.joiner")))); if (plugin.getScores().size() == 0) { plugin.sendPlayers(plugin.prefixMessage(plugin.getMessages().getString("error.allplayersleft"))); plugin.setState(QuizState.FINISHED); plugin.setRunning(false); } else { plugin.setState(QuizState.WAITFORNEXT); plugin.sendPlayers(plugin.getMessages().getString("quiz.question.next")); plugin.getWaitForNextRunnable().start(); } } else { plugin.sendPlayers( MessageFormat.format(plugin.getMessages().getString("quiz.question.timeleft"), timer)); if (plugin.getConfig().getBoolean("quiz.hints")) plugin.sendPlayers(MessageFormat.format(plugin.getMessages().getString("quiz.question.hint"), plugin.getHint(timer * 2))); timer -= 15; } }
From source file:ch.cyberduck.ui.action.ChecksumWorker.java
@Override public String getActivity() { return MessageFormat.format(Locale.localizedString("Compute MD5 hash of {0}", "Status"), this.toString(files)); }
From source file:com.microsoft.tfs.client.eclipse.project.ProjectManagerConnectionJob.java
protected ProjectManagerConnectionJob(final ProjectManagerDataProvider dataProvider, final URI serverURI, final boolean stayOffline) { super(MessageFormat.format(Messages.getString("ProjectManagerConnectionJob.ConnectingToServerFormat"), //$NON-NLS-1$ serverURI));/*from w w w . j av a2 s . c o m*/ Check.notNull(dataProvider, "dataProvider"); //$NON-NLS-1$ Check.notNull(serverURI, "serverURI"); //$NON-NLS-1$ this.dataProvider = dataProvider; this.serverURI = serverURI; this.stayOffline = stayOffline; }
From source file:cz.muni.fi.editor.services.api.notifications.NotificationFactoryImpl.java
@Override public Notification provideNotification(EditorEvent editorEvent) { Notification n = new Notification(); n.setNotificationDate(LocalDateTime.now()); switch (editorEvent.getType()) { case 1: {//from w ww . ja v a2 s . c om EOrganizationDisbanded disbanded = (EOrganizationDisbanded) editorEvent; n.setMessage(MessageFormat.format(editorEvent.getNotificationMessage(), disbanded.getName())); } break; case 2: { EOrganizationInvited invited = (EOrganizationInvited) editorEvent; n.setMessage(MessageFormat.format(editorEvent.getNotificationMessage(), invited.getOrganization().getOrganizationName())); n.setNotified(invited.getUser()); } break; case 3: { } break; case 4: { EOrganizationKicked kicked = (EOrganizationKicked) editorEvent; n.setMessage(MessageFormat.format(editorEvent.getNotificationMessage(), kicked.getOrganization().getOrganizationName())); n.setNotified(kicked.getUser()); } break; case 5: { EOrganizationPromoted promoted = (EOrganizationPromoted) editorEvent; n.setMessage(MessageFormat.format(editorEvent.getNotificationMessage(), promoted.getOrganization().getOrganizationName())); n.setNotified(promoted.getOrganization().getOwner()); } break; case 6: { EOrganizationRenamed renamed = (EOrganizationRenamed) editorEvent; n.setMessage(MessageFormat.format(editorEvent.getNotificationMessage(), renamed.getOriginalName(), renamed.getOrganization().getOrganizationName())); } break; case 7: { ERequestApproved approved = (ERequestApproved) editorEvent; n.setMessage(MessageFormat.format(editorEvent.getNotificationMessage(), requestToParameter(approved.getRequest()))); n.setRequest(approved.getRequest()); n.setNotified(approved.getRequest().getRequestor()); } break; case 8: { ERequestCreated created = (ERequestCreated) editorEvent; n.setRequest(created.getRequest()); n.setMessage(MessageFormat.format(editorEvent.getNotificationMessage(), requestToParameter(created.getRequest()))); } break; case 9: { ERequestDenied denied = (ERequestDenied) editorEvent; n.setRequest(denied.getRequest()); n.setMessage(MessageFormat.format(editorEvent.getNotificationMessage(), requestToParameter(denied.getRequest()))); } break; default: throw new IllegalArgumentException(MessageFormat .format("Invalid event type. Type cannot be greater than {0}", EditorEvent.types.length - 1)); } return n; }
From source file:com.thomaskuenneth.openweathermapweather.WeatherUtils.java
public static WeatherData getWeather(String city) throws JSONException, MalformedURLException, IOException { String name = null;//from w w w . j a v a 2 s .c om String description = null; String icon = null; Double temp = null; JSONObject jsonObject = new JSONObject(WeatherUtils.getFromServer(MessageFormat.format(URL, city))); if (jsonObject.has(NAME)) { name = jsonObject.getString(NAME); } if (jsonObject.has(WEATHER)) { JSONArray jsonArrayWeather = jsonObject.getJSONArray(WEATHER); if (jsonArrayWeather.length() > 0) { JSONObject jsonWeather = jsonArrayWeather.getJSONObject(0); if (jsonWeather.has(DESCRIPTION)) { description = jsonWeather.getString(DESCRIPTION); } if (jsonWeather.has(ICON)) { icon = jsonWeather.getString(ICON); } } } if (jsonObject.has(MAIN)) { JSONObject main = jsonObject.getJSONObject(MAIN); temp = main.getDouble(TEMP); } return new WeatherData(name, description, icon, temp); }
From source file:com.eu.evaluation.server.dao.eva.EvaluateItemDAO.java
/** * ??/*from ww w. java 2 s. com*/ * @param <T> * @param evaluateTypeEnum * @param entityEnum * @return */ public <T extends EvaluateItem> List<T> find(EvaluateTypeEnum evaluateTypeEnum, EntityEnum entityEnum) { String jpql = "select t from {0} t where t.objectDictionary.instanceType = :instanceType"; jpql = MessageFormat.format(jpql, evaluateTypeEnum.getEvaClass().getName()); MapSqlParameterSource params = new MapSqlParameterSource("instanceType", entityEnum.getInstanceType()); return this.createQuery(jpql, params).getResultList(); }
From source file:org.brushingbits.jnap.email.EmailFactory.java
/** * //from w w w. j a v a 2 s. c om * @param <E> * @param id * @param type * @return */ public <E extends Email> E getEmail(String id, Class<E> type) { E email = null; final String emailId = getIdPrefix() + id; try { email = applicationContext.getBean(emailId, type); } catch (NoSuchBeanDefinitionException e) { throw new MailPreparationException( MessageFormat.format("The e-mail with id '{0}' could not be found!", emailId), e); } return email; }
From source file:com.microsoft.tfs.client.clc.CLCTFProxyServerSettingsFactory.java
@Override public TFProxyServerSettings newProxyServerSettings() { final Option o = command.findOptionType(OptionProxy.class); if (o != null) { final String uri = ((OptionProxy) o).getURI().toString(); log.debug(MessageFormat.format("TF download option found, using proxy {0}", uri)); //$NON-NLS-1$ return new DefaultTFProxyServerSettings(uri); }//from w ww . j av a 2 s . c o m return super.newProxyServerSettings(); }
From source file:com.asakusafw.yaess.tools.GenerateExecutionId.java
static int execute(String[] args) { assert args != null; Configuration conf;/* ww w . ja v a 2 s. c om*/ try { conf = parseConfiguration(args); } catch (Exception e) { HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(Integer.MAX_VALUE); formatter.printHelp( MessageFormat.format("java -classpath ... {0}", GenerateExecutionId.class.getName()), OPTIONS, true); e.printStackTrace(System.out); return 1; } try { String executionId = computeExecutionId(conf); System.out.print(executionId); } catch (Exception e) { e.printStackTrace(); return 1; } return 0; }
From source file:ch.cyberduck.ui.cocoa.controller.CreateSymlinkController.java
@Override public void loadBundle() { final NSAlert alert = NSAlert.alert(); alert.setAlertStyle(NSAlert.NSInformationalAlertStyle); alert.setMessageText(LocaleFactory.localizedString("Create new symbolic link", "File")); alert.setInformativeText(MessageFormat.format( LocaleFactory.localizedString("Enter the name for the new symbolic link for {0}", "File"), selected.getName()));//from w w w .j a v a2s.co m alert.addButtonWithTitle(LocaleFactory.localizedString("Create", "File")); alert.addButtonWithTitle(LocaleFactory.localizedString("Cancel", "File")); alert.setIcon(IconCacheFactory.<NSImage>get().aliasIcon(null, 64)); super.loadBundle(alert); }