List of usage examples for java.util Formatter format
public Formatter format(String format, Object... args)
From source file:edu.cmu.tetrad.cli.search.FgsdCli.java
@Override public void printValidationInfos(Formatter fmt) { fmt.format("ensure variable names are unique = %s%n", !skipUniqueVarName); fmt.format("limit number of categories (%d) = %s%n", CATEGORY_LIMIT, !skipCategoryLimit); }
From source file:edu.cmu.tetrad.cli.search.FgsdCli.java
@Override public void printParameterInfos(Formatter fmt) { fmt.format("sample prior = %f%n", samplePrior); fmt.format("structure prior = %f%n", structurePrior); fmt.format("max degree = %d%n", maxDegree); fmt.format("faithfulness assumed = %s%n", faithfulnessAssumed); }
From source file:com.itemanalysis.psychometrics.irt.estimation.ItemFitG2.java
@Override public String toString() { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); f.format("%5s", "G2 "); f.format("%8.4d", getValue()); f.format("%2s", ""); f.format("%4d", (int) getDegreesOfFreedom()); f.format("%2s", ""); f.format("%1.4f", getPValue()); return f.toString(); }
From source file:org.gradle.internal.execution.impl.steps.SkipUpToDateStep.java
private void logOutOfDateReasons(List<String> reasons, UnitOfWork work) { if (LOGGER.isInfoEnabled()) { Formatter formatter = new Formatter(); formatter.format("%s is not up-to-date because:", StringUtils.capitalize(work.getDisplayName())); for (String message : reasons) { formatter.format("%n %s", message); }// w ww . j a v a 2s. c o m LOGGER.info(formatter.toString()); } }
From source file:org.gss_project.gss.server.BaseServlet.java
/** * A helper method that converts a byte buffer to a printable list of * hexadecimal numbers.//from www. j a va 2 s .c om */ protected String getHexString(byte[] buffer) { StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb); for (int i = 0; i < buffer.length; i++) formatter.format("0x%x, ", buffer[i]); return sb.toString(); }
From source file:org.apache.sqoop.io.SplittingOutputStream.java
/** Initialize the OutputStream to the next file to write to. *//*from w w w . j a v a2s . co m*/ private void openNextFile() throws IOException { StringBuffer sb = new StringBuffer(); Formatter fmt = new Formatter(sb); fmt.format("%05d", this.fileNum++); String filename = filePrefix + fmt.toString(); if (codec != null) { filename = filename + codec.getDefaultExtension(); } Path destFile = new Path(destDir, filename); FileSystem fs = destFile.getFileSystem(conf); LOG.debug("Opening next output file: " + destFile); if (fs.exists(destFile)) { Path canonicalDest = destFile.makeQualified(fs); throw new IOException("Destination file " + canonicalDest + " already exists"); } OutputStream fsOut = fs.create(destFile); // Count how many actual bytes hit HDFS. this.countingFilterStream = new CountingOutputStream(fsOut); if (codec != null) { // Wrap that in a compressing stream. this.writeStream = codec.createOutputStream(this.countingFilterStream); } else { // Write to the counting stream directly. this.writeStream = this.countingFilterStream; } }
From source file:com.cloudera.sqoop.io.SplittingOutputStream.java
/** Initialize the OutputStream to the next file to write to. *//*from w w w . j a va 2 s . c o m*/ private void openNextFile() throws IOException { FileSystem fs = FileSystem.get(conf); StringBuffer sb = new StringBuffer(); Formatter fmt = new Formatter(sb); fmt.format("%05d", this.fileNum++); String filename = filePrefix + fmt.toString(); if (this.doGzip) { filename = filename + ".gz"; } Path destFile = new Path(destDir, filename); LOG.debug("Opening next output file: " + destFile); if (fs.exists(destFile)) { Path canonicalDest = destFile.makeQualified(fs); throw new IOException("Destination file " + canonicalDest + " already exists"); } OutputStream fsOut = fs.create(destFile); // Count how many actual bytes hit HDFS. this.countingFilterStream = new CountingOutputStream(fsOut); if (this.doGzip) { // Wrap that in a Gzip stream. this.writeStream = new GZIPOutputStream(this.countingFilterStream); } else { // Write to the counting stream directly. this.writeStream = this.countingFilterStream; } }
From source file:com.pivotal.gemfire.tools.pulse.internal.service.MemberClientsService.java
public JSONObject execute(final HttpServletRequest request) throws Exception { // get cluster object Cluster cluster = Repository.get().getCluster(); // json object to be sent as response JSONObject responseJSON = new JSONObject(); try {//from w w w . j av a2 s . c o m JSONObject requestDataJSON = new JSONObject(request.getParameter("pulseData")); String memberName = requestDataJSON.getJSONObject("MemberClients").getString("memberName"); JSONArray clientListJson = new JSONArray(); Cluster.Member clusterMember = cluster.getMember(StringUtils.makeCompliantName(memberName)); if (clusterMember != null) { responseJSON.put("memberId", clusterMember.getId()); responseJSON.put(this.NAME, clusterMember.getName()); responseJSON.put(this.HOST, clusterMember.getHost()); // member's clients Cluster.Client[] memberClients = clusterMember.getMemberClients(); for (Cluster.Client memberClient : memberClients) { JSONObject regionJSON = new JSONObject(); regionJSON.put("clientId", memberClient.getId()); regionJSON.put(this.NAME, memberClient.getName()); regionJSON.put(this.HOST, memberClient.getHost()); regionJSON.put("queueSize", memberClient.getQueueSize()); regionJSON.put("uptime", TimeUtils.convertTimeSecondsToHMS(memberClient.getUptime())); Formatter fmt = new Formatter(); regionJSON.put("cpuUsage", fmt.format("%.4f", memberClient.getCpuUsage()).toString()); // regionJSON.put("cpuUsage", memberClient.getCpuUsage()); regionJSON.put("threads", memberClient.getThreads()); regionJSON.put("gets", memberClient.getGets()); regionJSON.put("puts", memberClient.getPuts()); clientListJson.put(regionJSON); fmt.close(); } responseJSON.put("memberClients", clientListJson); } // Send json response return responseJSON; } catch (JSONException e) { throw new Exception(e); } }
From source file:com.itemanalysis.psychometrics.statistics.StorelessDescriptiveStatistics.java
public String toString(String title) { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); f.format("%-50s", title); f.format("%n"); f.format("%30s", "=============================="); f.format("%n"); f.format("%-10s", "Statistic"); f.format("%5s", ""); f.format("%10s", "Value"); f.format("%5s", ""); f.format("%n"); f.format("%30s", "------------------------------"); f.format("%n"); f.format("%-10s", "N"); f.format("%5s", ""); f.format("%10.4f", (double) m.getN()); f.format("%5s", ""); f.format("%n"); f.format("%-10s", "Min"); f.format("%5s", ""); f.format("%10.4f", min.getResult()); f.format("%5s", ""); f.format("%n"); f.format("%-10s", "Max"); f.format("%5s", ""); f.format("%10.4f", max.getResult()); f.format("%5s", ""); f.format("%n"); f.format("%-10s", "Mean"); f.format("%5s", ""); f.format("%10.4f", m.getResult()); f.format("%5s", ""); f.format("%n"); f.format("%-10s", "St. Dev."); f.format("%5s", ""); f.format("%10.4f", sd.getResult()); f.format("%5s", ""); f.format("%n"); f.format("%-10s", "Skewness"); f.format("%5s", ""); f.format("%10.4f", skew.getResult()); f.format("%5s", ""); f.format("%n"); f.format("%-10s", "Kurtosis"); f.format("%5s", ""); f.format("%10.4f", kurt.getResult()); f.format("%5s", ""); f.format("%n"); f.format("%30s", "=============================="); f.format("%n"); return f.toString(); }
From source file:com.itemanalysis.psychometrics.mixture.MvNormalComponentDistribution.java
public String printMean() { StringBuilder sb = new StringBuilder(); Formatter f = new Formatter(sb); for (int i = 0; i < mu.getRowDimension(); i++) { f.format("% 8.2f", mu.getEntry(i, 0)); f.format("%5s", ""); }//from www.j a v a2 s. c o m f.format("%n"); return f.toString(); }