/** * <p> * Replace a String with another String inside a larger String, once. * </p> * <p> * A <code>null</code> reference passed to this method is a no-op. * </p> * * @see #replace(String text, String repl, String with, int max) * @param text text to search and replace in * @param repl String to search for * @param with String to replace with * @return the text with any replacements processed */ public static String replaceOnce( String text, String repl, String with ) { return replace( text, repl, with, 1 ); }
/** * <p> * Replace all occurrences of a String within another String. * </p> * <p> * A <code>null</code> reference passed to this method is a no-op. * </p> * * @see #replace(String text, String repl, String with, int max) * @param text text to search and replace in * @param repl String to search for * @param with String to replace with * @return the text with any replacements processed */ public static String replace( String text, String repl, String with ) { return replace( text, repl, with, -1 ); }
/** * <p> * Replace a char with another char inside a larger String, once. * </p> * <p> * A <code>null</code> reference passed to this method is a no-op. * </p> * * @see #replace(String text, char repl, char with, int max) * @param text text to search and replace in * @param repl char to search for * @param with char to replace with * @return the text with any replacements processed */ public static String replaceOnce( String text, char repl, char with ) { return replace( text, repl, with, 1 ); }
/** * <p> * Replace all occurrences of a char within another char. * </p> * <p> * A <code>null</code> reference passed to this method is a no-op. * </p> * * @see #replace(String text, char repl, char with, int max) * @param text text to search and replace in * @param repl char to search for * @param with char to replace with * @return the text with any replacements processed */ public static String replace( String text, char repl, char with ) { return replace( text, repl, with, -1 ); }
/** * <p> * Replace a char with another char inside a larger String, for the first <code>max</code> values of the search * char. * </p> * <p> * A <code>null</code> reference passed to this method is a no-op. * </p> * * @param text text to search and replace in * @param repl char to search for * @param with char to replace with * @param max maximum number of values to replace, or <code>-1</code> if no maximum * @return the text with any replacements processed */ public static String replace( String text, char repl, char with, int max ) { return replace( text, String.valueOf( repl ), String.valueOf( with ), max ); }
/** * Normalizes the pattern, e.g. converts forward and backward slashes to the platform-specific file separator. * * @param pattern The pattern to normalize, must not be <code>null</code>. * @return The normalized pattern, never <code>null</code>. */ private String normalizePattern( String pattern ) { pattern = pattern.trim(); if ( pattern.startsWith( SelectorUtils.REGEX_HANDLER_PREFIX ) ) { if ( File.separatorChar == '\\' ) { pattern = StringUtils.replace( pattern, "/", "\\\\" ); } else { pattern = StringUtils.replace( pattern, "\\\\", "/" ); } } else { pattern = pattern.replace( File.separatorChar == '/' ? '\\' : '/', File.separatorChar ); if ( pattern.endsWith( File.separator ) ) { pattern += "**"; } } return pattern; }
public static String interpolate( String text, Map<?, ?> namespace ) { Iterator<?> keys = namespace.keySet().iterator(); while ( keys.hasNext() ) { String key = keys.next().toString(); Object obj = namespace.get( key ); if ( obj == null ) { throw new NullPointerException( "The value of the key '" + key + "' is null." ); } String value = obj.toString(); text = replace( text, "${" + key + "}", value ); if ( !key.contains( " " ) ) { text = replace( text, "$" + key, value ); } } return text; }
protected String constructVersion( Versioning versioning, String baseVersion ) { String version = null; Snapshot snapshot = versioning.getSnapshot(); if ( snapshot != null ) { if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 ) { String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber(); version = StringUtils.replace( baseVersion, Artifact.SNAPSHOT_VERSION, newVersion ); } else { version = baseVersion; } } return version; }
String fileName = ae.getName(); PlexusIoResource resource = ae.getResource(); String name = StringUtils.replace(fileName, File.separatorChar, '/');
String name = StringUtils.replace( fileName, File.separatorChar, '/' );
private String getFormattedDate( long timestamp ) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis( timestamp ); Date date = cal.getTime(); String res = new SimpleDateFormat( "MMM dd, yyyy hh:mm:ss aaa z" ).format( date ); return StringUtils.replace( res, " ", " " ); }
public static Resource getResource( String resourceName ) { String r = StringUtils.replace( resourceName, "\\", "/" ); return new Resource( r ); }
@Override public void setPrefix( String prefix ) { char nonSeparator = File.separatorChar == '/' ? '\\' : '/'; super.setPrefix( StringUtils.replace( prefix, nonSeparator, File.separatorChar ) ); }
public VssScmProviderRepository( String user, String password, String vssdir, String project ) { super(); setUser( user ); setPassword( password ); this.vssdir = StringUtils.replace( vssdir, "/", "\\" ); // this.project = StringUtils.replace( project, "/", "\\" ); this.project = project; }
/** {@inheritDoc} */ @Override public void author_() { if ( getTextBuffer().length() > 0 ) { String text = HtmlTools.escapeHTML( getTextBuffer().toString() ); text = StringUtils.replace( text, "&#", "&#" ); authors.add( text.trim() ); } resetTextBuffer(); }
private String getDefaultValue( ModelDefault modelDefault ) { String value = modelDefault.getValue(); if ( isGenericType() ) { value = StringUtils.replace( value, "<?>", "/*<" + getTo() + ">*/" ); } return value; } }
public static String generateKPITestMethod(KPI kpi) { String kpiCode = kpi.getCode(); String kpiArray = generateKPIValuesArray(kpi); String methodStr = StringUtils.replace(TEST_KPI_METHOD_TEMPLATE, "{kpiCode}", kpiCode); methodStr = StringUtils.replace(methodStr, "{kpiValues}", kpiArray); return methodStr; }