1873 |
|
|
1874 |
return value; |
return value; |
1875 |
} |
} |
1876 |
|
|
1877 |
|
/** |
1878 |
|
* Returns true iff this String contains the sequence of Characters |
1879 |
|
* described in s. |
1880 |
|
* @param s the CharSequence |
1881 |
|
* @return true iff this String contains s |
1882 |
|
*/ |
1883 |
|
public boolean contains (CharSequence s) |
1884 |
|
{ |
1885 |
|
return this.indexOf(s.toString()) != -1; |
1886 |
|
} |
1887 |
|
|
1888 |
|
/** |
1889 |
|
* Returns a string that is this string with all instances of the sequence |
1890 |
|
* represented by <code>target</code> replaced by the sequence in |
1891 |
|
* <code>replacement</code>. |
1892 |
|
* @param target the sequence to be replaced |
1893 |
|
* @param replacement the sequence used as the replacement |
1894 |
|
* @return the string constructed as above |
1895 |
|
*/ |
1896 |
|
public String replace (CharSequence target, CharSequence replacement) |
1897 |
|
{ |
1898 |
|
String result = this; |
1899 |
|
int pos = result.indexOf(target.toString()); |
1900 |
|
while (pos != -1) |
1901 |
|
{ |
1902 |
|
result = result.substring(0, pos) + replacement.toString() |
1903 |
|
+ result.substring(pos + target.length(), result.length()); |
1904 |
|
pos = result.indexOf(target.toString()); |
1905 |
|
} |
1906 |
|
return result; |
1907 |
|
} |
1908 |
} |
} |