本文整理了Java中com.google.common.base.Strings.validSurrogatePairAt()
方法的一些代码示例,展示了Strings.validSurrogatePairAt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Strings.validSurrogatePairAt()
方法的具体详情如下:
包路径:com.google.common.base.Strings
类名称:Strings
方法名:validSurrogatePairAt
[英]True when a valid surrogate pair starts at the given index in the given string. Out-of-range indexes return false.
[中]当有效代理项对从给定字符串中的给定索引开始时为True。超出范围的索引返回false。
代码示例来源:origin: google/guava
/**
* Returns the longest string {@code prefix} such that {@code a.toString().startsWith(prefix) &&
* b.toString().startsWith(prefix)}, taking care not to split surrogate pairs. If {@code a} and
* {@code b} have no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: google/guava
/**
* Returns the longest string {@code suffix} such that {@code a.toString().endsWith(suffix) &&
* b.toString().endsWith(suffix)}, taking care not to split surrogate pairs. If {@code a} and
* {@code b} have no common suffix, returns the empty string.
*
* @since 11.0
*/
public static String commonSuffix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxSuffixLength = Math.min(a.length(), b.length());
int s = 0;
while (s
}
if (validSurrogatePairAt(a, a.length() - s - 1)
|| validSurrogatePairAt(b, b.length() - s - 1)) {
s--;
}
return a.subSequence(a.length() - s, a.length()).toString();
}
代码示例来源:origin: google/j2objc
/**
* Returns the longest string {@code prefix} such that {@code a.toString().startsWith(prefix) &&
* b.toString().startsWith(prefix)}, taking care not to split surrogate pairs. If {@code a} and
* {@code b} have no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: google/j2objc
/**
* Returns the longest string {@code suffix} such that {@code a.toString().endsWith(suffix) &&
* b.toString().endsWith(suffix)}, taking care not to split surrogate pairs. If {@code a} and
* {@code b} have no common suffix, returns the empty string.
*
* @since 11.0
*/
public static String commonSuffix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxSuffixLength = Math.min(a.length(), b.length());
int s = 0;
while (s
}
if (validSurrogatePairAt(a, a.length() - s - 1)
|| validSurrogatePairAt(b, b.length() - s - 1)) {
s--;
}
return a.subSequence(a.length() - s, a.length()).toString();
}
代码示例来源:origin: wildfly/wildfly
/**
* Returns the longest string {@code prefix} such that {@code a.toString().startsWith(prefix) &&
* b.toString().startsWith(prefix)}, taking care not to split surrogate pairs. If {@code a} and
* {@code b} have no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: wildfly/wildfly
/**
* Returns the longest string {@code suffix} such that {@code a.toString().endsWith(suffix) &&
* b.toString().endsWith(suffix)}, taking care not to split surrogate pairs. If {@code a} and
* {@code b} have no common suffix, returns the empty string.
*
* @since 11.0
*/
public static String commonSuffix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxSuffixLength = Math.min(a.length(), b.length());
int s = 0;
while (s
}
if (validSurrogatePairAt(a, a.length() - s - 1)
|| validSurrogatePairAt(b, b.length() - s - 1)) {
s--;
}
return a.subSequence(a.length() - s, a.length()).toString();
}
代码示例来源:origin: google/guava
public void testValidSurrogatePairAt() {
assertTrue(Strings.validSurrogatePairAt("\uD8AB\uDCAB", 0));
assertTrue(Strings.validSurrogatePairAt("abc\uD8AB\uDCAB", 3));
assertTrue(Strings.validSurrogatePairAt("abc\uD8AB\uDCABxyz", 3));
assertFalse(Strings.validSurrogatePairAt("\uD8AB\uD8AB", 0));
assertFalse(Strings.validSurrogatePairAt("\uDCAB\uDCAB", 0));
assertFalse(Strings.validSurrogatePairAt("\uD8AB\uDCAB", -1));
assertFalse(Strings.validSurrogatePairAt("\uD8AB\uDCAB", 1));
assertFalse(Strings.validSurrogatePairAt("\uD8AB\uDCAB", -2));
assertFalse(Strings.validSurrogatePairAt("\uD8AB\uDCAB", 2));
assertFalse(Strings.validSurrogatePairAt("x\uDCAB", 0));
assertFalse(Strings.validSurrogatePairAt("\uD8ABx", 0));
}
代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger
/**
* Returns the longest string {@code prefix} such that {@code a.toString().startsWith(prefix) &&
* b.toString().startsWith(prefix)}, taking care not to split surrogate pairs. If {@code a} and
* {@code b} have no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: com.diffplug.guava/guava-core
/**
* Returns the longest string {@code prefix} such that
* {@code a.toString().startsWith(prefix) && b.toString().startsWith(prefix)},
* taking care not to split surrogate pairs. If {@code a} and {@code b} have
* no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
/**
* Returns the longest string {@code prefix} such that
* {@code a.toString().startsWith(prefix) && b.toString().startsWith(prefix)},
* taking care not to split surrogate pairs. If {@code a} and {@code b} have
* no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: com.google.guava/guava-jdk5
/**
* Returns the longest string {@code prefix} such that
* {@code a.toString().startsWith(prefix) && b.toString().startsWith(prefix)},
* taking care not to split surrogate pairs. If {@code a} and {@code b} have
* no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Returns the longest string {@code prefix} such that
* {@code a.toString().startsWith(prefix) && b.toString().startsWith(prefix)},
* taking care not to split surrogate pairs. If {@code a} and {@code b} have
* no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Returns the longest string {@code prefix} such that {@code a.toString().startsWith(prefix) &&
* b.toString().startsWith(prefix)}, taking care not to split surrogate pairs. If {@code a} and
* {@code b} have no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: Nextdoor/bender
/**
* Returns the longest string {@code prefix} such that
* {@code a.toString().startsWith(prefix) && b.toString().startsWith(prefix)},
* taking care not to split surrogate pairs. If {@code a} and {@code b} have
* no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: org.hudsonci.lib.guava/guava
/**
* Returns the longest string {@code prefix} such that
* {@code a.toString().startsWith(prefix) && b.toString().startsWith(prefix)},
* taking care not to split surrogate pairs. If {@code a} and {@code b} have
* no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava
/**
* Returns the longest string {@code prefix} such that
* {@code a.toString().startsWith(prefix) && b.toString().startsWith(prefix)},
* taking care not to split surrogate pairs. If {@code a} and {@code b} have
* no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Returns the longest string {@code prefix} such that
* {@code a.toString().startsWith(prefix) && b.toString().startsWith(prefix)},
* taking care not to split surrogate pairs. If {@code a} and {@code b} have
* no common prefix, returns the empty string.
*
* @since 11.0
*/
public static String commonPrefix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxPrefixLength = Math.min(a.length(), b.length());
int p = 0;
while (p
}
if (validSurrogatePairAt(a, p - 1) || validSurrogatePairAt(b, p - 1)) {
p--;
}
return a.subSequence(0, p).toString();
}
代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger
/**
* Returns the longest string {@code suffix} such that {@code a.toString().endsWith(suffix) &&
* b.toString().endsWith(suffix)}, taking care not to split surrogate pairs. If {@code a} and
* {@code b} have no common suffix, returns the empty string.
*
* @since 11.0
*/
public static String commonSuffix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxSuffixLength = Math.min(a.length(), b.length());
int s = 0;
while (s
}
if (validSurrogatePairAt(a, a.length() - s - 1)
|| validSurrogatePairAt(b, b.length() - s - 1)) {
s--;
}
return a.subSequence(a.length() - s, a.length()).toString();
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Returns the longest string {@code suffix} such that {@code a.toString().endsWith(suffix) &&
* b.toString().endsWith(suffix)}, taking care not to split surrogate pairs. If {@code a} and
* {@code b} have no common suffix, returns the empty string.
*
* @since 11.0
*/
public static String commonSuffix(CharSequence a, CharSequence b) {
checkNotNull(a);
checkNotNull(b);
int maxSuffixLength = Math.min(a.length(), b.length());
int s = 0;
while (s
}
if (validSurrogatePairAt(a, a.length() - s - 1)
|| validSurrogatePairAt(b, b.length() - s - 1)) {
s--;
}
return a.subSequence(a.length() - s, a.length()).toString();
}
代码示例来源:origin: com.google.guava/guava-tests
public void testValidSurrogatePairAt() {
assertTrue(Strings.validSurrogatePairAt("\uD8AB\uDCAB", 0));
assertTrue(Strings.validSurrogatePairAt("abc\uD8AB\uDCAB", 3));
assertTrue(Strings.validSurrogatePairAt("abc\uD8AB\uDCABxyz", 3));
assertFalse(Strings.validSurrogatePairAt("\uD8AB\uD8AB", 0));
assertFalse(Strings.validSurrogatePairAt("\uDCAB\uDCAB", 0));
assertFalse(Strings.validSurrogatePairAt("\uD8AB\uDCAB", -1));
assertFalse(Strings.validSurrogatePairAt("\uD8AB\uDCAB", 1));
assertFalse(Strings.validSurrogatePairAt("\uD8AB\uDCAB", -2));
assertFalse(Strings.validSurrogatePairAt("\uD8AB\uDCAB", 2));
assertFalse(Strings.validSurrogatePairAt("x\uDCAB", 0));
assertFalse(Strings.validSurrogatePairAt("\uD8ABx", 0));
}