本文整理汇总了Java中org.apache.commons.lang3.text.StrMatcher类的典型用法代码示例。如果您正苦于以下问题:Java StrMatcher类的具体用法?Java StrMatcher怎么用?Java StrMatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StrMatcher类属于org.apache.commons.lang3.text包,在下文中一共展示了StrMatcher类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: tokenize
import org.apache.commons.lang3.text.StrMatcher; //导入依赖的package包/类
/** Split string x in tokens. Effectively just a friendly wrapper around StrTokenizer.
* Use *single* quotes for avoiding splitting.
*/
public static ArrayList<String> tokenize(String x, String delimiterString){
if(x == null){
return null;
}
// This is a hack to allow empty tokens to be passed at the command line.
// An empty
x= x.replace("''", "' '");
// See also http://stackoverflow.com/questions/38161437/inconsistent-behaviour-of-strtokenizer-to-split-string
StrTokenizer str= new StrTokenizer(x);
str.setTrimmerMatcher(StrMatcher.spaceMatcher());
str.setDelimiterString(delimiterString);
str.setQuoteChar('\'');
// str.setIgnoreEmptyTokens(false);
ArrayList<String> tokens= (ArrayList<String>) str.getTokenList();
for(int i= 0; i < tokens.size(); i++){
String tok= tokens.get(i).trim();
tokens.set(i, tok);
}
return tokens;
}
开发者ID:dariober,项目名称:ASCIIGenome,代码行数:28,代码来源:Utils.java
示例2: _tokenizeString
import org.apache.commons.lang3.text.StrMatcher; //导入依赖的package包/类
static String[] _tokenizeString(String string) {
final StrTokenizer _tokenizer = new StrTokenizer().
setDelimiterMatcher(StrMatcher.trimMatcher()).
setQuoteMatcher(StrMatcher.quoteMatcher()).
setTrimmerMatcher(StrMatcher.trimMatcher()).
setIgnoredMatcher(StrMatcher.quoteMatcher());
_tokenizer.reset(string.toLowerCase());
return _tokenizer.getTokenArray();
}
开发者ID:wardle,项目名称:rsterminology,代码行数:10,代码来源:ParsedMedicationBuilder.java
示例3: getFirstMatch
import org.apache.commons.lang3.text.StrMatcher; //导入依赖的package包/类
public String getFirstMatch(StrMatcher strMatcher) {
int length = strMatcher.isMatch(buffer, currentPos);
if (length > 0) {
String result = substring(currentPos, currentPos + length);
currentPos += length;
return result;
}
return null;
}
开发者ID:Web-of-Building-Data,项目名称:Ifc2Rdf,代码行数:11,代码来源:StrBuilderWrapper.java
示例4: newStrSubstitutor
import org.apache.commons.lang3.text.StrMatcher; //导入依赖的package包/类
public static <V> StrSubstitutor newStrSubstitutor(String start, String end, char escape, final Map<String, V> valueMap){
StrSubstitutor substitutor = new StrSubstitutor(StrLookup.mapLookup(valueMap), StrMatcher.stringMatcher(start), StrMatcher.stringMatcher(end), escape);
return substitutor;
}
开发者ID:wayshall,项目名称:onetwo,代码行数:5,代码来源:ExpressionFacotry.java
示例5: getSeparator
import org.apache.commons.lang3.text.StrMatcher; //导入依赖的package包/类
public StrMatcher getSeparator() {
return separator;
}
开发者ID:softwareloop,项目名称:tstconfig,代码行数:4,代码来源:Config.java
示例6: setSeparator
import org.apache.commons.lang3.text.StrMatcher; //导入依赖的package包/类
public void setSeparator(StrMatcher separator) {
this.separator = separator;
}
开发者ID:softwareloop,项目名称:tstconfig,代码行数:4,代码来源:Config.java
示例7: processFile
import org.apache.commons.lang3.text.StrMatcher; //导入依赖的package包/类
/**
* Processes the specified CSV file. For every line but the header line (which is required), the
* specified command is executed.
*
* @param reader
* the reader for loading the CSV data
* @param delimiter
* the column separator
* @param quoteChar
* the quote character ('\0' for no quoting)
* @param command
* the command (i. e. a Groovy closure if used in a Groovy script) to be executed for
* every processed line
*/
public void processFile(final Reader reader, final String delimiter, final char quoteChar, final Runnable command) {
try {
List<String> inputLines = CharStreams.readLines(reader);
StrTokenizer st = StrTokenizer.getCSVInstance();
st.setDelimiterString(delimiter);
if (quoteChar != '\0') {
st.setQuoteChar(quoteChar);
} else {
st.setQuoteMatcher(StrMatcher.noneMatcher());
}
// extract header
String headerLine = inputLines.remove(0);
List<Column> columns = initColumns(st, headerLine);
for (String line : inputLines) {
st.reset(line);
String[] colArray = st.getTokenArray();
int len = colArray.length;
checkState(len == columns.size(), "Mismatch between number of header columns and number of line columns.");
DataSource dataSource = dataSourceProvider.get();
Configuration config = configProvider.get();
for (int i = 0; i < len; ++i) {
String value = StringUtils.trimToEmpty(colArray[i]);
String dataSetKey = columns.get(i).dataSetKey;
String key = columns.get(i).key;
if (dataSetKey != null) {
if ("<auto>".equals(value)) {
dataSource.resetFixedValue(dataSetKey, key);
} else {
log.debug("Setting data set entry for " + this + " to value=" + value);
dataSource.setFixedValue(dataSetKey, key, value);
}
} else {
log.debug("Setting property for " + this + " to value=" + value);
config.put(key, value);
}
}
command.run();
}
} catch (IOException ex) {
throw new JFunkException("Error processing CSV data", ex);
}
}
开发者ID:mgm-tp,项目名称:jfunk,代码行数:62,代码来源:CsvDataProcessor.java
注:本文中的org.apache.commons.lang3.text.StrMatcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论