/** * @see #split(String, String, int) */ public static String[] split( String text, String separator ) { return split( text, separator, -1 ); }
/** * <p> * Splits the provided text into a array, using whitespace as the separator. * </p> * <p> * The separator is not included in the returned String array. * </p> * * @param str the String to parse * @return an array of parsed Strings */ public static String[] split( String str ) { return split( str, null, -1 ); }
private String[] splitGoalSpec(String fullGoal) throws MojoFailureException { String parts[] = StringUtils.split(fullGoal, ":"); if (parts.length != 3) { throw new MojoFailureException("Cannot parse " + fullGoal + " as a maven plugin goal. " + "It must be fully qualified as in <groupId>:<artifactId>:<goal>"); } return new String[]{parts[0] + ":" + parts[1], parts[2]}; }
private List<File> parseExtClasspath( CliRequest cliRequest ) { String extClassPath = cliRequest.userProperties.getProperty( EXT_CLASS_PATH ); if ( extClassPath == null ) { extClassPath = cliRequest.systemProperties.getProperty( EXT_CLASS_PATH ); } List<File> jars = new ArrayList<>(); if ( StringUtils.isNotEmpty( extClassPath ) ) { for ( String jar : StringUtils.split( extClassPath, File.pathSeparator ) ) { File file = resolveFile( new File( jar ), cliRequest.workingDirectory ); slf4jLogger.debug( " Included " + file ); jars.add( file ); } } return jars; }
public void set( String goals ) { mojos = new ArrayList<>(); if ( StringUtils.isNotEmpty( goals ) ) { String[] mojoGoals = StringUtils.split( goals, "," ); for ( String mojoGoal: mojoGoals ) { LifecycleMojo lifecycleMojo = new LifecycleMojo(); lifecycleMojo.setGoal( mojoGoal.trim() ); mojos.add( lifecycleMojo ); } } }
private GoalSpec parseGoalSpec( String goalSpec ) { GoalSpec gs = new GoalSpec(); String[] p = StringUtils.split( goalSpec.trim(), ":" ); if ( p.length == 3 ) { // <groupId>:<artifactId>:<goal> gs.groupId = p[0]; gs.artifactId = p[1]; gs.goal = p[2]; } else if ( p.length == 4 ) { // <groupId>:<artifactId>:<version>:<goal> gs.groupId = p[0]; gs.artifactId = p[1]; gs.version = p[2]; gs.goal = p[3]; } else { // invalid gs = null; } return gs; }
/** * <p> * Reverses a String that is delimited by a specific character. * </p> * <p> * The Strings between the delimiters are not reversed. Thus java.lang.String becomes String.lang.java (if the * delimiter is <code>'.'</code>). * </p> * * @param str the String to reverse * @param delimiter the delimiter to use * @return the reversed String */ public static String reverseDelimitedString( String str, String delimiter ) { // could implement manually, but simple way is to reuse other, // probably slower, methods. String[] strs = split( str, delimiter ); reverseArray( strs ); return join( strs, delimiter ); }
public List<TaskSegment> calculateTaskSegments( MavenSession session ) throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException, PluginVersionResolutionException, LifecyclePhaseNotFoundException, LifecycleNotFoundException { MavenProject rootProject = session.getTopLevelProject(); List<String> tasks = session.getGoals(); if ( ( tasks == null || tasks.isEmpty() ) && !StringUtils.isEmpty( rootProject.getDefaultGoal() ) ) { tasks = Arrays.asList( StringUtils.split( rootProject.getDefaultGoal() ) ); } return calculateTaskSegments( session, tasks ); }
private void addCopy(StringBuilder b) { if (assemblyUser != null) { String tmpDir = createTempDir(); addCopyEntries(b, tmpDir); String[] userParts = StringUtils.split(assemblyUser, ":"); String userArg = userParts.length > 1 ? userParts[0] + ":" + userParts[1] : userParts[0]; String chmod = "chown -R " + userArg + " " + tmpDir + " && cp -rp " + tmpDir + "/* / && rm -rf " + tmpDir; if (userParts.length > 2) { DockerFileKeyword.USER.addTo(b, "root"); DockerFileKeyword.RUN.addTo(b, chmod); DockerFileKeyword.USER.addTo(b, userParts[2]); } else { DockerFileKeyword.RUN.addTo(b, chmod); } } else { addCopyEntries(b, ""); } }
private static @Nonnull String getFileExtention( @Nonnull File file ) { String path = file.getAbsolutePath(); String archiveExt = FileUtils.getExtension( path ).toLowerCase( Locale.ENGLISH ); if ( "gz".equals( archiveExt ) || "bz2".equals( archiveExt ) || "xz".equals( archiveExt ) || "snappy".equals( archiveExt ) ) { String[] tokens = StringUtils.split( path, "." ); if ( tokens.length > 2 && "tar".equals( tokens[tokens.length - 2].toLowerCase( Locale.ENGLISH ) ) ) { archiveExt = "tar." + archiveExt; } } return archiveExt; }
String[] s = StringUtils.split( line, ":" );
private String[] split(String s) { if (s == null) { return new String[0]; } return StringUtils.split(s, ","); }
private String[] splitGoalSpec(String fullGoal) throws MojoFailureException { String parts[] = StringUtils.split(fullGoal, ":"); if (parts.length != 3) { throw new MojoFailureException("Cannot parse " + fullGoal + " as a maven plugin goal. " + "It must be fully qualified as in <groupId>:<artifactId>:<goal>"); } return new String[] { parts[0] + ":" + parts[1], parts[2]}; }
private List<String> getExecutablePaths( Map<String, String> enviro ) { List<String> paths = new ArrayList<String>(); paths.add( "" ); String path = enviro.get( "PATH" ); if ( path != null ) { paths.addAll( Arrays.asList( StringUtils.split( path, File.pathSeparator ) ) ); } return paths; }
public void setIncludes(String includes) { if (includes == null) { this.includes=null; } else { setIncludes(StringUtils.split(includes, ",")); } }
/** * mainly used to parse excludes,includes configuration * @param str The string to be split. * @return The result items. */ public static String[] tokenizer( String str ) { return StringUtils.split( cleanToBeTokenizedString( str ), "," ); }
private List<String> getSplittedProperties( String commaSeparatedProperties ) { List<String> propertiesList = Collections.emptyList(); if ( StringUtils.isNotEmpty( commaSeparatedProperties ) ) { String[] splittedProps = StringUtils.split( commaSeparatedProperties, "," ); propertiesList = Arrays.asList( StringUtils.stripAll( splittedProps ) ); } return propertiesList; }
private void handleWindowsDomainUser( Properties driverProperties ) { if ( "net.sourceforge.jtds.jdbc.Driver".equals( config.getDriver() ) ) { String[] tokens = StringUtils.split( config.getUsername(), "\\" ); if ( tokens != null && tokens.length == 2 ) { driverProperties.put( "user", tokens[1] ); driverProperties.put( "domain", tokens[0] ); } } }