当前位置: 首页>>代码示例>>Java>>正文


Java StrBuilder.build方法代码示例

本文整理汇总了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();
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:18,代码来源:ContentPathBuilderImpl.java

示例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();
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:17,代码来源:ContentPathBuilderImpl.java

示例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);
        }
    }
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:27,代码来源:SdcctXdmUtils.java

示例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();
}
 
开发者ID:esacinc,项目名称:crigtt,代码行数:27,代码来源:CrigttFileUtils.java

示例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();
}
 
开发者ID:stephenwilliams,项目名称:userscript-maven-plugin,代码行数:36,代码来源:UserscriptBuilder.java

示例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();
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:34,代码来源:ContentPathBuilderImpl.java

示例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();
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:33,代码来源:LoggingEntityInterceptor.java

示例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();
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:16,代码来源:LoggingEntityIndexingInterceptor.java

示例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();
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:28,代码来源:SdcctStringUtils.java

示例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();
}
 
开发者ID:esacinc,项目名称:crigtt,代码行数:9,代码来源:CrigttSqlUtils.java

示例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());
}
 
开发者ID:esacinc,项目名称:crigtt,代码行数:56,代码来源:CrigttSqlUtils.java


注:本文中的org.apache.commons.lang3.text.StrBuilder.build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。