List of usage examples for java.text MessageFormat format
public static String format(String pattern, Object... arguments)
From source file:ch.cyberduck.core.googledrive.DriveUrlProvider.java
@Override public DescriptiveUrlBag toUrl(Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if (file.isFile()) { try {/* w ww. jav a2 s.c o m*/ if (StringUtils.isBlank(file.attributes().getVersionId())) { return DescriptiveUrlBag.empty(); } final File f = session.getClient().files().get(file.attributes().getVersionId()).execute(); if (StringUtils.isNotBlank(f.getWebContentLink())) { list.add(new DescriptiveUrl(URI.create(f.getWebContentLink()), DescriptiveUrl.Type.http, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), "HTTP"))); } if (StringUtils.isNotBlank(f.getWebViewLink())) { list.add(new DescriptiveUrl(URI.create(f.getWebViewLink()), DescriptiveUrl.Type.http, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), "Download"))); } } catch (IOException e) { new DriveExceptionMappingService().map(e); } } return list; }
From source file:pzalejko.iot.hardware.home.core.service.configuration.DefaultConfigurationService.java
@PostConstruct public void init() { final String property = System.getProperty(CONFIGURATION_DIRECTORY_KEY); if (property == null) { final String msg = MessageFormat.format(LogMessages.CONFIGURATION_DIRECTORY_HAS_NOT_BE_SPECIFIED, CONFIGURATION_DIRECTORY_KEY); throw new IllegalStateException(msg); }//from w w w .ja v a 2 s. c o m final File file = new File(property); if (file.isDirectory()) { this.confDirectory = file; LOG.debug(LogMessages.FOUND_CONFIGURATION_DIRECTORY, file.getAbsoluteFile()); } else { final String msg = MessageFormat.format(LogMessages.PROPERTY_DOES_NOT_POINT_TO_ANY_DIRECTORY, CONFIGURATION_DIRECTORY_KEY); throw new IllegalStateException(msg); } }
From source file:com.swordlord.gozer.renderer.fop.FopTransformerErrorListener.java
public void fatalError(TransformerException arg0) throws TransformerException { // TODO Auto-generated method stub LOG.error(MessageFormat.format("Transformation fatal error: {0}", arg0)); }
From source file:com.dv.sharer.restclients.ImageRestClient.java
public Response uploadFile(Integer id, byte[] data) throws Exception { data = Base64.encodeBase64(data);/*from w ww. j a v a2 s . c om*/ String dataStr = new String(data); Invocation.Builder builder = getWebTarget().path(MessageFormat.format("upload/{0}", new Object[] { id })) .request(); String response = builder.post(Entity.entity(dataStr, MediaType.TEXT_PLAIN), String.class); Response resp = Response.fromJson(response, Response.class); return resp; }
From source file:com.artistech.tuio.mouse.MouseDriver.java
/** * Add Object Event.//from ww w .j a v a 2 s . co m * * @param tobj */ @Override public void addTuioObject(TuioObject tobj) { logger.debug(MessageFormat.format("add tuio object symbol id: {0}", tobj.getSymbolID())); }
From source file:at.alladin.rmbt.controlServer.ResultUpdateResource.java
@Post("json") public String request(final String entity) { addAllowOrigin();/*from ww w . j av a 2 s. c om*/ JSONObject request = null; final ErrorList errorList = new ErrorList(); final JSONObject answer = new JSONObject(); final String ip = getIP(); System.out.println(MessageFormat.format(labels.getString("NEW_RESULT_UPDATE"), ip)); if (entity != null && !entity.isEmpty()) { try { request = new JSONObject(entity); final UUID clientUUID = UUID.fromString(request.getString("uuid")); final UUID testUUID = UUID.fromString(request.getString("test_uuid")); final int zipCode = request.optInt("zip_code", 0); final double geoLat = request.optDouble("geo_lat", Double.NaN); final double geoLong = request.optDouble("geo_long", Double.NaN); final float geoAccuracy = (float) request.optDouble("accuracy", 0); final String provider = request.optString("provider").toLowerCase(); final Client client = new Client(conn); final long clientId = client.getClientByUuid(clientUUID); if (clientId < 0) throw new IllegalArgumentException("error while loading client"); final Test test = new Test(conn); if (test.getTestByUuid(testUUID) < 0) throw new IllegalArgumentException("error while loading test"); if (test.getField("client_id").longValue() != clientId) throw new IllegalArgumentException("client UUID does not match test"); if (zipCode > 0) { ((IntField) test.getField("zip_code")).setValue(zipCode); } if (!Double.isNaN(geoLat) && !Double.isNaN(geoLong) && (provider.equals(GEO_PROVIDER_GEOCODER) || provider.equals(GEO_PROVIDER_MANUAL))) { final GeoLocation geoloc = new GeoLocation(conn); geoloc.setTest_id(test.getUid()); final Timestamp tstamp = java.sql.Timestamp .valueOf(new Timestamp((new Date().getTime())).toString()); geoloc.setTime(tstamp, TimeZone.getDefault().toString()); geoloc.setAccuracy(geoAccuracy); geoloc.setGeo_lat(geoLat); geoloc.setGeo_long(geoLong); geoloc.setProvider(provider); geoloc.storeLocation(); ((DoubleField) test.getField("geo_lat")).setValue(geoLat); ((DoubleField) test.getField("geo_long")).setValue(geoLong); ((DoubleField) test.getField("geo_accuracy")).setValue(geoAccuracy); test.getField("geo_provider").setString(provider); } test.storeTestResults(true); if (test.hasError()) errorList.addError(test.getError()); } catch (final JSONException e) { errorList.addError("ERROR_REQUEST_JSON"); System.out.println("Error parsing JSDON Data " + e.toString()); } catch (final IllegalArgumentException e) { errorList.addError("ERROR_REQUEST_JSON"); System.out.println("Error parsing JSDON Data " + e.toString()); } } return answer.toString(); }
From source file:com.microsoft.tfs.client.common.ui.commands.ConnectToProjectCollectionCommand.java
@Override public String getName() { final String messageFormat = Messages.getString("ConnectToProjectCollectionCommand.ConnectToServerFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, serverURI.toString()); return message; }
From source file:com.microsoft.tfs.core.util.internal.AppleSingleUtil.java
/** * Encodes a file in-place, creating an AppleSingle file in place of the * given file.//from ww w .ja v a 2 s.com * * Technically creates an AppleSingle file in a temp file and renames it * over the given file. Note that this is not atomic. * * @param file * The file to encode into an AppleSingle file * @param filename * The output filename to encode in the AppleSingle file */ public static void encodeFile(final File file, final String filename) throws IOException { /* * Do not alter files on non-Mac OS X platforms * * TODO: at some point we should split these into data fork + * AppleDouble files */ if (!Platform.isCurrentPlatform(Platform.MAC_OS_X)) { throw new IOException( MessageFormat.format(Messages.getString("AppleSingleUtil.NotSupportedOnPlatformFormat"), //$NON-NLS-1$ Platform.getCurrentPlatformString())); } final File directory = file.getParentFile(); File temp = File.createTempFile("teApple", ".tmp", directory); //$NON-NLS-1$ //$NON-NLS-2$ try { AppleSingleEncoderStream input = null; OutputStream output = null; /* * Create an AppleSingleEncoderStream. This is what does all the * magic, it reads a file and its resource forks, metadata, etc, off * disk and provides that information in an AppleSingle stream. * * Note that we allow callers to override filename (as they're * usually giving us a temp file) and we use an epoch date (to * ensure md5 sanity on unchanged files.) */ try { input = new AppleSingleEncoderStream(file); input.setFilesystem("Teamprise"); //$NON-NLS-1$ input.setFilename(filename); input.setDate(new Date(0)); output = new FileOutputStream(temp); duplicateFile(input, output); } finally { if (input != null) { try { input.close(); } catch (final Exception e) { log.warn(Messages.getString("AppleSingleUtil.CouldNotCloseAppleSingleInputStream"), e); //$NON-NLS-1$ } } if (output != null) { try { output.close(); } catch (final Exception e) { log.warn(Messages.getString("AppleSingleUtil.CouldNotCloseAppleSingleOutputStream"), e); //$NON-NLS-1$ } } } renameFile(temp, file); temp = null; } finally { if (temp != null) { temp.delete(); } } }
From source file:com.microsoft.tfs.client.common.ui.webaccessintegration.browserfunctions.WorkItemSavedBrowserFunction.java
@Override public Object function(final Object[] arguments) { Check.notNull(arguments, "arguments"); //$NON-NLS-1$ Check.isTrue(arguments.length == 1, "arguments.length == 1"); //$NON-NLS-1$ Check.isTrue(arguments[0] instanceof String, "arguments[0] instanceof String"); //$NON-NLS-1$ final String artifactURI = (String) arguments[0]; int workItemID; try {/*from w w w.ja va 2s. c o m*/ final ArtifactID artifactID = new ArtifactID(artifactURI); workItemID = Integer.parseInt(artifactID.getToolSpecificID()); } catch (final MalformedURIException e) { final String format = Messages.getString("WorkItemSavedBrowserFunction.MalformedURIFormat"); //$NON-NLS-1$ final String message = MessageFormat.format(format, artifactURI); log.error(message, e); return null; } editor.onWorkItemSaved(workItemID); return null; }
From source file:ch.cyberduck.core.aquaticprime.AbstractLicense.java
@Override public String toString() { return MessageFormat.format(LocaleFactory.localizedString("Registered to {0}", "License"), this.getName()); }