當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtils.chomp方法代碼示例

本文整理匯總了Java中org.apache.commons.lang3.StringUtils.chomp方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtils.chomp方法的具體用法?Java StringUtils.chomp怎麽用?Java StringUtils.chomp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang3.StringUtils的用法示例。


在下文中一共展示了StringUtils.chomp方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: protocolCommandSent

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public void protocolCommandSent(final ProtocolCommandEvent event) {
    final String message = StringUtils.chomp(event.getMessage());
    if(message.startsWith(FTPCmd.PASS.name())) {
        this.log(Type.request, String.format("%s %s", FTPCmd.PASS.name(),
                StringUtils.repeat("*", StringUtils.length(StringUtils.removeStart(message, FTPCmd.PASS.name())))));
    }
    else {
        this.log(Type.request, message);
    }
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:12,代碼來源:LoggingProtocolCommandListener.java

示例2: getModificationTime

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
@Override
public String getModificationTime(final String file) throws IOException {
    final String status = super.getModificationTime(file);
    if(null == status) {
        throw new FTPException(this.getReplyCode(), this.getReplyString());
    }
    return StringUtils.chomp(status.substring(3).trim());
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:9,代碼來源:FTPClient.java

示例3: splitIntoMainSections

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private MutableList<Pair<String, String>> splitIntoMainSections(String text, ImmutableList<String> elementsToCheck, String elementPrefix) {
    MutableList<Pair<String, String>> outerSections = Lists.mutable.empty();
    String nextSectionName = null;
    boolean startOfSearch = true;

    // here, we go in a loop searching for the next referenc of "[elementPrefix] [sectionName]", e.g. //// CHANGE
    // By each of those points, we split those into separate text sections and return back to the client.
    // We aim to preserve the line breaks found when parsing the sections
    while (text != null) {
        String currentSectionName = nextSectionName;
        String currentSectionText;

        int earliestIndex = Integer.MAX_VALUE;

        for (String firstLevelElement : elementsToCheck) {
            // on the first search, the text may start w/ the section; hence, we set the search fromIndex param to 0.
            // Subsequently, the index picks up at the beginning of the next section; hence, we must start
            // the search at the next character, so the fromIndex param is 1
            int index = text.indexOf(elementPrefix + " " + firstLevelElement, startOfSearch ? 0 : 1);

            if (index != -1 && index < earliestIndex) {
                earliestIndex = index;
                nextSectionName = firstLevelElement;
            }
        }

        startOfSearch = false;

        if (earliestIndex == Integer.MAX_VALUE) {
            currentSectionText = StringUtils.chomp(text);
            text = null;
        } else {
            currentSectionText = StringUtils.chomp(text.substring(0, earliestIndex));
            text = text.substring(earliestIndex);
        }

        outerSections.add(Tuples.pair(currentSectionName, currentSectionText));
    }
    return outerSections;
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:41,代碼來源:TextMarkupDocumentReader.java

示例4: parseString

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類
private ImmutableList<TextMarkupDocumentSection> parseString(String text, MutableList<String> elementsToCheck, boolean recurse,
        String elementPrefix) {
    MutableList<TextMarkupDocumentSection> sections = Lists.mutable.empty();
    while (true) {
        int earliestIndex = Integer.MAX_VALUE;

        for (String firstLevelElement : elementsToCheck) {
            int index = text.indexOf(elementPrefix + " " + firstLevelElement, 1);
            if (index != -1 && index < earliestIndex) {
                earliestIndex = index;
            }
        }

        if (earliestIndex == Integer.MAX_VALUE) {
            sections.add(new TextMarkupDocumentSection(null, text));
            break;
        } else {
            sections.add(new TextMarkupDocumentSection(null, text.substring(0, earliestIndex)));
            text = text.substring(earliestIndex);
        }
    }
    for (TextMarkupDocumentSection section : sections) {
        MutableMap<String, String> attrs = Maps.mutable.empty();
        MutableSet<String> toggles = Sets.mutable.empty();
        String content = StringUtils.chomp(section.getContent());

        String[] contents = content.split("\\r?\\n", 2);
        String firstLine = contents[0];

        for (String elementToCheck : elementsToCheck) {
            if (firstLine.startsWith(elementPrefix + " " + elementToCheck)) {
                section.setName(elementToCheck);
                String[] args = StringUtils.splitByWholeSeparator(firstLine, " ");
                for (String arg : args) {
                    if (arg.contains("=")) {
                        String[] attr = arg.split("=");
                        if (attr.length > 2) {
                            throw new IllegalArgumentException("Cannot mark = multiple times in a parameter - "
                                    + firstLine);
                        }
                        String attrVal = attr[1];
                        if (attrVal.startsWith("\"") && attrVal.endsWith("\"")) {
                            attrVal = attrVal.substring(1, attrVal.length() - 1);
                        }
                        attrs.put(attr[0], attrVal);
                    } else {
                        toggles.add(arg);
                    }
                }
                if (contents.length > 1) {
                    content = contents[1];
                } else {
                    content = null;
                }
            }
        }
        section.setAttrs(attrs.toImmutable());
        section.setToggles(toggles.toImmutable());

        if (!recurse) {
            section.setContent(content);
        } else if (content != null) {
            ImmutableList<TextMarkupDocumentSection> subsections = this.parseString(content, this.secondLevelElements, false, "//");
            if (subsections.size() == 1) {
                section.setContent(content);
            } else {
                section.setContent(subsections.get(0).getContent());
                section.setSubsections(subsections.subList(1, subsections.size()));
            }
        } else {
            section.setContent(null);
        }
    }

    return sections.toImmutable();
}
 
開發者ID:goldmansachs,項目名稱:obevo,代碼行數:77,代碼來源:TextMarkupDocumentReaderOld.java


注:本文中的org.apache.commons.lang3.StringUtils.chomp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。