本文整理了Java中net.roboconf.core.utils.Utils.splitNicely()
方法的一些代码示例,展示了Utils.splitNicely()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.splitNicely()
方法的具体详情如下:
包路径:net.roboconf.core.utils.Utils
类名称:Utils
方法名:splitNicely
[英]Splits a string and formats the result.
[中]拆分字符串并格式化结果。
代码示例来源:origin: roboconf/roboconf-platform
/**
* Constructor.
* @param context
* @param instruction
* @param line
*/
EmailCommandInstruction( Context context, String instruction, int line ) {
super( context, instruction, line );
Pattern p = Pattern.compile( PREFIX + "\\s+(.*)\\s*with\\s+(.*)", Pattern.CASE_INSENSITIVE );
Matcher m = p.matcher( instruction );
if( m.matches()) {
this.syntaxicallyCorrect = true;
this.tos.addAll( Utils.splitNicely( m.group( 1 ), "," ));
this.msg = m.group( 2 ).trim().replace( "\\n", "\n" );
}
}
代码示例来源:origin: roboconf/roboconf-platform
/**
* Gets and splits property values separated by a comma.
* @param holder a property holder (not null)
* @return a non-null list of non-null values
*/
public static List<String> getPropertyValues( AbstractBlockHolder holder, String propertyName ) {
List<String> result = new ArrayList<> ();
for( BlockProperty p : holder.findPropertiesBlockByName( propertyName )) {
result.addAll( Utils.splitNicely( p.getValue(), ParsingConstants.PROPERTY_SEPARATOR ));
}
return result;
}
代码示例来源:origin: net.roboconf/roboconf-dm
private Set<String> getPreferencesAsCollection( String key ) {
String listAsString = get( key, "" );
List<String> list = Utils.filterEmptyValues( Utils.splitNicely( listAsString, "," ));
return new LinkedHashSet<>( list );
}
}
代码示例来源:origin: roboconf/roboconf-platform
/**
* Gets and splits data separated by a comma.
* @param holder a property holder (not null)
* @return a non-null map (key = data name, value = data value, which can be null)
*/
public static Map<String,String> getData( AbstractBlockHolder holder ) {
BlockProperty p = holder.findPropertyBlockByName( ParsingConstants.PROPERTY_INSTANCE_DATA );
Map<String,String> result = new HashMap<> ();
String propertyValue = p == null ? null : p.getValue();
for( String s : Utils.splitNicely( propertyValue, ParsingConstants.PROPERTY_SEPARATOR )) {
Map.Entry<String,String> entry = VariableHelpers.parseExportedVariable( s );
result.put( entry.getKey(), entry.getValue());
}
return result;
}
代码示例来源:origin: net.roboconf/roboconf-dm
/**
* Loads the application bindings into an application.
* @param app a non-null application
* @param configurationDirectory the DM's configuration directory
*/
public static void loadApplicationBindings( Application app ) {
File descDir = new File( app.getDirectory(), Constants.PROJECT_DIR_DESC );
File appBindingsFile = new File( descDir, APP_BINDINGS_FILE );
Logger logger = Logger.getLogger( ConfigurationUtils.class.getName());
Properties props = Utils.readPropertiesFileQuietly( appBindingsFile, logger );
for( Map.Entry<?,?> entry : props.entrySet()) {
for( String part : Utils.splitNicely((String) entry.getValue(), "," )) {
if( ! Utils.isEmptyOrWhitespaces( part ))
app.bindWithApplication((String) entry.getKey(), part );
}
}
}
代码示例来源:origin: roboconf/roboconf-platform
for( String rawExport : Utils.splitNicely( rawExports, "," )) {
Matcher m = pattern.matcher( rawExport );
if( m.matches())
result.tags.addAll( Utils.splitNicely( rawTags, "," ));
代码示例来源:origin: net.roboconf/roboconf-dm
for( String s : Utils.splitNicely( preferences, "," )) {
if( Utils.isEmptyOrWhitespaces( s ))
continue;
代码示例来源:origin: roboconf/roboconf-platform
@Test( expected = IllegalArgumentException.class )
public void testSplitNicely_illegalArgument_2() {
Utils.splitNicely( "once, upon, a , time ", null );
}
代码示例来源:origin: roboconf/roboconf-platform
@Test( expected = IllegalArgumentException.class )
public void testSplitNicely_illegalArgument_1() {
Utils.splitNicely( "once, upon, a , time ", "" );
}
代码示例来源:origin: net.roboconf/roboconf-dm
List<String> recipients = Utils.splitNicely( defaultRecipients, "," );
tos.addAll( recipients );
代码示例来源:origin: roboconf/roboconf-platform
for( String string : Utils.splitNicely( instructionsText, "\n" ) ) {
代码示例来源:origin: roboconf/roboconf-platform
for( String s : Utils.splitNicely( value, ParsingConstants.PROPERTY_SEPARATOR )) {
if( s.matches( ParsingConstants.PATTERN_ID ))
continue;
|| ParsingConstants.PROPERTY_GRAPH_EXTENDS.equals( name )) {
for( String s : Utils.splitNicely( value, ParsingConstants.PROPERTY_SEPARATOR )) {
if( Utils.isEmptyOrWhitespaces( s )) {
result.add( new ParsingError( ErrorCode.PM_EMPTY_REFERENCED_NAME, block.getFile(), line ));
for( String s : Utils.splitNicely( value, ParsingConstants.PROPERTY_SEPARATOR )) {
代码示例来源:origin: roboconf/roboconf-platform
@Test
public void testSplitNicely() {
List<String> result = Utils.splitNicely( "once, upon, a , time ", "," );
Assert.assertEquals( 4, result.size());
Assert.assertEquals( "once", result.get( 0 ));
Assert.assertEquals( "upon", result.get( 1 ));
Assert.assertEquals( "a", result.get( 2 ));
Assert.assertEquals( "time", result.get( 3 ));
result = Utils.splitNicely( "once \n\n, upon, a , time \n ", "\n" );
Assert.assertEquals( 4, result.size());
Assert.assertEquals( "once", result.get( 0 ));
Assert.assertEquals( "", result.get( 1 ).trim());
Assert.assertEquals( ", upon, a , time", result.get( 2 ));
Assert.assertEquals( "", result.get( 3 ).trim());
result = Utils.splitNicely( "once $ $a$ $$ time", "$" );
Assert.assertEquals( 6, result.size());
Assert.assertEquals( "once", result.get( 0 ));
Assert.assertEquals( "", result.get( 1 ).trim());
Assert.assertEquals( "a", result.get( 2 ));
Assert.assertEquals( "", result.get( 3 ).trim());
Assert.assertEquals( "", result.get( 4 ).trim());
Assert.assertEquals( "time", result.get( 5 ));
}
内容来源于网络,如有侵权,请联系作者删除!