List of usage examples for java.text MessageFormat format
public static String format(String pattern, Object... arguments)
From source file:in.jeevankumar.casino.roulette.Outcome.java
/** * Easy-to-read representation of this Outcome. * @return String of the form name (odds:1) *//*from w ww .j a v a2s .com*/ public String toString() { Object[] values = { name, new Integer(odds) }; String msgTempl = "{0} ({1}:1)"; return MessageFormat.format(msgTempl, values); }
From source file:core.tooling.logging.Logger.java
public void debug(String message, Object... params) { if (isDebugEnabled()) { logger.debug(MessageFormat.format(message, params)); } }
From source file:com.futureplatforms.kirin.test.NetworkingBackendTest.java
@Override protected void setUp() throws Exception { mJSONString = "[\"foo\",\"bar\",\"baz\"]"; String packageName = mContext.getPackageName(); mBackend = new NetworkingBackend(getContext(), mJS, MessageFormat.format("Android/data/{0}/files", packageName)) { @Override//ww w .j a v a 2s . c om protected String downloadString(JSONObject config) throws IOException { String urlString = config.optString("url"); try { new URL(urlString); } catch (MalformedURLException e) { throw new IOException("URL is not a real URL: " + urlString); } if (mJSONString == null || mJSONString.contains("EXCEPTION")) { throw new IOException(); } return mJSONString; } }; }
From source file:com.microsoft.tfs.client.common.ui.wit.form.CustomControlLoader.java
private static String getStringAttribute(final IConfigurationElement configElement, final String name, final String defaultValue) { final String value = configElement.getAttribute(name); if (value != null) { return value; }/* w w w. j a v a2s . c o m*/ if (defaultValue != null) { return defaultValue; } final String messageFormat = Messages.getString("CustomControlLoader.MissingAttributeFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, name); throw new IllegalArgumentException(message); }
From source file:psiprobe.beans.stats.providers.StandardSeriesProvider.java
@Override public void populate(DefaultTableXYDataset dataset, StatsCollection statsCollection, HttpServletRequest request) {//from w w w . j av a 2 s . c o m String seriesParam = ServletRequestUtils.getStringParameter(request, "sp", null); for (int i = 0; i < statNames.size(); i++) { String statName = statNames.get(i); if (seriesParam != null) { statName = MessageFormat.format(statName, seriesParam); } List<XYDataItem> stats = statsCollection.getStats(statName); if (stats != null) { String series = ServletRequestUtils.getStringParameter(request, "s" + (i + 1) + "l", "series" + i); dataset.addSeries(toSeries(series, stats)); } } }
From source file:hadoopInstaller.logging.MessageFormattingLog.java
public void debug(Throwable t, String format, Object... arguments) { this.log.debug( MessageFormat.format(Messages.getString(format), arguments) + " - " + t.getLocalizedMessage()); this.log.trace("trace", t); }
From source file:com.asakusafw.thundergate.runtime.cache.mapreduce.Invalidation.java
private static long getTimestamp(Configuration conf) { String until = conf.get(KEY_INVALIDATION_TIMESTAMP); if (until == null) { LOG.debug(MessageFormat.format("invalidation timstamp is not set: {0}", KEY_INVALIDATION_TIMESTAMP)); return 0L; }//from w ww . ja v a2 s .c o m LOG.debug(MessageFormat.format("invalidation timstamp: {0}={1}", KEY_INVALIDATION_TIMESTAMP, until)); long timestamp = DateUtil.parseDateTime(until, '-', ' ', ':'); if (timestamp < 0) { throw new IllegalArgumentException( MessageFormat.format("invalid timestamp: {0}={1}", KEY_INVALIDATION_TIMESTAMP, until)); } return timestamp; }
From source file:com.asakusafw.runtime.stage.optimizer.ReducerSimplifierConfigurator.java
@Override public void configure(Job job) throws IOException, InterruptedException { int count = job.getNumReduceTasks(); if (count <= TASKS_TINY) { return;//from w w w . j av a2 s . c om } Configuration conf = job.getConfiguration(); long limit = conf.getLong(KEY_TINY_LIMIT, -1L); if (limit < 0L) { if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Reducer simplifier is disabled for tiny inputs: {0}", //$NON-NLS-1$ job.getJobName())); } return; } long estimated = StageInputDriver.estimateInputSize(job); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Reducer simplifier: job={0}, tiny-limit={1}, estimated={2}", //$NON-NLS-1$ job.getJobName(), limit, estimated)); } if (estimated < 0L || estimated > limit) { return; } LOG.info(MessageFormat.format("The number of reduce task ({0}) is configured: {1}->{2}", job.getJobName(), job.getNumReduceTasks(), TASKS_TINY)); job.setNumReduceTasks(TASKS_TINY); }
From source file:at.alladin.rmbt.controlServer.StatusResource.java
@Post("json") public String request(final String entity) { addAllowOrigin();/*ww w.java 2 s . co m*/ JSONObject request = null; final ErrorList errorList = new ErrorList(); final JSONObject answer = new JSONObject(); String answerString; final String clientIpRaw = getIP(); final InetAddress clientAddress = InetAddresses.forString(clientIpRaw); System.out.println(MessageFormat.format(labels.getString("NEW_STATUS_REQ"), clientIpRaw)); double geolat = 0; double geolong = 0; float geoaccuracy = 0; // in m double geoaltitude = 0; float geospeed = 0; // in m/s String telephonyNetworkSimOperator = ""; String telephonyNetworkSimCountry = ""; boolean homeCountry = true; if (entity != null && !entity.isEmpty()) { // try parse the string to a JSON object try { // debug parameters sent request = new JSONObject(entity); System.out.println(request.toString(4)); /* sample request Status request from 46.206.21.94 { "accuracy": 65, "altitude": 233.5172119140625, "client": "RMBT", "device": "iPhone", "language": "de", "lat": 48.19530995813387, "long": 16.29190354953834, "model": "iPhone5,2", "name": "RMBT", "network_type": 2, "os_version": "8.1.2", "plattform": "iOS", "softwareRevision": "next-858-8491858", "softwareVersion": "1.3.7", "softwareVersionCode": "1307", "speed": 0, "telephony_network_sim_country": "at", "telephony_network_sim_operator": "232-01", "telephony_network_sim_operator_name": "A1", "time": 1418241092784, "timezone": "Europe/Vienna", "type": "MOBILE", "uuid": "1cf594f6-0d07-4ff6-acd3-3d78ed9c0274", "version": "0.3" } */ geolat = request.optDouble("lat", 0); geolong = request.optDouble("long", 0); geoaccuracy = (float) request.optDouble("accuracy", 0); geoaltitude = request.optDouble("altitude", 0); geospeed = (float) request.optDouble("speed", 0); telephonyNetworkSimOperator = request.optString("telephony_network_sim_operator", ""); telephonyNetworkSimCountry = request.optString("telephony_network_sim_country", ""); } catch (final JSONException e) { errorList.addError("ERROR_REQUEST_JSON"); System.out.println("Error parsing JSON Data " + e.toString()); } } else { errorList.addErrorString("Expected request is missing."); } /* * * wb_a2 = 'AT' (2 digit country code) * ne_50m_admin_0_countries (SRID 900913 Mercator) * lat/long (SRID 4326 WGS84) * * SELECT st_contains(the_geom, ST_transform(ST_GeomFromText('POINT(56.391944 48.218056)',4326),900913)) home_country * FROM ne_50m_admin_0_countries * WHERE wb_a2='AT'; * * * */ try { PreparedStatement st; st = conn.prepareStatement( " SELECT st_contains(the_geom, ST_TRANSFORM(ST_GeomFromText( ? ,4326),900913)) home_country " + " FROM ne_50m_admin_0_countries " + " WHERE wb_a2 = ? "); int i = 1; final String point = "POINT(" + String.valueOf(geolong) + " " + String.valueOf(geolat) + ")"; st.setObject(i++, point); st.setObject(i++, telephonyNetworkSimCountry.toUpperCase()); //debug query System.out.println(st.toString()); final ResultSet rs = st.executeQuery(); if (rs.next()) // result only available if country (wb_a2) is found in ne_50_admmin_0_countries homeCountry = rs.getBoolean("home_country"); } catch (final SQLException e) { errorList.addError("ERROR_DB_GENERAL"); e.printStackTrace(); } try { answer.put("home_country", homeCountry); answer.putOpt("error", errorList.getList()); } catch (final JSONException e) { System.out.println("Error saving ErrorList: " + e.toString()); } answerString = answer.toString(); return answerString; }
From source file:com.nearinfinity.blur.log.LogImpl.java
public void info(Object message, Object... args) { if (isInfoEnabled()) { log.info(MessageFormat.format(message.toString(), args)); } }