本文整理汇总了Java中org.codehaus.plexus.util.StringUtils.split方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.split方法的具体用法?Java StringUtils.split怎么用?Java StringUtils.split使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.StringUtils
的用法示例。
在下文中一共展示了StringUtils.split方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertStringToActionProperties
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
public static Map<String, String> convertStringToActionProperties(String text) {
PropertySplitter split = new PropertySplitter(text);
String tok = split.nextPair();
Map<String,String> props = new LinkedHashMap<String,String>();
while (tok != null) {
String[] prp = StringUtils.split(tok, "=", 2); //NOI18N
if (prp.length >= 1 ) {
String key = prp[0];
//in case the user adds -D by mistake, remove it to get a parsable xml file.
if (key.startsWith("-D")) { //NOI18N
key = key.substring("-D".length()); //NOI18N
}
if (key.startsWith("-")) { //NOI18N
key = key.substring(1);
}
if (key.endsWith("=")) {
key = key.substring(0, key.length() - 1);
}
if (key.trim().length() > 0 && Verifier.checkElementName(key.trim()) == null) {
props.put(key.trim(), prp.length > 1 ? prp[1] : "");
}
}
tok = split.nextPair();
}
return props;
}
示例2: find
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
public static @CheckForNull File[] find(@NonNull URL root, boolean javadoc) {
String k = root.toString();
Preferences n = node(javadoc);
String v = n.get(k, null);
if (v == null) {
return null;
}
String[] split = StringUtils.split(v, "||");
List<File> toRet = new ArrayList<File>();
for (String vv : split) {
File f = FileUtilities.convertStringToFile(vv);
if (f.isFile()) {
toRet.add(f);
} else {
//what do we do when one of the possibly more files is gone?
//in most cases we are dealing with exactly one file, so keep the
//previous behaviour of removing it.
n.remove(k);
}
}
return toRet.toArray(new File[0]);
}
示例3: instantiate
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
@Override
@Messages({"PRG_Dir=Creating directory", "PRG_FINISH=Finishing..."})
public Set<FileObject> instantiate (ProgressHandle handle) throws IOException {
handle.start();
try {
handle.progress(Bundle.PRG_Dir());
ProjectInfo vi = new ProjectInfo((String) wiz.getProperty("groupId"), (String) wiz.getProperty("artifactId"), (String) wiz.getProperty("version"), (String) wiz.getProperty("package")); //NOI18N
String[] splitlog = StringUtils.split(log, ":");
ArchetypeWizardUtils.logUsage(splitlog[0], splitlog[1], splitlog[2]);
File projFile = FileUtil.normalizeFile((File) wiz.getProperty(CommonProjectActions.PROJECT_PARENT_FOLDER)); // NOI18N
CreateProjectBuilder builder = createBuilder(projFile, vi, handle);
builder.create();
handle.progress(Bundle.PRG_FINISH());
return ArchetypeWizardUtils.openProjects(projFile, null);
} finally {
handle.finish();
}
}
示例4: getApplicableTokens
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
private List<Token> getApplicableTokens(Map<String, String> moduleProps, String string) {
String tokens = moduleProps.get(string);
if (tokens == null) {
return Arrays.asList(Token.values());
}
String[] split = StringUtils.split(tokens, ",");
List<Token> toRet = new ArrayList<Token>();
for (String val : split) {
try {
toRet.add(Token.valueOf(val.trim()));
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
return toRet;
}
示例5: consumeLine
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
public void consumeLine( String line )
{
if ( line.startsWith( START_PARSING_INDICATOR ) )
{
this.startParsing = true;
return;
}
if ( this.startParsing )
{
String[] tokens = StringUtils.split( line, "=" );
if ( tokens.length == 2 )
{
envs.put( tokens[0], tokens[1] );
}
}
else
{
System.out.println( line );
}
}
示例6: getDriverProperties
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
/**
* parse driverProperties into Properties set
*
* @return the driver properties
* @throws MojoExecutionException
*/
protected Properties getDriverProperties()
throws MojoExecutionException
{
Properties properties = new Properties();
if ( !StringUtils.isEmpty( this.driverProperties ) )
{
String[] tokens = StringUtils.split( this.driverProperties, "," );
for ( int i = 0; i < tokens.length; ++i )
{
String[] keyValueTokens = StringUtils.split( tokens[i].trim(), "=" );
if ( keyValueTokens.length != 2 )
{
throw new MojoExecutionException( "Invalid JDBC Driver properties: " + this.driverProperties );
}
properties.setProperty( keyValueTokens[0], keyValueTokens[1] );
}
}
return properties;
}
示例7: trimCommaSeparateString
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
private String trimCommaSeparateString( String in )
{
if ( in == null || in.trim().length() == 0 )
{
return "";
}
StringBuffer out = new StringBuffer();
String[] tokens = StringUtils.split( in, "," );
for ( int i = 0; i < tokens.length; ++i )
{
if ( i != 0 )
{
out.append( "," );
}
out.append( tokens[i].trim() );
}
return out.toString();
}
示例8: attachSecondaryArtifacts
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
private void attachSecondaryArtifacts()
{
final String[] tokens;
if(this.linkerSecondaryOutputExtensions != null) {
tokens = StringUtils.split( this.linkerSecondaryOutputExtensions, "," );
} else {
tokens = new String[0];
}
for ( int i = 0; i < tokens.length; ++i )
{
// TODO: shouldn't need classifier
Artifact artifact =
artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(),
this.classifier, tokens[i].trim() );
artifact.setFile( new File( this.linkerOutputDirectory + "/" + this.project.getBuild().getFinalName() + "."
+ tokens[i].trim() ) );
project.addAttachedArtifact( artifact );
}
}
示例9: constructTrouble
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
static Trouble constructTrouble(@NonNull String type, @NullAllowed String message, @NullAllowed String text, boolean error) {
Trouble t = new Trouble(error);
if (message != null) {
Matcher match = COMPARISON_PATTERN.matcher(message);
if (match.matches()) {
t.setComparisonFailure(new Trouble.ComparisonFailure(match.group(1), match.group(2)));
} else {
match = COMPARISON_PATTERN_AFTER_65.matcher(message);
if (match.matches()) {
t.setComparisonFailure(new Trouble.ComparisonFailure(match.group(1), match.group(2)));
}
}
}
if (text != null) {
String[] strs = StringUtils.split(text, "\n");
List<String> lines = new ArrayList<String>();
if (message != null) {
lines.add(message);
}
lines.add(type);
for (int i = 1; i < strs.length; i++) {
lines.add(strs[i]);
}
t.setStackTrace(lines.toArray(new String[0]));
}
return t;
}
示例10: getBootClasspath
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
private String[] getBootClasspath() {
String carg = PluginPropertyUtils.getPluginProperty(project, Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER, "compilerArgument", "compile", null);
if (carg != null) {
//TODO
}
Properties cargs = PluginPropertyUtils.getPluginPropertyParameter(project, Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER, "compilerArguments", "compile");
if (cargs != null) {
String carg2 = cargs.getProperty("bootclasspath");
if (carg2 != null) {
return StringUtils.split(carg2, File.pathSeparator);
}
}
return null;
}
示例11: getPackagingExcludes
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
/**
* @return The package excludes.
*/
public String[] getPackagingExcludes() {
if (StringUtils.isEmpty(packagingExcludes)) {
return new String[0];
} else {
return StringUtils.split(packagingExcludes, ",");
}
}
示例12: getPackagingIncludes
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
/**
* @return The packaging includes.
*/
public String[] getPackagingIncludes() {
if (StringUtils.isEmpty(packagingIncludes)) {
return new String[]{"**"};
} else {
return StringUtils.split(packagingIncludes, ",");
}
}
示例13: pathBaseVersionOf
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
/**
* get relative path the copied artifact using base version. This is mainly use to SNAPSHOT instead of timestamp in
* the file name
*
* @param artifactRepositoryLayout
* @param artifact
* @return
*/
public static String pathBaseVersionOf( ArtifactRepositoryLayout artifactRepositoryLayout, Artifact artifact )
{
ArtifactHandler artifactHandler = artifact.getArtifactHandler();
StringBuffer fileName = new StringBuffer();
fileName.append( artifact.getArtifactId() ).append( "-" ).append( artifact.getBaseVersion() );
if ( artifact.hasClassifier() )
{
fileName.append( "-" ).append( artifact.getClassifier() );
}
if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 )
{
fileName.append( "." ).append( artifactHandler.getExtension() );
}
String relativePath = artifactRepositoryLayout.pathOf( artifact );
String[] tokens = StringUtils.split( relativePath, "/" );
tokens[tokens.length - 1] = fileName.toString();
StringBuffer path = new StringBuffer();
for ( int i = 0; i < tokens.length; ++i )
{
path.append( tokens[i] );
if ( i != tokens.length - 1 )
{
path.append( "/" );
}
}
return path.toString();
}
示例14: RobotCommand
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
public RobotCommand(String voiceCommand){
String[] voiceCommandArray = StringUtils.split(voiceCommand, " ");
Command command;
int size = voiceCommandArray.length;
int i = 0;
while (size != i) {
try {
command = matchStringWithMovement(voiceCommandArray[i], voiceCommandArray[i + 1]);
if (command != Command.NoCommand) {
commands.add(command);
i++;
}
} catch (IndexOutOfBoundsException e) {
command = matchStringWithMovement(voiceCommandArray[i]);
if (command != Command.NoCommand) {
commands.add(command);
}
} finally {
i++;
}
}
// for (String word : voiceCommandArray) {
// command = matchStringWithMovement(word);
// if(command != Command.NoCommand){
// commands.add(command);
// }
// }
}
示例15: breakPaths
import org.codehaus.plexus.util.StringUtils; //导入方法依赖的package包/类
public static File[] breakPaths( String paths )
{
String[] tokens = StringUtils.split( paths, "," );
File[] files = new File[tokens.length];
for ( int i = 0; i < tokens.length; ++i )
{
files[i] = new File( tokens[i] );
}
return files;
}