/*
(non-Javadoc)

@see net.rubyeye.xmemcached.MemcachedClient#replace(java.lang.String, int, T,
net.rubyeye.xmemcached.transcoders.Transcoder, long)
197816
public final <T> boolean replace(String key, final int exp, final T value,
      final Transcoder<T> transcoder, final long timeout)
      throws TimeoutException, InterruptedException, MemcachedException {
    key = this.preProcessKey(key);
    byte[] keyBytes = this.checkStoreArguments(key, exp, value);
    return this.sendStoreCommand(
        this.commandFactory.createReplaceCommand(key, keyBytes, exp, value, false, transcoder),
        timeout);
  }
580488
def replace(self, key, val, time=0, min_compress_len=0):
        '''
        '''
        return self._set("replace", key, val, time, min_compress_len)
255827
public static String replace(final CharSequence target, final CharSequence replacement, final String string) {
    return Pattern.compile(quote(target.toString())/*
                                                    * , Pattern.LITERAL jdk 1.4
                                                    */).matcher(string).replaceAll(
    /* Matcher. jdk 1.4 */quoteReplacement(replacement.toString()));
  }
1064058
public static void replaceAll(StringBuffer haystack, String needle, String newNeedle, int interval) {
		if (needle == null) {
			throw new IllegalArgumentException("string to replace can not be empty");
		}
		int idx = haystack.indexOf(needle);
		int nextIdx = -1;
		int processedChunkSize = idx;
		int needleLength = needle.length();
		int newNeedleLength = newNeedle.length();
		while (idx != -1/* && idx < haystack.length()*/) {
			if (processedChunkSize >= interval) {
				haystack.replace(idx, idx + needleLength, newNeedle);
				nextIdx = haystack.indexOf(needle, idx + newNeedleLength);
				processedChunkSize = nextIdx - idx;//length of replacement is not included
				idx = nextIdx;
			}
			else {
				nextIdx = haystack.indexOf(needle, idx + newNeedleLength);
				processedChunkSize += nextIdx - idx;
				idx = nextIdx;
				if (newNeedleLength == 0) {
					return;
				}
			}
		}
	}
420300
public static void replaceAll(StringBuffer haystack, String needle, String newNeedle) {
/*		if(needle == null || "".equals(needle))
		{
			throw new IllegalArgumentException("string to replace may not be empty");
		}
		int idx = haystack.indexOf(needle);
		int needleLength = needle.length();
		int newNeedleLength = newNeedle.length();
		while (idx != -1)
		{
			haystack.replace(idx, idx + needleLength, newNeedle);
			idx = haystack.indexOf(needle, idx + newNeedleLength);
		}*/
		replaceAll(haystack, needle, newNeedle, 0);
	}
755391
@Override
    public V replace(K key, V value) {
        int hash = hash(key);
        if (value == null) {
          throw new NullPointerException();
        }
        Segment<K,V> s = segmentForHash(hash);
        return s == null ? null : s.replace(key, hash, value);
    }
1258351
public String replace(CharSequence text, ObsoleteReplacer replacer) throws IOException
    {
        if (text.length() == 0)
        {
            return "";
        }
        CharArrayWriter caw = new CharArrayWriter();
        InputReader reader = Input.getInstance(text);
        replace(reader, caw, replacer);
        return caw.toString();
    }
1370732
public static function strIreplace($search, $replace, $str, $count = null, $encoding = null)
    {
        $encoding = $encoding === null ? mb_internal_encoding() : $encoding;

        if (!is_array($search)) {
            $slen = strlen($search);

            if ($slen == 0) {
                return $str;
            }

            $lendif = strlen($replace) - strlen($search);
            $search = static::strtolower($search, $encoding);
            $search = preg_quote($search, '/');
            $lstr = static::strtolower($str, $encoding);
            $i = 0;
            $matched = 0;

            while (preg_match('/(.*)' . $search . '/Us', $lstr, $matches)) {
                if ($count !== null && $i === $count) {
                    break;
                }

                $mlen = strlen($matches[0]);
                $lstr = substr($lstr, $mlen);

                $str = substr_replace($str, $replace, $matched + strlen($matches[1]), $slen);
                $matched += $mlen + $lendif;
                $i++;
            }

            return $str;
        } else {
            $keys = array_keys($search);

            foreach ($keys as $k) {
                if (is_array($replace)) {
                    if (array_key_exists($k, $replace)) {
                        $str = static::strIreplace($search[$k], $replace[$k], $str, $count, $encoding);
                    } else {
                        $str = static::strIreplace($search[$k], '', $str, $count, $encoding);
                    }
                } else {
                    $str = static::strIreplace($search[$k], $replace, $str, $count, $encoding);
                }
            }

            return $str;
        }
    }
884773
@SuppressWarnings("unchecked")
  public final <T> T get(final String key, final long timeout)
      throws TimeoutException, InterruptedException, MemcachedException {
    return (T) this.get(key, timeout, this.transcoder);
  }
1173090
protected void replaceValue(Map<String, Object> content, String key, Object value) {
		if (content.containsKey(key) && value != null) {
			content.put(key, value);
		}
	}
1007875
public boolean replace(K key, V oldValue, V newValue) {
        if (oldValue == null || newValue == null) {
            throw new NullPointerException();
        }
        int hash = this.hashOf(key);
        return this.segmentFor(hash).replace(key, hash, oldValue, newValue);
    }
1034025
public static String replaceAllSpecialChracters(String toBeReplaced) {
	toBeReplaced = toBeReplaced.replaceAll("&", "&amp;");
	toBeReplaced = toBeReplaced.replaceAll("<", "&lt;");
	toBeReplaced = toBeReplaced.replaceAll(">", "&gt;");
	toBeReplaced = toBeReplaced.replaceAll("\"", "&quot;");
	toBeReplaced = toBeReplaced.replaceAll("'", "&apos;");
	// toBeReplaced = toBeReplaced.replace("^", "&circ");
	// toBeReplaced = toBeReplaced.replaceAll("0xb", "");
	int len = toBeReplaced.length();
	char[] temp = toBeReplaced.toCharArray();
	for (int i = 0; i < len; i++) {
	    char xCode = temp[i];
	    if ((xCode > '\u0000' && xCode <= '\u0020') || (xCode == '\u0026')
		    || (xCode == '\u0022') || (xCode == '\u02C6')
		    || (xCode == '\u201C') || (xCode == '\u201D')
		    || (xCode == '\u201E')) {
		String sub1 = toBeReplaced.substring(0, i);
		String sub2 = toBeReplaced.substring(i + 1, len);

		String replacement = "";
		if ((xCode > '\u0000' && xCode <= '\u0020'))
		    replacement = " ";
		if (xCode == '\u0026')
		    replacement = " ";
		if (xCode == '\u0022')
		    replacement = " ";
		if (xCode == '\u02C6')
		    replacement = " ";
		if (xCode == '\u201C')
		    replacement = " ";
		if (xCode == '\u201D')
		    replacement = " ";
		if (xCode == '\u201E')
		    replacement = " ";

		toBeReplaced = sub1 + replacement + sub2;
	    }
	    len = toBeReplaced.length();
	    temp = toBeReplaced.toCharArray();
	}

	return (toBeReplaced);
    }
848440
@Override
  public boolean replaceFailure(K key, V value, V newValue, StoreAccessException e) {
    cleanup(key, e);
    return false;
  }
548142
public String replace(CharSequence text, CharSequence replacement)
    {
        try
        {
            if (text.length() == 0)
            {
                if (acceptEmpty)
                {
                    return "";
                }
            }
            CharArrayWriter caw = new CharArrayWriter();
            InputReader reader = Input.getInstance(text);
            ObsoleteSimpleReplacer fsp = new ObsoleteSimpleReplacer(replacement);
            replace(reader, caw, fsp);
            return caw.toString();
        }
        catch (IOException ex)
        {
            throw new IllegalArgumentException("can't happen", ex);
        }
    }
426223
private static void replaceAll(StringBuffer s,
			final String o, final String n) {
		int olen = o.length();
		int nlen = n.length();
		int found = s.indexOf(o);
		while (found >= 0) {
			s.replace(found,found + olen,n);
			found = s.indexOf(o,found + nlen);
		}
	}
10210
@Deprecated @ReplacedBy(value="java.lang.String.replace()", reason="since 1.5")
    public static String replace (String source, String before, String after)
    {
        int pos = source.indexOf(before);
        if (pos == -1) {
            return source;
        }

        StringBuilder sb = new StringBuilder(source.length() + 32);

        int blength = before.length();
        int start = 0;
        while (pos != -1) {
            sb.append(source.substring(start, pos));
            sb.append(after);
            start = pos + blength;
            pos = source.indexOf(before, start);
        }
        sb.append(source.substring(start));

        return sb.toString();
    }
794245
public final <T> T get(final String key, final Transcoder<T> transcoder)
      throws TimeoutException, InterruptedException, MemcachedException {
    return this.get(key, this.opTimeout, transcoder);
  }