本文整理汇总了Java中org.apache.commons.lang.text.StrBuilder.append方法的典型用法代码示例。如果您正苦于以下问题:Java StrBuilder.append方法的具体用法?Java StrBuilder.append怎么用?Java StrBuilder.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.text.StrBuilder
的用法示例。
在下文中一共展示了StrBuilder.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* Entry point for generating a directory listing.
*/
public void execute(PrintWriter out, PrintWriter err) {
StrBuilder output = new StrBuilder();
if (listProfiles) {
output.append(createProfileListing());
} else if (printProfile) {
output.append(getProfileDetails(profileName));
} else if (createProfile) {
output.append(createProfile());
} else if (deleteProfile) {
output.append(deleteProfile());
} else {
output.append(helpScreen());
}
out.println(output.toString());
out.flush();
err.flush();
}
示例2: createProfileListing
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* Create the Profile listing output
*/
protected String createProfileListing() {
StrBuilder sb = new StrBuilder();
List<AbstractProfileBase> profileList = getProfiles();
columnWidths = calcColumnWidths(profileList);
for (Map.Entry<String, Integer> entry : columnWidths.entrySet()) {
sb.appendFixedWidthPadRight(entry.getKey(), entry.getValue(), ' ').append(COL_SEP);
}
sb.append(NEWLINE);
for (AbstractProfileBase profile : profileList) {
sb.appendFixedWidthPadRight("" + profile.getName(), columnWidths.get(KEY_PROFILE_NAME),
' ')
.append(COL_SEP);
sb.appendFixedWidthPadRight("" + profile.getType(), columnWidths.get(KEY_TYPE), ' ')
.append(COL_SEP);
sb.append(NEWLINE);
}
return sb.toString();
}
示例3: toString
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* <p>Returns the string representation of this range.</p>
*
* <p>This string is the string representation of the minimum and
* maximum numbers in the range, separated by a hyphen. If a number
* is negative, then it is enclosed in parentheses.</p>
*
* @return the string representation of this range
*/
public String toString() {
StrBuilder sb = new StrBuilder();
if (min.doubleValue() < 0) {
sb.append('(')
.append(min)
.append(')');
} else {
sb.append(min);
}
sb.append('-');
if (max.doubleValue() < 0) {
sb.append('(')
.append(max)
.append(')');
} else {
sb.append(max);
}
return sb.toString();
}
示例4: toString
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* <p>Gets a string representation of the character range.</p>
*
* @return string representation of this range
*/
public String toString() {
if (iToString == null) {
StrBuilder buf = new StrBuilder(4);
if (isNegated()) {
buf.append('^');
}
buf.append(start);
if (start != end) {
buf.append('-');
buf.append(end);
}
iToString = buf.toString();
}
return iToString;
}
示例5: errorLocator
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
private String errorLocator(Throwable exception) {
String base = exception.getClass().getSimpleName();
if (exception.getStackTrace().length == 0) {
return base;
}
StrBuilder buf = new StrBuilder(512);
buf.append(base).append("<br />");
int count = 0;
for (int i = 0; i < exception.getStackTrace().length && count < 4; i++) {
StackTraceElement ste = exception.getStackTrace()[i];
if (ste.getClassName().startsWith("sun.") || ste.getClassName().startsWith("javax.") || ste.getClassName().startsWith("com.sun.") ||
(ste.getClassName().equals("java.lang.reflect.Method") && ste.getMethodName().equals("invoke"))) {
continue;
}
if (ste.getLineNumber() >= 0) {
buf.append(String.format(" at %s.%s() L%d<br />", ste.getClassName(), ste.getMethodName(), ste.getLineNumber()));
} else {
buf.append(String.format(" at %s.%s()<br />", ste.getClassName(), ste.getMethodName()));
}
count++;
}
return buf.toString();
}
示例6: of
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* Obtains a failure result for a non-empty list of failures.
*
* @param failures the failures, not empty, not null
* @return the failure result, not null
*/
static <U> Result<U> of(List<Failure> failures) {
ArgumentChecker.notEmpty(failures, "failures");
ImmutableSet<Failure> fails = ImmutableSet.copyOf(failures);
FailureStatus status = fails.iterator().next().getStatus();
StrBuilder buf = new StrBuilder();
for (Failure failure : fails) {
buf.appendSeparator(", ");
buf.append(failure.getMessage());
if (!status.equals(failure.getStatus())) {
status = FailureStatus.MULTIPLE;
}
}
Result<?> result = new FailureResult<>(fails, status, buf.toString());
return Result.failure(result);
}
示例7: toLongString
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* Gets a full-detail string containing all child nodes and positions.
*
* @return the full-detail string, not null
*/
public String toLongString() {
StrBuilder childBuf = new StrBuilder(1024);
childBuf.append("[");
for (int i = 0; i < getChildNodes().size(); i++) {
PortfolioNode child = getChildNodes().get(i);
if (child instanceof SimplePortfolioNode) {
childBuf.append(((SimplePortfolioNode) child).toLongString());
} else {
childBuf.append(child.toString());
}
if (i != getChildNodes().size() - 1) {
childBuf.append(",");
}
}
childBuf.append("]");
return new StrBuilder(childBuf.size() + 128)
.append("PortfolioNode[uniqueId=")
.append(getUniqueId())
.append(",childNodes=")
.append(childBuf)
.append(",positions=")
.append(getPositions()).append("]")
.toString();
}
示例8: appendOrderByClause
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* Appends the ORDER BY clause of the sql query to the given string builder.
*
* @param query The query.
* @param queryStringBuilder The string builder holding the string query.
*/
static void appendOrderByClause(Query query, StrBuilder queryStringBuilder) {
if (!query.hasSort()) {
return;
}
queryStringBuilder.append("ORDER BY ");
QuerySort querySort = query.getSort();
List<ColumnSort> sortColumns = querySort.getSortColumns();
int numOfSortColumns = sortColumns.size();
for (int col = 0; col < numOfSortColumns; col++) {
ColumnSort columnSort = sortColumns.get(col);
queryStringBuilder.append(getColumnId(columnSort.getColumn()));
if (columnSort.getOrder() == SortOrder.DESCENDING) {
queryStringBuilder.append(" DESC");
}
if (col < numOfSortColumns - 1) {
queryStringBuilder.append(", ");
}
}
queryStringBuilder.append(" ");
}
示例9: appendSelectClause
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
/**
* Appends the SELECT clause of the sql query to the given string builder.
*
* @param query The query.
* @param queryStringBuilder The string builder holding the string query.
*/
static void appendSelectClause(Query query,
StrBuilder queryStringBuilder) {
queryStringBuilder.append("SELECT ");
// If it's a selectAll query, build "select *" clause.
if (!query.hasSelection()) {
queryStringBuilder.append("* ");
return;
}
List<AbstractColumn> columns = query.getSelection().getColumns();
int numOfColsInQuery = columns.size();
// Add the Ids of the columns to the select clause
for (int col = 0; col < numOfColsInQuery; col++) {
queryStringBuilder.append(getColumnId(columns.get(col)));
if (col < numOfColsInQuery - 1) {
queryStringBuilder.append(", ");
}
}
queryStringBuilder.append(" ");
}
示例10: executeCommand
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
@Override
public String executeCommand(final SigarProxy sigar) throws SigarException {
StrBuilder sb = new StrBuilder(200);
ProcStat procStat = sigar.getProcStat();
sb.append(TYPE_PROC);
sb.append(separator);
sb.append(procStat.getTotal());
sb.append(separator);
sb.append(procStat.getRunning());
sb.append(separator);
sb.append(procStat.getIdle());
sb.append(separator);
sb.append(procStat.getSleeping());
sb.append(separator);
sb.append(procStat.getStopped());
sb.append(separator);
sb.append(procStat.getZombie());
sb.append(separator);
sb.append(procStat.getThreads());
return sb.toString();
}
示例11: executeCommand
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
@Override
public String executeCommand(final SigarProxy sigar) throws SigarException {
StrBuilder sb = new StrBuilder(200);
CpuPerc[] cpus = sigar.getCpuPercList();
CpuPerc cpuAll = sigar.getCpuPerc();
sb.append(TYPE_CPU_X);
sb.append(separator);
writeCpu(sb, cpuAll);
if (cpus.length > 1) { // more than one CPU
appendLineBreak(sb);
for (int i = 0; i < cpus.length; i++) {
appendLineBreak(sb, i);
sb.append(TYPE_CPU + i);
sb.append(separator);
writeCpu(sb, cpus[i]);
}
}
return sb.toString();
}
示例12: executeCommand
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
@Override
public String executeCommand(final SigarProxy sigar) throws SigarException {
StrBuilder sb = new StrBuilder(200);
Swap swap = sigar.getSwap();
sb.append(TYPE_SWAP);
sb.append(separator);
sb.append(swap.getTotal() / 1024L);
sb.append(separator);
sb.append(swap.getUsed() / 1024L);
sb.append(separator);
sb.append(swap.getFree() / 1024L);
return sb.toString();
}
示例13: executeCommand
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
@Override
public String executeCommand(final SigarProxy sigar) throws SigarException {
StrBuilder sb = new StrBuilder(200);
String[] type = new String[] { "State.Name.sw=java" };
long[] pids = Shell.getPids(sigar, type);
for (int i = 0; i < pids.length; i++) {
appendLineBreak(sb, i);
sb.append(TYPE_JAVA_X + i);
sb.append(separator);
long pid = pids[i];
String cpuPerc = "?";
@SuppressWarnings("unchecked")
List<Object> info = new ArrayList<Object>(Ps.getInfo(sigar, pid));
ProcCpu cpu = sigar.getProcCpu(pid);
cpuPerc = CpuPerc.format(cpu.getPercent());
info.add(info.size() - 1, cpuPerc);
sb.append(Ps.join(info));
}
return sb.toString();
}
示例14: executeCommand
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
@Override
public String executeCommand(final SigarProxy sigar) throws SigarException {
StrBuilder sb = new StrBuilder(200);
Mem mem = sigar.getMem();
sb.append(TYPE_MEM);
sb.append(separator);
sb.append(mem.getTotal() / 1024L);
sb.append(separator);
sb.append(mem.getUsed() / 1024L);
sb.append(separator);
sb.append(mem.getFree() / 1024L);
sb.append(separator);
sb.append(mem.getActualUsed() / 1024L);
sb.append(separator);
sb.append(mem.getActualFree() / 1024L);
return sb.toString();
}
示例15: fullline
import org.apache.commons.lang.text.StrBuilder; //导入方法依赖的package包/类
public static String fullline(final ChatColor color, final ChatColor color2, final ChatColor style, char character, String mess) {
StrBuilder sb = new StrBuilder();
boolean t = true;
int l = 0;
if ((54 - mess.length()) % 2 == 0)
l = 54 / mess.length();
for (int i = 0; i < l + 1; i++) {
sb.append(style);
if (t) {
sb.append(color);
t = false;
} else {
sb.append(color2);
t = true;
}
sb.append(character);
}
return sb.toString() + " " + mess + " " + sb.toString();
}