Java Utililty Methods String Substitute

List of utility methods to do String Substitute

  1. HOME
  2. Java
  3. S
  4. String Substitute

Description

The list of methods to do String Substitute are organized into topic(s).

Method

String stringSubstitution(String argStr, Hashtable vars)
string Substitution
StringBuffer argBuf = new StringBuffer();
for (int cIdx = 0; cIdx < argStr.length();) {
 char ch = argStr.charAt(cIdx);
 switch (ch) {
 case '$':
 StringBuffer nameBuf = new StringBuffer();
 for (++cIdx; cIdx < argStr.length(); ++cIdx) {
 ch = argStr.charAt(cIdx);
...
String substitute(String original, String match, String subst)
Find all occurences of the "match" in original, and substitute the "subst" string.
String s = original;
int pos;
while (0 <= (pos = s.indexOf(match))) {
 StringBuffer sb = new StringBuffer(s);
 s = sb.replace(pos, pos + match.length(), subst).toString();
return s;
String substitute(String str, Hashtable vars, String delimiter)
Searches the line for any variables which should be substituted with values from the hashtable.
String key = null;
for (Enumeration keys = vars.keys(); keys.hasMoreElements();) {
 key = (String) keys.nextElement();
 if ((key != null) && (key.indexOf(delimiter) == -1)) {
 str = replaceVar(str, delimiter + key + delimiter, (String) vars.get(key));
return str;
...
String substituteProperty(String value, Properties coreProperties)
substitute Property
if (value == null || value.indexOf('$') == -1) {
 return value;
List<String> fragments = new ArrayList<String>();
List<String> propertyRefs = new ArrayList<String>();
parsePropertyString(value, fragments, propertyRefs);
StringBuilder sb = new StringBuilder();
Iterator<String> i = fragments.iterator();
...

AltStyle によって変換されたページ (->オリジナル) /