You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
573 lines
12 KiB
573 lines
12 KiB
.class public final Lcom/google/common/base/Strings; |
|
.super Ljava/lang/Object; |
|
.source "Strings.java" |
|
|
|
|
|
# annotations |
|
.annotation build Lcom/google/common/annotations/GwtCompatible; |
|
.end annotation |
|
|
|
|
|
# direct methods |
|
.method private constructor <init>()V |
|
.locals 0 |
|
|
|
.prologue |
|
.line 38 |
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V |
|
|
|
return-void |
|
.end method |
|
|
|
.method public static commonPrefix(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; |
|
.locals 5 |
|
|
|
.prologue |
|
const/4 v1, 0x0 |
|
|
|
.line 189 |
|
invoke-static {p0}, Lcom/google/common/base/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object; |
|
|
|
.line 190 |
|
invoke-static {p1}, Lcom/google/common/base/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object; |
|
|
|
.line 192 |
|
invoke-interface {p0}, Ljava/lang/CharSequence;->length()I |
|
|
|
move-result v0 |
|
|
|
invoke-interface {p1}, Ljava/lang/CharSequence;->length()I |
|
|
|
move-result v2 |
|
|
|
invoke-static {v0, v2}, Ljava/lang/Math;->min(II)I |
|
|
|
move-result v2 |
|
|
|
move v0, v1 |
|
|
|
.line 194 |
|
:goto_0 |
|
if-ge v0, v2, :cond_0 |
|
|
|
invoke-interface {p0, v0}, Ljava/lang/CharSequence;->charAt(I)C |
|
|
|
move-result v3 |
|
|
|
invoke-interface {p1, v0}, Ljava/lang/CharSequence;->charAt(I)C |
|
|
|
move-result v4 |
|
|
|
if-ne v3, v4, :cond_0 |
|
|
|
.line 195 |
|
add-int/lit8 v0, v0, 0x1 |
|
|
|
goto :goto_0 |
|
|
|
.line 197 |
|
:cond_0 |
|
add-int/lit8 v2, v0, -0x1 |
|
|
|
invoke-static {p0, v2}, Lcom/google/common/base/Strings;->validSurrogatePairAt(Ljava/lang/CharSequence;I)Z |
|
|
|
move-result v2 |
|
|
|
if-nez v2, :cond_1 |
|
|
|
add-int/lit8 v2, v0, -0x1 |
|
|
|
invoke-static {p1, v2}, Lcom/google/common/base/Strings;->validSurrogatePairAt(Ljava/lang/CharSequence;I)Z |
|
|
|
move-result v2 |
|
|
|
if-eqz v2, :cond_2 |
|
|
|
.line 198 |
|
:cond_1 |
|
add-int/lit8 v0, v0, -0x1 |
|
|
|
.line 200 |
|
:cond_2 |
|
invoke-interface {p0, v1, v0}, Ljava/lang/CharSequence;->subSequence(II)Ljava/lang/CharSequence; |
|
|
|
move-result-object v0 |
|
|
|
invoke-interface {v0}, Ljava/lang/CharSequence;->toString()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
return-object v0 |
|
.end method |
|
|
|
.method public static commonSuffix(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String; |
|
.locals 4 |
|
|
|
.prologue |
|
.line 212 |
|
invoke-static {p0}, Lcom/google/common/base/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object; |
|
|
|
.line 213 |
|
invoke-static {p1}, Lcom/google/common/base/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object; |
|
|
|
.line 215 |
|
invoke-interface {p0}, Ljava/lang/CharSequence;->length()I |
|
|
|
move-result v0 |
|
|
|
invoke-interface {p1}, Ljava/lang/CharSequence;->length()I |
|
|
|
move-result v1 |
|
|
|
invoke-static {v0, v1}, Ljava/lang/Math;->min(II)I |
|
|
|
move-result v1 |
|
|
|
.line 216 |
|
const/4 v0, 0x0 |
|
|
|
.line 218 |
|
:goto_0 |
|
if-ge v0, v1, :cond_0 |
|
|
|
invoke-interface {p0}, Ljava/lang/CharSequence;->length()I |
|
|
|
move-result v2 |
|
|
|
sub-int/2addr v2, v0 |
|
|
|
add-int/lit8 v2, v2, -0x1 |
|
|
|
invoke-interface {p0, v2}, Ljava/lang/CharSequence;->charAt(I)C |
|
|
|
move-result v2 |
|
|
|
invoke-interface {p1}, Ljava/lang/CharSequence;->length()I |
|
|
|
move-result v3 |
|
|
|
sub-int/2addr v3, v0 |
|
|
|
add-int/lit8 v3, v3, -0x1 |
|
|
|
invoke-interface {p1, v3}, Ljava/lang/CharSequence;->charAt(I)C |
|
|
|
move-result v3 |
|
|
|
if-ne v2, v3, :cond_0 |
|
|
|
.line 219 |
|
add-int/lit8 v0, v0, 0x1 |
|
|
|
goto :goto_0 |
|
|
|
.line 221 |
|
:cond_0 |
|
invoke-interface {p0}, Ljava/lang/CharSequence;->length()I |
|
|
|
move-result v1 |
|
|
|
sub-int/2addr v1, v0 |
|
|
|
add-int/lit8 v1, v1, -0x1 |
|
|
|
invoke-static {p0, v1}, Lcom/google/common/base/Strings;->validSurrogatePairAt(Ljava/lang/CharSequence;I)Z |
|
|
|
move-result v1 |
|
|
|
if-nez v1, :cond_1 |
|
|
|
invoke-interface {p1}, Ljava/lang/CharSequence;->length()I |
|
|
|
move-result v1 |
|
|
|
sub-int/2addr v1, v0 |
|
|
|
add-int/lit8 v1, v1, -0x1 |
|
|
|
invoke-static {p1, v1}, Lcom/google/common/base/Strings;->validSurrogatePairAt(Ljava/lang/CharSequence;I)Z |
|
|
|
move-result v1 |
|
|
|
if-eqz v1, :cond_2 |
|
|
|
.line 223 |
|
:cond_1 |
|
add-int/lit8 v0, v0, -0x1 |
|
|
|
.line 225 |
|
:cond_2 |
|
invoke-interface {p0}, Ljava/lang/CharSequence;->length()I |
|
|
|
move-result v1 |
|
|
|
sub-int v0, v1, v0 |
|
|
|
invoke-interface {p0}, Ljava/lang/CharSequence;->length()I |
|
|
|
move-result v1 |
|
|
|
invoke-interface {p0, v0, v1}, Ljava/lang/CharSequence;->subSequence(II)Ljava/lang/CharSequence; |
|
|
|
move-result-object v0 |
|
|
|
invoke-interface {v0}, Ljava/lang/CharSequence;->toString()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
return-object v0 |
|
.end method |
|
|
|
.method public static emptyToNull(Ljava/lang/String;)Ljava/lang/String; |
|
.locals 1 |
|
.param p0 # Ljava/lang/String; |
|
.annotation runtime Ljavax/annotation/Nullable; |
|
.end annotation |
|
.end param |
|
.annotation runtime Ljavax/annotation/Nullable; |
|
.end annotation |
|
|
|
.prologue |
|
.line 58 |
|
invoke-static {p0}, Lcom/google/common/base/Strings;->isNullOrEmpty(Ljava/lang/String;)Z |
|
|
|
move-result v0 |
|
|
|
if-eqz v0, :cond_0 |
|
|
|
const/4 p0, 0x0 |
|
|
|
:cond_0 |
|
return-object p0 |
|
.end method |
|
|
|
.method public static isNullOrEmpty(Ljava/lang/String;)Z |
|
.locals 1 |
|
.param p0 # Ljava/lang/String; |
|
.annotation runtime Ljavax/annotation/Nullable; |
|
.end annotation |
|
.end param |
|
|
|
.prologue |
|
.line 75 |
|
if-eqz p0, :cond_0 |
|
|
|
invoke-virtual {p0}, Ljava/lang/String;->length()I |
|
|
|
move-result v0 |
|
|
|
if-nez v0, :cond_1 |
|
|
|
:cond_0 |
|
const/4 v0, 0x1 |
|
|
|
:goto_0 |
|
return v0 |
|
|
|
:cond_1 |
|
const/4 v0, 0x0 |
|
|
|
goto :goto_0 |
|
.end method |
|
|
|
.method public static nullToEmpty(Ljava/lang/String;)Ljava/lang/String; |
|
.locals 0 |
|
.param p0 # Ljava/lang/String; |
|
.annotation runtime Ljavax/annotation/Nullable; |
|
.end annotation |
|
.end param |
|
|
|
.prologue |
|
.line 47 |
|
if-nez p0, :cond_0 |
|
|
|
const-string p0, "" |
|
|
|
:cond_0 |
|
return-object p0 |
|
.end method |
|
|
|
.method public static padEnd(Ljava/lang/String;IC)Ljava/lang/String; |
|
.locals 2 |
|
|
|
.prologue |
|
.line 130 |
|
invoke-static {p0}, Lcom/google/common/base/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object; |
|
|
|
.line 131 |
|
invoke-virtual {p0}, Ljava/lang/String;->length()I |
|
|
|
move-result v0 |
|
|
|
if-lt v0, p1, :cond_0 |
|
|
|
.line 139 |
|
:goto_0 |
|
return-object p0 |
|
|
|
.line 134 |
|
:cond_0 |
|
new-instance v1, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v1, p1}, Ljava/lang/StringBuilder;-><init>(I)V |
|
|
|
.line 135 |
|
invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
.line 136 |
|
invoke-virtual {p0}, Ljava/lang/String;->length()I |
|
|
|
move-result v0 |
|
|
|
:goto_1 |
|
if-ge v0, p1, :cond_1 |
|
|
|
.line 137 |
|
invoke-virtual {v1, p2}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder; |
|
|
|
.line 136 |
|
add-int/lit8 v0, v0, 0x1 |
|
|
|
goto :goto_1 |
|
|
|
.line 139 |
|
:cond_1 |
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object p0 |
|
|
|
goto :goto_0 |
|
.end method |
|
|
|
.method public static padStart(Ljava/lang/String;IC)Ljava/lang/String; |
|
.locals 2 |
|
|
|
.prologue |
|
.line 98 |
|
invoke-static {p0}, Lcom/google/common/base/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object; |
|
|
|
.line 99 |
|
invoke-virtual {p0}, Ljava/lang/String;->length()I |
|
|
|
move-result v0 |
|
|
|
if-lt v0, p1, :cond_0 |
|
|
|
.line 107 |
|
:goto_0 |
|
return-object p0 |
|
|
|
.line 102 |
|
:cond_0 |
|
new-instance v1, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v1, p1}, Ljava/lang/StringBuilder;-><init>(I)V |
|
|
|
.line 103 |
|
invoke-virtual {p0}, Ljava/lang/String;->length()I |
|
|
|
move-result v0 |
|
|
|
:goto_1 |
|
if-ge v0, p1, :cond_1 |
|
|
|
.line 104 |
|
invoke-virtual {v1, p2}, Ljava/lang/StringBuilder;->append(C)Ljava/lang/StringBuilder; |
|
|
|
.line 103 |
|
add-int/lit8 v0, v0, 0x1 |
|
|
|
goto :goto_1 |
|
|
|
.line 106 |
|
:cond_1 |
|
invoke-virtual {v1, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
.line 107 |
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object p0 |
|
|
|
goto :goto_0 |
|
.end method |
|
|
|
.method public static repeat(Ljava/lang/String;I)Ljava/lang/String; |
|
.locals 8 |
|
|
|
.prologue |
|
const/4 v1, 0x1 |
|
|
|
const/4 v2, 0x0 |
|
|
|
.line 154 |
|
invoke-static {p0}, Lcom/google/common/base/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object; |
|
|
|
.line 156 |
|
if-gt p1, v1, :cond_2 |
|
|
|
.line 157 |
|
if-ltz p1, :cond_1 |
|
|
|
move v0, v1 |
|
|
|
:goto_0 |
|
const-string v3, "invalid count: %s" |
|
|
|
new-array v1, v1, [Ljava/lang/Object; |
|
|
|
invoke-static {p1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer; |
|
|
|
move-result-object v4 |
|
|
|
aput-object v4, v1, v2 |
|
|
|
invoke-static {v0, v3, v1}, Lcom/google/common/base/Preconditions;->checkArgument(ZLjava/lang/String;[Ljava/lang/Object;)V |
|
|
|
.line 158 |
|
if-nez p1, :cond_0 |
|
|
|
const-string p0, "" |
|
|
|
.line 177 |
|
:cond_0 |
|
:goto_1 |
|
return-object p0 |
|
|
|
:cond_1 |
|
move v0, v2 |
|
|
|
.line 157 |
|
goto :goto_0 |
|
|
|
.line 162 |
|
:cond_2 |
|
invoke-virtual {p0}, Ljava/lang/String;->length()I |
|
|
|
move-result v0 |
|
|
|
.line 163 |
|
int-to-long v4, v0 |
|
|
|
int-to-long v6, p1 |
|
|
|
mul-long/2addr v4, v6 |
|
|
|
.line 164 |
|
long-to-int v1, v4 |
|
|
|
.line 165 |
|
int-to-long v6, v1 |
|
|
|
cmp-long v3, v6, v4 |
|
|
|
if-eqz v3, :cond_3 |
|
|
|
.line 166 |
|
new-instance v0, Ljava/lang/ArrayIndexOutOfBoundsException; |
|
|
|
new-instance v1, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
const-string v2, "Required array size too large: " |
|
|
|
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v1 |
|
|
|
invoke-virtual {v1, v4, v5}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v1 |
|
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v1 |
|
|
|
invoke-direct {v0, v1}, Ljava/lang/ArrayIndexOutOfBoundsException;-><init>(Ljava/lang/String;)V |
|
|
|
throw v0 |
|
|
|
.line 170 |
|
:cond_3 |
|
new-array v3, v1, [C |
|
|
|
.line 171 |
|
invoke-virtual {p0, v2, v0, v3, v2}, Ljava/lang/String;->getChars(II[CI)V |
|
|
|
.line 173 |
|
:goto_2 |
|
sub-int v4, v1, v0 |
|
|
|
if-ge v0, v4, :cond_4 |
|
|
|
.line 174 |
|
invoke-static {v3, v2, v3, v0, v0}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V |
|
|
|
.line 173 |
|
shl-int/lit8 v0, v0, 0x1 |
|
|
|
goto :goto_2 |
|
|
|
.line 176 |
|
:cond_4 |
|
sub-int/2addr v1, v0 |
|
|
|
invoke-static {v3, v2, v3, v0, v1}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V |
|
|
|
.line 177 |
|
new-instance p0, Ljava/lang/String; |
|
|
|
invoke-direct {p0, v3}, Ljava/lang/String;-><init>([C)V |
|
|
|
goto :goto_1 |
|
.end method |
|
|
|
.method static validSurrogatePairAt(Ljava/lang/CharSequence;I)Z |
|
.locals 1 |
|
.annotation build Lcom/google/common/annotations/VisibleForTesting; |
|
.end annotation |
|
|
|
.prologue |
|
.line 234 |
|
if-ltz p1, :cond_0 |
|
|
|
invoke-interface {p0}, Ljava/lang/CharSequence;->length()I |
|
|
|
move-result v0 |
|
|
|
add-int/lit8 v0, v0, -0x2 |
|
|
|
if-gt p1, v0, :cond_0 |
|
|
|
invoke-interface {p0, p1}, Ljava/lang/CharSequence;->charAt(I)C |
|
|
|
move-result v0 |
|
|
|
invoke-static {v0}, Ljava/lang/Character;->isHighSurrogate(C)Z |
|
|
|
move-result v0 |
|
|
|
if-eqz v0, :cond_0 |
|
|
|
add-int/lit8 v0, p1, 0x1 |
|
|
|
invoke-interface {p0, v0}, Ljava/lang/CharSequence;->charAt(I)C |
|
|
|
move-result v0 |
|
|
|
invoke-static {v0}, Ljava/lang/Character;->isLowSurrogate(C)Z |
|
|
|
move-result v0 |
|
|
|
if-eqz v0, :cond_0 |
|
|
|
const/4 v0, 0x1 |
|
|
|
:goto_0 |
|
return v0 |
|
|
|
:cond_0 |
|
const/4 v0, 0x0 |
|
|
|
goto :goto_0 |
|
.end method
|
|
|