本文整理汇总了Java中org.apache.commons.lang.text.StrBuilder类的典型用法代码示例。如果您正苦于以下问题:Java StrBuilder类的具体用法?Java StrBuilder怎么用?Java StrBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StrBuilder类属于org.apache.commons.lang.text包,在下文中一共展示了StrBuilder类的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: deleteProfile
import org.apache.commons.lang.text.StrBuilder; //导入依赖的package包/类
/**
* Delete an existing Profile
*/
protected String deleteProfile() {
StrBuilder output = new StrBuilder();
AbstractProfileBase profile = ProfileManager.getProfileByName(profileName);
try {
ProfileManager.deleteProfile(profile, true);
} catch (Exception e) {
String errMsg = "Error deleting profile '" + profile + "'";
errMsg = DBUtils.getErrorMessage(errMsg, e);
LOG.log(Level.WARNING, errMsg, e);
output.append(errMsg);
setExitCode(EXIT_CODE_DM_ERROR);
}
return output.toString();
}
示例3: 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();
}
示例4: 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();
}
示例5: squeeze
import org.apache.commons.lang.text.StrBuilder; //导入依赖的package包/类
/**
* <p>Squeezes any repetitions of a character that is mentioned in the
* supplied set.</p>
*
* <p>An example is:</p>
* <ul>
* <li>squeeze("hello", {"el"}) => "helo"</li>
* </ul>
*
* @see CharSet#getInstance(java.lang.String) for set-syntax.
* @param str the string to squeeze, may be null
* @param set the character set to use for manipulation, may be null
* @return modified String, <code>null</code> if null string input
*/
public static String squeeze(String str, String[] set) {
if (StringUtils.isEmpty(str) || ArrayUtils.isEmpty(set)) {
return str;
}
CharSet chars = CharSet.getInstance(set);
StrBuilder buffer = new StrBuilder(str.length());
char[] chrs = str.toCharArray();
int sz = chrs.length;
char lastChar = ' ';
char ch = ' ';
for (int i = 0; i < sz; i++) {
ch = chrs[i];
if (chars.contains(ch)) {
if ((ch == lastChar) && (i != 0)) {
continue;
}
}
buffer.append(ch);
lastChar = ch;
}
return buffer.toString();
}
示例6: 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;
}
示例7: toCanonicalName
import org.apache.commons.lang.text.StrBuilder; //导入依赖的package包/类
/**
* Converts a class name to a JLS style class name.
*
* @param className the class name
* @return the converted name
*/
private static String toCanonicalName(String className) {
className = StringUtils.deleteWhitespace(className);
if (className == null) {
throw new NullArgumentException("className");
} else if (className.endsWith("[]")) {
StrBuilder classNameBuffer = new StrBuilder();
while (className.endsWith("[]")) {
className = className.substring(0, className.length() - 2);
classNameBuffer.append("[");
}
String abbreviation = (String) abbreviationMap.get(className);
if (abbreviation != null) {
classNameBuffer.append(abbreviation);
} else {
classNameBuffer.append("L").append(className).append(";");
}
className = classNameBuffer.toString();
}
return className;
}
示例8: setValue
import org.apache.commons.lang.text.StrBuilder; //导入依赖的package包/类
protected void setValue(Object value, boolean updateEditComponent) {
if (!Objects.equals(value, this.value)) {
Object prevValue = this.value;
this.value = value;
for (ParamValueChangeListener listener : new ArrayList<>(listeners)) {
listener.valueChanged(prevValue, value);
}
if (updateEditComponent && this.editComponent instanceof Component.HasValue) {
if (value instanceof Collection && editComponent instanceof TextField) {
//if the value type is an array and the editComponent is a textField ('IN' condition for String attribute)
//then we should set the string value (not the array) to the text field
String caption = new StrBuilder().appendWithSeparators((Collection) value, ",").toString();
((TextField) editComponent).setValue(caption);
} else {
((Component.HasValue) editComponent).setValue(value);
}
}
}
}
示例9: createMetaData
import org.apache.commons.lang.text.StrBuilder; //导入依赖的package包/类
@Override
protected LiveDataMetaData createMetaData(ComponentRepository repo) {
List<ComponentInfo> infos = buildInfoList();
Set<ExternalScheme> schemes = Sets.newLinkedHashSet();
StrBuilder buf = new StrBuilder();
for (ComponentInfo info : infos) {
ComponentInfo infoProvider = repo.findInfo(LiveDataMetaDataProvider.class, info.getClassifier());
if (infoProvider == null) {
throw new OpenGammaRuntimeException("Unable to find matching LiveDataMetaDataProvider: " + info);
}
LiveDataMetaDataProvider provider = (LiveDataMetaDataProvider) repo.getInstance(infoProvider);
LiveDataMetaData metaData = provider.metaData();
schemes.addAll(metaData.getSupportedSchemes());
buf.appendSeparator(", ").append(metaData.getDescription());
}
return new LiveDataMetaData(ImmutableList.copyOf(schemes), LiveDataServerTypes.STANDARD, buf.toString());
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:18,代码来源:PriorityResolvingCombiningLiveDataServerComponentFactory.java
示例10: 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();
}
示例11: 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);
}
示例12: 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();
}
示例13: toString
import org.apache.commons.lang.text.StrBuilder; //导入依赖的package包/类
@Override
public String toString() {
return new StrBuilder(256)
.append("Trade[")
.append(getUniqueId())
.append(", ")
.append(getQuantity())
.append(' ')
.append(LinkUtils.best(getSecurityLink()))
.append(", ")
.append(getCounterparty())
.append(", ")
.append(getTradeDate())
.append(" ")
.append(getTradeTime())
.append(']')
.toString();
}
示例14: 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(" ");
}
示例15: 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(" ");
}