导航菜单

页面标题

页面副标题

SpeedCash v6.5.1482 - Status.java 源代码

正在查看: SpeedCash v6.5.1482 应用的 Status.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package io.grpc;

import com.google.common.base.Charsets;
import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import com.google.common.base.Throwables;
import io.grpc.Metadata;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.TreeMap;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

@CheckReturnValue
@Immutable
public final class Status {
    public static final Metadata.Key<Status> f;
    public static final Metadata.i<String> g;
    public static final Metadata.Key<String> h;
    public final Code a;
    public final String b;
    public final Throwable c;
    public static final boolean d = Boolean.parseBoolean(System.getProperty("io.grpc.Status.failOnEqualsForTest", "false"));
    public static final List<Status> e = c();
    public static final Status OK = Code.OK.toStatus();
    public static final Status CANCELLED = Code.CANCELLED.toStatus();
    public static final Status UNKNOWN = Code.UNKNOWN.toStatus();
    public static final Status INVALID_ARGUMENT = Code.INVALID_ARGUMENT.toStatus();
    public static final Status DEADLINE_EXCEEDED = Code.DEADLINE_EXCEEDED.toStatus();
    public static final Status NOT_FOUND = Code.NOT_FOUND.toStatus();
    public static final Status ALREADY_EXISTS = Code.ALREADY_EXISTS.toStatus();
    public static final Status PERMISSION_DENIED = Code.PERMISSION_DENIED.toStatus();
    public static final Status UNAUTHENTICATED = Code.UNAUTHENTICATED.toStatus();
    public static final Status RESOURCE_EXHAUSTED = Code.RESOURCE_EXHAUSTED.toStatus();
    public static final Status FAILED_PRECONDITION = Code.FAILED_PRECONDITION.toStatus();
    public static final Status ABORTED = Code.ABORTED.toStatus();
    public static final Status OUT_OF_RANGE = Code.OUT_OF_RANGE.toStatus();
    public static final Status UNIMPLEMENTED = Code.UNIMPLEMENTED.toStatus();
    public static final Status INTERNAL = Code.INTERNAL.toStatus();
    public static final Status UNAVAILABLE = Code.UNAVAILABLE.toStatus();
    public static final Status DATA_LOSS = Code.DATA_LOSS.toStatus();

    public enum Code {
        OK(0),
        CANCELLED(1),
        UNKNOWN(2),
        INVALID_ARGUMENT(3),
        DEADLINE_EXCEEDED(4),
        NOT_FOUND(5),
        ALREADY_EXISTS(6),
        PERMISSION_DENIED(7),
        RESOURCE_EXHAUSTED(8),
        FAILED_PRECONDITION(9),
        ABORTED(10),
        OUT_OF_RANGE(11),
        UNIMPLEMENTED(12),
        INTERNAL(13),
        UNAVAILABLE(14),
        DATA_LOSS(15),
        UNAUTHENTICATED(16);

        public final int a;
        public final byte[] b;

        Code(int i) {
            this.a = i;
            this.b = Integer.toString(i).getBytes(Charsets.US_ASCII);
        }

        public final byte[] b() {
            return this.b;
        }

        public Status toStatus() {
            return (Status) Status.e.get(this.a);
        }

        public int value() {
            return this.a;
        }
    }

    public static final class b implements Metadata.i<Status> {
        public b() {
        }

        @Override
        public Status parseAsciiString(byte[] bArr) {
            return Status.e(bArr);
        }

        @Override
        public byte[] toAsciiString(Status status) {
            return status.getCode().b();
        }
    }

    public static final class c implements Metadata.i<String> {
        public static final byte[] a = {48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70};

        public c() {
        }

        public static boolean a(byte b) {
            return b < 32 || b >= 126 || b == 37;
        }

        public static String c(byte[] bArr) {
            ByteBuffer allocate = ByteBuffer.allocate(bArr.length);
            int i = 0;
            while (i < bArr.length) {
                if (bArr[i] == 37 && i + 2 < bArr.length) {
                    try {
                        allocate.put((byte) Integer.parseInt(new String(bArr, i + 1, 2, Charsets.US_ASCII), 16));
                        i += 3;
                    } catch (NumberFormatException unused) {
                    }
                }
                allocate.put(bArr[i]);
                i++;
            }
            return new String(allocate.array(), 0, allocate.position(), Charsets.UTF_8);
        }

        public static byte[] e(byte[] bArr, int i) {
            byte[] bArr2 = new byte[((bArr.length - i) * 3) + i];
            if (i != 0) {
                System.arraycopy(bArr, 0, bArr2, 0, i);
            }
            int i2 = i;
            while (i < bArr.length) {
                byte b = bArr[i];
                if (a(b)) {
                    bArr2[i2] = 37;
                    byte[] bArr3 = a;
                    bArr2[i2 + 1] = bArr3[(b >> 4) & 15];
                    bArr2[i2 + 2] = bArr3[b & 15];
                    i2 += 3;
                } else {
                    bArr2[i2] = b;
                    i2++;
                }
                i++;
            }
            return Arrays.copyOf(bArr2, i2);
        }

        @Override
        public String parseAsciiString(byte[] bArr) {
            for (int i = 0; i < bArr.length; i++) {
                byte b = bArr[i];
                if (b < 32 || b >= 126 || (b == 37 && i + 2 < bArr.length)) {
                    return c(bArr);
                }
            }
            return new String(bArr, 0);
        }

        @Override
        public byte[] toAsciiString(String str) {
            byte[] bytes = str.getBytes(Charsets.UTF_8);
            for (int i = 0; i < bytes.length; i++) {
                if (a(bytes[i])) {
                    return e(bytes, i);
                }
            }
            return bytes;
        }
    }

    static {
        f = Metadata.Key.e("grpc-status", false, new b());
        c cVar = new c();
        g = cVar;
        h = Metadata.Key.e("grpc-message", false, cVar);
    }

    public Status(Code code) {
        this(code, null, null);
    }

    public static List<Status> c() {
        TreeMap treeMap = new TreeMap();
        for (Code code : Code.values()) {
            Status status = (Status) treeMap.put(Integer.valueOf(code.value()), new Status(code));
            if (status != null) {
                throw new IllegalStateException("Code value duplication between " + status.getCode().name() + " & " + code.name());
            }
        }
        return Collections.unmodifiableList(new ArrayList(treeMap.values()));
    }

    public static String d(Status status) {
        if (status.b == null) {
            return status.a.toString();
        }
        return status.a + ": " + status.b;
    }

    public static Status e(byte[] bArr) {
        return (bArr.length == 1 && bArr[0] == 48) ? OK : f(bArr);
    }

    public static Status f(byte[] bArr) {
        int i;
        byte b2;
        int length = bArr.length;
        char c2 = 1;
        if (length != 1) {
            i = (length == 2 && (b2 = bArr[0]) >= 48 && b2 <= 57) ? 0 + ((b2 - 48) * 10) : 0;
            return UNKNOWN.withDescription("Unknown code " + new String(bArr, Charsets.US_ASCII));
        }
        c2 = 0;
        byte b3 = bArr[c2];
        if (b3 >= 48 && b3 <= 57) {
            int i2 = i + (b3 - 48);
            List<Status> list = e;
            if (i2 < list.size()) {
                return list.get(i2);
            }
        }
        return UNKNOWN.withDescription("Unknown code " + new String(bArr, Charsets.US_ASCII));
    }

    public static Status fromCode(Code code) {
        return code.toStatus();
    }

    public static Status fromCodeValue(int i) {
        if (i >= 0) {
            List<Status> list = e;
            if (i <= list.size()) {
                return list.get(i);
            }
        }
        return UNKNOWN.withDescription("Unknown code " + i);
    }

    public static Status fromThrowable(Throwable th) {
        for (Throwable th2 = (Throwable) Preconditions.checkNotNull(th, "t"); th2 != null; th2 = th2.getCause()) {
            if (th2 instanceof StatusException) {
                return ((StatusException) th2).getStatus();
            }
            if (th2 instanceof StatusRuntimeException) {
                return ((StatusRuntimeException) th2).getStatus();
            }
        }
        return UNKNOWN.withCause(th);
    }

    @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4683")
    @Nullable
    public static Metadata trailersFromThrowable(Throwable th) {
        for (Throwable th2 = (Throwable) Preconditions.checkNotNull(th, "t"); th2 != null; th2 = th2.getCause()) {
            if (th2 instanceof StatusException) {
                return ((StatusException) th2).getTrailers();
            }
            if (th2 instanceof StatusRuntimeException) {
                return ((StatusRuntimeException) th2).getTrailers();
            }
        }
        return null;
    }

    public StatusException asException() {
        return new StatusException(this);
    }

    public StatusRuntimeException asRuntimeException() {
        return new StatusRuntimeException(this);
    }

    public Status augmentDescription(String str) {
        if (str == null) {
            return this;
        }
        if (this.b == null) {
            return new Status(this.a, str, this.c);
        }
        return new Status(this.a, this.b + "\n" + str, this.c);
    }

    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    @Nullable
    public Throwable getCause() {
        return this.c;
    }

    public Code getCode() {
        return this.a;
    }

    @Nullable
    public String getDescription() {
        return this.b;
    }

    public int hashCode() {
        return super.hashCode();
    }

    public boolean isOk() {
        return Code.OK == this.a;
    }

    public String toString() {
        MoreObjects.ToStringHelper add = MoreObjects.toStringHelper(this).add("code", this.a.name()).add("description", this.b);
        Throwable th = this.c;
        Object obj = th;
        if (th != null) {
            obj = Throwables.getStackTraceAsString(th);
        }
        return add.add("cause", obj).toString();
    }

    public Status withCause(Throwable th) {
        return Objects.equal(this.c, th) ? this : new Status(this.a, this.b, th);
    }

    public Status withDescription(String str) {
        return Objects.equal(this.b, str) ? this : new Status(this.a, str, this.c);
    }

    public Status(Code code, @Nullable String str, @Nullable Throwable th) {
        this.a = (Code) Preconditions.checkNotNull(code, "code");
        this.b = str;
        this.c = th;
    }

    public StatusException asException(@Nullable Metadata metadata) {
        return new StatusException(this, metadata);
    }

    @ExperimentalApi("https://github.com/grpc/grpc-java/issues/4683")
    public StatusRuntimeException asRuntimeException(@Nullable Metadata metadata) {
        return new StatusRuntimeException(this, metadata);
    }
}