List of usage examples for java.text MessageFormat format
public static String format(String pattern, Object... arguments)
From source file:com.microsoft.azure.management.datalake.store.uploader.UploadMetadataGeneratorTests.java
@Test public void UploadMetadataGenerator_AlignSegmentsToRecordBoundaries() throws IOException, UploadFailedException, InvalidMetadataException { //We keep creating a file, by appending a number of bytes to it (taken from FileLengthsInMB). //At each iteration, we append a new blob of data, and then run the whole test on the entire file Random rnd = new Random(0); File folderPath = new File(MessageFormat.format("{0}\\uploadtest", new File(".").getAbsoluteFile())); File filePath = new File(folderPath, "verifymetadata.txt"); try {//from w ww. j a va2 s . c o m if (!folderPath.exists()) { folderPath.mkdirs(); } if (filePath.exists()) { filePath.delete(); } for (Number lengthMB : FileLengthsMB) { int appendLength = (int) (lengthMB.doubleValue() * 1024 * 1024); AppendToFile(filePath.getAbsolutePath(), appendLength, rnd, 0, MaxAppendLength); String metadataFilePath = filePath + ".metadata.txt"; UploadParameters up = new UploadParameters(filePath.getAbsolutePath(), filePath.getAbsolutePath(), null, 1, false, false, false, 4 * 1024 * 1024, null); UploadMetadataGenerator mg = new UploadMetadataGenerator(up, MaxAppendLength); UploadMetadata metadata = mg.createNewMetadata(metadataFilePath); VerifySegmentsAreOnRecordBoundaries(metadata, filePath.getAbsolutePath()); } } finally { if (folderPath.exists()) { FileUtils.deleteQuietly(folderPath); } } }
From source file:br.com.tcc.rest.config.TccExceptionHandler.java
@Override public Response toResponse(Exception exception) { Throwable cleanException = cleanException(exception); LoggerFactory.getLogger(getClass()).error(cleanException.getMessage(), cleanException); String message = cleanException.getMessage(); if (cleanException instanceof BusinessException) { StringBuilder builder = new StringBuilder(); for (Pendency pendency : ((PendingException) cleanException).getPending()) { builder.append(MessageFormat.format(getBundleMessage(pendency.getMessage()), (pendency.getAdditionalData()))); builder.append(System.getProperty("line.separator")); builder.append(System.getProperty("line.separator")); }/*w ww . j av a 2 s . c o m*/ message = builder.toString(); } else if (cleanException instanceof PendingException) { message = MessageFormat.format(getBundleMessage(message), ((BusinessException) cleanException).getMessageParams()); //message = StringEscapeUtils.escapeHtml3(builder.toString()); } message = message == null ? "null" : message; Map m = new HashMap(); m.put("message", message); m.put("st", ExceptionUtils.getFullStackTrace(cleanException)); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(m).type("application/json").build(); //return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(message).type(MediaType.TEXT_HTML).build(); }
From source file:com.asakusafw.runtime.io.sequencefile.SequenceFileUtil.java
/** * Creates a new reader.//from w w w .j av a 2 s . co m * @param in the source * @param status target file status * @param conf current configuration * @return the created sequence file reader * @throws IOException if failed to open the sequence file * @throws IllegalArgumentException if some parameters were {@code null} */ public static SequenceFile.Reader openReader(InputStream in, FileStatus status, Configuration conf) throws IOException { if (in == null) { throw new IllegalArgumentException("in must not be null"); //$NON-NLS-1$ } if (status == null) { throw new IllegalArgumentException("status must not be null"); //$NON-NLS-1$ } if (conf == null) { throw new IllegalArgumentException("conf must not be null"); //$NON-NLS-1$ } if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format("Creating sequence file reader for {0}", //$NON-NLS-1$ status.getPath())); } return new SequenceFile.Reader(conf, SequenceFile.Reader.stream(new FSDataInputStream(new WrappedInputStream(in))), SequenceFile.Reader.length(status.getLen())); }
From source file:ch.cyberduck.ui.action.WriteMetadataWorker.java
@Override public String getActivity() { return MessageFormat.format(Locale.localizedString("Writing metadata of {0}", "Status"), this.toString(files)); }
From source file:edu.usu.sdl.core.init.ApplyOnceInit.java
public void applyChanges() { log.log(Level.INFO, MessageFormat.format("Checking {0} to make sure it''s applied.", appliedKey)); String lastRunString = service.getSystemService().getPropertyValue(appliedKey + "_LASTRUN_DTS"); if (StringUtils.isNotBlank(lastRunString)) { log.log(Level.INFO, MessageFormat.format("Already Applied {0} on {1}", appliedKey, lastRunString)); } else {/* w ww. jav a 2 s . c o m*/ String results = internalApply(); log.log(Level.INFO, MessageFormat.format("Applied {0} changes", appliedKey)); service.getSystemService().saveProperty(appliedKey + "_LASTRUN_DTS", TimeUtil.dateToString(TimeUtil.currentDate())); service.getSystemService().saveProperty(appliedKey + "_STATUS", results); } }
From source file:com.nearinfinity.blur.log.LogImpl.java
public void debug(Object message, Throwable t, Object... args) { if (isDebugEnabled()) { log.debug(MessageFormat.format(message.toString(), args), t); }//w ww. java2s . c o m }
From source file:nz.co.senanque.sandbox.LocaleTest.java
@Test public void testValidate() { Locale locale = new Locale("fr"); Locale.setDefault(locale);/*from w w w .j a v a2 s. c o m*/ String t = MessageFormat.format( "chec de l''envoi: label = {0} n''est pas une adresse email valide, a tent = {1}", new Object[] { "aa", "bb" }); assertEquals("chec de l'envoi: label = aa n'est pas une adresse email valide, a tent = bb", t); }
From source file:com.swordlord.gozer.renderer.fop.FopTransformerErrorListener.java
public void error(TransformerException arg0) throws TransformerException { LOG.error(MessageFormat.format("Transformation error: {0}", arg0)); }
From source file:com.asakusafw.shafu.core.util.IoUtils.java
/** * Creates a new temporary folder.//from w w w . jav a2 s . com * @return the created folder * @throws IOException if failed to create a temporary folder */ public static File createTemporaryFolder() throws IOException { File file = File.createTempFile("dir", null); //$NON-NLS-1$ if (file.delete() == false) { throw new IOException(MessageFormat.format(Messages.IoUtils_errorFailedToDeleteTemporaryFile, file)); } if (file.mkdirs() == false) { throw new IOException( MessageFormat.format(Messages.IoUtils_errorFailedToCreateTemporaryDirectory, file)); } return file; }
From source file:nu.yona.server.Translator.java
public static String buildLocaleSpecificResourcePath(String format) { return MessageFormat.format(format, determineLocaleInfix()); }