List of usage examples for java.util Formatter out
public Appendable out()
From source file:org.LexGrid.LexBIG.admin.ListSchemes.java
/** * Primary entry point for the program./* ww w. java2 s.c o m*/ * * @throws Exception */ public void run(String[] args) throws Exception { synchronized (ResourceManager.instance()) { LexBIGService lbs = LexBIGServiceImpl.defaultInstance(); CodingSchemeRenderingList schemes = lbs.getSupportedCodingSchemes(); // Parse the command line ... CommandLine cl = null; Options options = getCommandOptions(); try { cl = new BasicParser().parse(options, args); } catch (ParseException e) { Util.displayCommandOptions("ListExtensions", options, "ListExtensions -a", e); return; } if (schemes.getCodingSchemeRenderingCount() == 0) Util.displayMessage("No coding schemes found."); else { boolean fullRequested = cl.hasOption('f'); if (fullRequested) { for (CodingSchemeRendering csr : schemes.getCodingSchemeRendering()) { // Separator ... Util.displayMessage("============================="); CodingSchemeSummary css = csr.getCodingSchemeSummary(); CodingScheme cs = lbs.resolveCodingScheme(css.getCodingSchemeURI(), Constructors.createCodingSchemeVersionOrTagFromVersion(css.getRepresentsVersion())); Util.displayMessage(ObjectToString.toString(cs, "", 80)); } } else { Formatter f = new Formatter(); String format = "%-20.20s|%-10.10s|%-35.35s|%-10.10s\n"; Object[] hSep = new Object[] { Dash20, Dash10, Dash35, Dash10 }; f.format(format, hSep); f.format(format, new Object[] { "Local Name", "Version", "URN", "Tag" }); f.format(format, hSep); for (CodingSchemeRendering csr : schemes.getCodingSchemeRendering()) { CodingSchemeSummary css = csr.getCodingSchemeSummary(); // Evaluate local name String localName = css.getLocalName(); if (localName != null && localName.length() > 20) localName = localName.substring(0, 18) + ">>"; // Evaluate version String version = css.getRepresentsVersion(); if (version != null && version.length() > 10) version = version.substring(0, 8) + ">>"; // Evaluate urn String urn = css.getCodingSchemeURI(); if (urn != null && urn.length() > 35) urn = urn.substring(0, 33) + ">>"; // Evaluate tag(s) String[] tags = csr.getRenderingDetail().getVersionTags().getTag(); String tag = tags.length > 0 ? tags[0] : ""; if (tag != null && tag.length() > 10) tag = tag.substring(0, 8) + ">>"; // Output the first line f.format(format, new Object[] { localName, version, urn, tag }); // Output additional tags for (int i = 1; i < tags.length; i++) { tag = tags[i]; if (tag != null && tag.length() > 10) tag = tag.substring(0, 8) + ">>"; f.format(format, "", "", "", tag); } // Output separator f.format(format, hSep); } Util.displayMessage(f.out().toString()); Util.displayMessage(""); Util.displayMessage("NOTE: >> indicates column value exceeds the available width."); Util.displayMessage(" Specify the '-f' option for additional detail."); } } } }
From source file:org.apache.hadoop.dfs.FSNamesystem.java
private static final void logAuditEvent(UserGroupInformation ugi, InetAddress addr, String cmd, String src, String dst, FileStatus stat) { final Formatter fmt = auditFormatter.get(); ((StringBuilder) fmt.out()).setLength(0); auditLog.info(fmt.format(AUDIT_FORMAT, ugi, addr, cmd, src, dst, (stat == null) ? null : stat.getOwner() + ':' + stat.getGroup() + ':' + stat.getPermission()) .toString());// ww w . j av a 2s . com }
From source file:org.apache.jxtadoop.hdfs.server.namenode.FSNamesystem.java
private static final void logAuditEvent(UserGroupInformation ugi, PeerID pid, String cmd, String src, String dst, FileStatus stat) { final Formatter fmt = auditFormatter.get(); ((StringBuilder) fmt.out()).setLength(0); auditLog.info(fmt.format(AUDIT_FORMAT, ugi, pid, cmd, src, dst, (stat == null) ? null : stat.getOwner() + ':' + stat.getGroup() + ':' + stat.getPermission()) .toString());/* ww w. j a va 2 s. c o m*/ }
From source file:org.apache.hadoop.hdfs.server.namenode.FSNamesystem.java
private static final void logAuditEvent(UserGroupInformation ugi, InetAddress addr, String cmd, String src, String dst, HdfsFileStatus stat) { final Formatter fmt = auditFormatter.get(); ((StringBuilder) fmt.out()).setLength(0); auditLog.info(fmt.format(AUDIT_FORMAT, ugi, addr, cmd, src, dst, (stat == null) ? null : stat.getOwner() + ':' + stat.getGroup() + ':' + stat.getPermission()) .toString());//from w w w . j ava 2s. co m }