Example usage for org.apache.commons.text StringTokenizer setQuoteMatcher

List of usage examples for org.apache.commons.text StringTokenizer setQuoteMatcher

Introduction

In this page you can find the example usage for org.apache.commons.text StringTokenizer setQuoteMatcher.

Prototype

public StringTokenizer setQuoteMatcher(final StringMatcher quote) 

Source Link

Document

Set the quote matcher to use.

Usage

From source file:com.blackducksoftware.integration.hub.detect.detector.clang.ClangCompileCommandParser.java

public List<String> getCompilerArgsForGeneratingDepsMkFile(final String origCompileCommand,
        final String depsMkFilePath, final Map<String, String> optionOverrides) {
    logger.trace(String.format("origCompileCommand         : %s", origCompileCommand));
    String quotesRemovedCompileCommand = escapeQuotedWhitespace(origCompileCommand.trim());
    logger.trace(String.format("quotesRemovedCompileCommand: %s", quotesRemovedCompileCommand));
    StringTokenizer tokenizer = new StringTokenizer(quotesRemovedCompileCommand);
    tokenizer.setQuoteMatcher(StringMatcherFactory.INSTANCE.quoteMatcher());
    final List<String> argList = new ArrayList<>();
    String lastPart = "";
    int partIndex = 0;
    while (tokenizer.hasNext()) {
        String part = unEscapeDoubleQuotes(restoreWhitespace(tokenizer.nextToken()));
        if (partIndex > 0) {
            String optionValueOverride = null;
            for (String optionToOverride : optionOverrides.keySet()) {
                if (optionToOverride.equals(lastPart)) {
                    optionValueOverride = optionOverrides.get(optionToOverride);
                }//from w  w  w.j a  va2 s.  c o  m
            }
            if (optionValueOverride != null) {
                argList.add(optionValueOverride);
            } else {
                argList.add(part);
            }
        }
        lastPart = part;
        partIndex++;
    }
    argList.add("-M");
    argList.add("-MF");
    argList.add(depsMkFilePath);
    return argList;
}