/** * Wrapper of {@link String#replaceFirst(String, String)} but return FastStr inance * * @param regex the regular expression specifies the place to be replaced * @param replacement the string to replace the found part * @return a FastStr that has the first found part replaced */ @Override public FastStr replaceFirst(String regex, String replacement) { return unsafeOf(Pattern.compile(regex).matcher(this).replaceFirst(replacement)); }
/** * Wrapper of {@link String#replaceAll(String, String)} but return FastStr type instance * * @param regex the regular expression specifies the pattern to be replaced * @param replacement the replacement string * @return a FastStr instance with all found part replaced */ @Override public FastStr replaceAll(String regex, String replacement) { return unsafeOf(Pattern.compile(regex).matcher(this).replaceAll(replacement)); }
/** * Wrapper of {@link String#replaceAll(String, String)} but return FastStr type instance * * @param regex the regular expression specifies the pattern to be replaced * @param replacement the replacement string * @return a FastStr instance with all found part replaced */ @Override public FastStr replaceAll(String regex, String replacement) { return unsafeOf(Pattern.compile(regex).matcher(this).replaceAll(replacement)); }
/** * Wrapper of {@link String#toLowerCase(java.util.Locale)} but return FastStr type instance * * @param locale the locale * @return a FastStr instance with all characters from this FastStr * be converted into lowercase based on the locale specified */ public FastStr toLowerCase(Locale locale) { String s = toString(); return unsafeOf(s.toLowerCase(locale)); }
/** * Wrapper of {@link String#toUpperCase(java.util.Locale)} but return FastStr type instance * * @param locale the locale * @return a FastStr instance with all characters from this FastStr * be converted into uppercase based on the locale specified */ @Override public FastStr toUpperCase(Locale locale) { String s = toString(); return unsafeOf(s.toUpperCase(locale)); }
/** * Wrapper of {@link String#toUpperCase(java.util.Locale)} but return FastStr type instance * * @param locale the locale * @return a FastStr instance with all characters from this FastStr * be converted into uppercase based on the locale specified */ @Override public FastStr toUpperCase(Locale locale) { String s = toString(); return unsafeOf(s.toUpperCase(locale)); }
@Override public FastStr copy() { if (EMPTY_STR == this) return this; return unsafeOf(charArray(), 0, size()); }
public FastStr canonical() { if (EMPTY_STR == this) return this; if (begin == 0) return this; return unsafeOf(unsafeChars(), 0, size()); }
@Override public FastStr copy() { if (EMPTY_STR == this) return this; return unsafeOf(charArray(), 0, size()); }
public FastStr canonical() { if (EMPTY_STR == this) return this; if (begin == 0) return this; return unsafeOf(unsafeChars(), 0, size()); }
public static H.Format contentType(String path) { H.Format retVal = null; if (path.contains(".")) { FastStr s = FastStr.unsafeOf(path).afterLast('.'); retVal = H.Format.of(s.toString()); } return null == retVal ? H.Format.BINARY : retVal; }
public static H.Format contentType(String path) { H.Format retVal = null; if (path.contains(".")) { FastStr s = FastStr.unsafeOf(path).afterLast('.'); retVal = H.Format.of(s.toString()); } return null == retVal ? H.Format.BINARY : retVal; }
@Override public FastStr capFirst() { if (isEmpty()) return this; int sz = size(); char[] buf = this.buf; char[] newBuf = S.unsafeCapFirst(buf, begin, sz); if (buf == newBuf) return this; return unsafeOf(newBuf, 0, sz); }
public FastStr urlEncode() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.urlEncode(s)); }
public FastStr decodeBASE64() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.decodeBASE64(s)); }
public FastStr urlEncode() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.urlEncode(s)); }
public FastStr encodeBASE64() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.encodeBASE64(s)); }
public FastStr decodeBASE64() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.decodeBASE64(s)); }
public FastStr encodeBASE64() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.encodeBASE64(s)); }
@Override public FastStr dropWhile($.Function<? super Character, Boolean> predicate) { int sz = size(); if (sz == 0) return EMPTY_STR; int b = -1, e = toInternalId(sz); for (int i = 0; i < sz; ++i) { char c = charAt(i); b = toInternalId(i); if (!predicate.apply(c)) break; } return unsafeOf(buf, b, e); }