本文整理汇总了Java中org.apache.commons.lang3.text.StrBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java StrBuilder.build方法的具体用法?Java StrBuilder.build怎么用?Java StrBuilder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.text.StrBuilder
的用法示例。
在下文中一共展示了StrBuilder.build方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildFluentPathExpression
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
private static String buildFluentPathExpression(LinkedList<ContentPathSegment<?, ?>> segments) {
StrBuilder builder = new StrBuilder();
ElementPathSegment elemSegment;
for (ContentPathSegment<?, ?> segment : segments) {
builder.appendSeparator(SdcctStringUtils.PERIOD_CHAR);
builder.append(segment.getLocalName());
if ((segment instanceof ElementPathSegment) && (elemSegment = ((ElementPathSegment) segment)).hasIndex()) {
builder.append(SdcctStringUtils.L_BRACKET_CHAR);
builder.append(elemSegment.getIndex());
builder.append(SdcctStringUtils.R_BRACKET_CHAR);
}
}
return builder.build();
}
示例2: buildJsonPointerExpression
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
private static String buildJsonPointerExpression(LinkedList<ContentPathSegment<?, ?>> segments) {
StrBuilder builder = new StrBuilder();
ElementPathSegment elemSegment;
for (ContentPathSegment<?, ?> segment : segments) {
builder.append(SdcctStringUtils.SLASH_CHAR);
builder.append(segment.getLocalName());
if ((segment instanceof ElementPathSegment) && (elemSegment = ((ElementPathSegment) segment)).hasIndex()) {
builder.append(SdcctStringUtils.SLASH_CHAR);
builder.append(elemSegment.getIndex());
}
}
return builder.build();
}
示例3: getStringValue
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
@Nullable
public static String getStringValue(@Nullable Sequence seq) {
if (seq == null) {
return null;
}
if (seq instanceof AtomicValue) {
return ((AtomicValue) seq).getStringValue();
} else if (seq instanceof Item) {
return ((Item) seq).getStringValue();
} else {
try {
SequenceIterator seqIterator = seq.iterate();
StrBuilder builder = new StrBuilder();
Item seqItem;
while ((seqItem = seqIterator.next()) != null) {
Optional.ofNullable(getStringValue(seqItem)).ifPresent(builder::append);
}
return builder.build();
} catch (XPathException e) {
throw new SaxonApiUncheckedException(e);
}
}
}
示例4: buildSafeFileName
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
public static String buildSafeFileName(String fileName) {
char[] fileNameChars = FilenameUtils.getName(fileName).toCharArray();
StrBuilder fileNameBuilder = new StrBuilder(fileNameChars.length);
char fileNameChar;
for (int a = 0; a < fileNameChars.length; a++) {
if (!CharUtils.isAscii((fileNameChar = fileNameChars[a]))) {
continue;
}
if (Character.isWhitespace(fileNameChar)) {
while (((a + 1) < fileNameChars.length) && Character.isWhitespace(fileNameChars[(a + 1)])) {
a++;
}
if (!fileNameBuilder.isEmpty() && ((a + 2) < fileNameChars.length)) {
fileNameBuilder.append(StringUtils.SPACE);
}
} else if (Character.isLetterOrDigit(fileNameChar) || (fileNameChar == CrigttStringUtils.HYPHEN_CHAR)
|| (fileNameChar == CrigttStringUtils.PERIOD_CHAR) || (fileNameChar == CrigttStringUtils.UNDERSCORE_CHAR)) {
fileNameBuilder.append(fileNameChar);
}
}
return fileNameBuilder.build();
}
示例5: assemble
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
private String assemble() throws UserscriptBuilderException {
StrBuilder builder = new StrBuilder();
builder.appendln("// ==UserScript==");
appendValid(builder, "// @name ", userscript.getMetadata().getName());
appendValid(builder, "// @namespace ", userscript.getMetadata().getNamespace());
appendValid(builder, "// @description ", userscript.getMetadata().getDescription());
appendValid(builder, "// @version ", userscript.getMetadata().getVersion());
appendValid(builder, "// @author ", userscript.getMetadata().getAuthor());
appendValid(builder, "// @include ", userscript.getMetadata().getIncludes());
appendValid(builder, "// @exclude ", userscript.getMetadata().getExcludes());
appendValid(builder, "// @match ", userscript.getMetadata().getMatches());
appendValid(builder, "// @require ", userscript.getMetadata().getRequires());
appendValid(builder, "// @resource ", userscript.getMetadata().getResources());
appendValid(builder, "// @grant ", userscript.getMetadata().getGrants());
appendValid(builder, "// @noframes ", userscript.getMetadata().isNoFrames());
appendValid(builder, "// @run-at ", userscript.getMetadata().getRunAt());
appendValid(builder, "// @icon ", userscript.getMetadata().getIcon());
appendValid(builder, "// @downloadURL ", userscript.getMetadata().getDownloadURL());
appendValid(builder, "// @updateURL ", userscript.getMetadata().getUpdateURL());
builder.appendln("// ==/UserScript==");
builder.appendNewLine();
File sourceFile = new File(mojo.getSourceDirectory(), userscript.getSource());
String source;
try {
source = FileUtils.readFileToString(sourceFile);
} catch (IOException e) {
throw new UserscriptBuilderException("Could not read sourceFile: " + sourceFile.getPath(), e);
}
builder.append(filterSource(source));
return builder.build();
}
示例6: buildXpathExpression
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
private String buildXpathExpression(Map<String, String> namespaces, LinkedList<ContentPathSegment<?, ?>> segments) {
StrBuilder builder = new StrBuilder();
String nsPrefix;
boolean attrSegmentItem;
ElementPathSegment elemSegment;
for (ContentPathSegment<?, ?> segment : segments) {
builder.append(SdcctStringUtils.SLASH_CHAR);
if ((attrSegmentItem = (segment instanceof AttributePathSegment))) {
builder.append(SdcctStringUtils.AT_CHAR);
}
final String nsUri = segment.getNamespaceUri();
if (!(nsPrefix = namespaces.entrySet().stream().filter(nsEntry -> nsEntry.getValue().equals(nsUri)).findFirst().map(Entry::getKey)
.orElseGet(segment::getNamespacePrefix)).isEmpty()) {
builder.append(nsPrefix);
builder.append(SdcctStringUtils.COLON_CHAR);
}
builder.append(segment.getLocalName());
if (!attrSegmentItem && (elemSegment = ((ElementPathSegment) segment)).hasIndex()) {
builder.append(SdcctStringUtils.L_BRACKET_CHAR);
// noinspection ConstantConditions
builder.append((elemSegment.getIndex() + 1));
builder.append(SdcctStringUtils.R_BRACKET_CHAR);
}
}
return builder.build();
}
示例7: buildMessage
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
private static String buildMessage(EntityEventType eventType, Object entity, Serializable id, boolean includeState, Object[] states, String[] propNames,
Type[] types) {
StrBuilder msgBuilder = new StrBuilder("Entity (class=");
msgBuilder.append(entity.getClass().getName());
msgBuilder.append(", id=");
msgBuilder.append(id);
msgBuilder.append(") ");
msgBuilder.append(eventType.getId());
msgBuilder.append(": [");
for (int a = 0; a < propNames.length; a++) {
if (a > 0) {
msgBuilder.append("; ");
}
msgBuilder.append("{propName=");
msgBuilder.append(propNames[a]);
msgBuilder.append(", type=");
msgBuilder.append(types[a].getName());
if (includeState) {
msgBuilder.append(", state=");
msgBuilder.append(states[a]);
}
msgBuilder.append("}");
}
msgBuilder.append("]");
return msgBuilder.build();
}
示例8: buildMessage
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
private static String buildMessage(SdcctEntity entity, EntityIndexingEventType eventType) {
Class<? extends SdcctEntity> entityClass = entity.getClass();
StrBuilder msgBuilder = new StrBuilder("Entity (class=");
msgBuilder.append(entityClass.getName());
msgBuilder.append(", name=");
msgBuilder.append(entityClass.getAnnotation(Entity.class).name());
msgBuilder.append(", id=");
msgBuilder.append(entity.getEntityId());
msgBuilder.append(") ");
msgBuilder.append(eventType.getId());
msgBuilder.append(" in index.");
return msgBuilder.build();
}
示例9: joinCamelCase
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
public static String joinCamelCase(boolean capitalize, String ... strParts) {
if (strParts.length == 0) {
return StringUtils.EMPTY;
}
String strPart;
if (strParts.length == 1) {
strPart = strParts[0].toLowerCase();
return (capitalize ? StringUtils.capitalize(strPart) : strPart);
}
StrBuilder strBuilder = new StrBuilder();
for (int a = 0; a < strParts.length; a++) {
strPart = strParts[a].toLowerCase();
if (capitalize || (a > 0)) {
strPart = StringUtils.capitalize(strPart);
}
strBuilder.append(strPart);
}
return strBuilder.build();
}
示例10: buildFunctionCall
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
public static String buildFunctionCall(String funcName, String ... args) {
StrBuilder funcCallBuilder = new StrBuilder(funcName);
funcCallBuilder.append(CALL_PREFIX);
funcCallBuilder.appendWithSeparators(args, ITEM_DELIM);
funcCallBuilder.append(CALL_SUFFIX);
return funcCallBuilder.build();
}
示例11: buildSelectQuery
import org.apache.commons.lang3.text.StrBuilder; //导入方法依赖的package包/类
public static <T> OSQLSynchQuery<T> buildSelectQuery(Class<T> targetClass, @Nullable String targetClassName, @Nullable List<String> projections,
Map<String, String> params, @Nullable String groupByFieldName) {
StrBuilder queryBuilder = new StrBuilder(SELECT_CMD);
queryBuilder.append(StringUtils.SPACE);
if (!CollectionUtils.isEmpty(projections)) {
queryBuilder.appendWithSeparators(projections, ITEM_DELIM);
queryBuilder.append(StringUtils.SPACE);
}
queryBuilder.append(FROM_OP);
queryBuilder.append(StringUtils.SPACE);
queryBuilder.append(((targetClassName != null) ? targetClassName : targetClass.getSimpleName()));
queryBuilder.append(StringUtils.SPACE);
if (!MapUtils.isEmpty(params)) {
queryBuilder.append(WHERE_OP);
String[] paramNames = params.keySet().toArray(new String[params.size()]);
for (int a = 0; a < paramNames.length; a++) {
queryBuilder.append(StringUtils.SPACE);
if (a > 0) {
queryBuilder.append(AND_OP);
queryBuilder.append(StringUtils.SPACE);
}
queryBuilder.append(paramNames[a]);
queryBuilder.append(StringUtils.SPACE);
if (params.get(paramNames[a]) != null) {
queryBuilder.append(EQ_OP);
queryBuilder.append(StringUtils.SPACE);
queryBuilder.append(PARAM_PREFIX);
queryBuilder.append(paramNames[a]);
} else {
queryBuilder.append(IS_OP);
queryBuilder.append(StringUtils.SPACE);
queryBuilder.append(NULL_VALUE);
}
}
}
if (groupByFieldName != null) {
queryBuilder.append(StringUtils.SPACE);
queryBuilder.append(GROUP_OP);
queryBuilder.append(StringUtils.SPACE);
queryBuilder.append(BY_OP);
queryBuilder.append(StringUtils.SPACE);
queryBuilder.append(groupByFieldName);
}
return new OSQLSynchQuery<>(queryBuilder.build());
}