LoggingByteArrayOutputStream.smali
.class public Lcom/google/api/client/util/LoggingByteArrayOutputStream;
.super Ljava/io/ByteArrayOutputStream;
# instance fields
.field private f:I
.field private final g:I
.field private h:Z
.field private final i:Ljava/util/logging/Level;
.field private final j:Ljava/util/logging/Logger;
# direct methods
.method public constructor <init>(Ljava/util/logging/Logger;Ljava/util/logging/Level;I)V
.registers 4
invoke-direct {p0}, Ljava/io/ByteArrayOutputStream;-><init>()V
invoke-static {p1}, Lcom/google/api/client/util/Preconditions;->d(Ljava/lang/Object;)Ljava/lang/Object;
check-cast p1, Ljava/util/logging/Logger;
iput-object p1, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->j:Ljava/util/logging/Logger;
invoke-static {p2}, Lcom/google/api/client/util/Preconditions;->d(Ljava/lang/Object;)Ljava/lang/Object;
check-cast p2, Ljava/util/logging/Level;
iput-object p2, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->i:Ljava/util/logging/Level;
if-ltz p3, :cond_15
const/4 p1, 0x1
goto :goto_16
:cond_15
const/4 p1, 0x0
:goto_16
invoke-static {p1}, Lcom/google/api/client/util/Preconditions;->a(Z)V
iput p3, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->g:I
return-void
.end method
.method private static a(Ljava/lang/StringBuilder;I)V
.registers 5
const/4 v0, 0x1
if-ne p1, v0, :cond_9
const-string p1, "1 byte"
invoke-virtual {p0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
goto :goto_1a
:cond_9
invoke-static {}, Ljava/text/NumberFormat;->getInstance()Ljava/text/NumberFormat;
move-result-object v0
int-to-long v1, p1
invoke-virtual {v0, v1, v2}, Ljava/text/NumberFormat;->format(J)Ljava/lang/String;
move-result-object p1
invoke-virtual {p0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string p1, " bytes"
invoke-virtual {p0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
:goto_1a
return-void
.end method
# virtual methods
.method public declared-synchronized close()V
.registers 6
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
monitor-enter p0
:try_start_1
iget-boolean v0, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->h:Z
if-nez v0, :cond_56
iget v0, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->f:I
if-eqz v0, :cond_53
new-instance v0, Ljava/lang/StringBuilder;
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
const-string v1, "Total: "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
iget v1, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->f:I
invoke-static {v0, v1}, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->a(Ljava/lang/StringBuilder;I)V
iget v1, p0, Ljava/io/ByteArrayOutputStream;->count:I
if-eqz v1, :cond_31
iget v1, p0, Ljava/io/ByteArrayOutputStream;->count:I
iget v2, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->f:I
if-ge v1, v2, :cond_31
const-string v1, " (logging first "
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
iget v1, p0, Ljava/io/ByteArrayOutputStream;->count:I
invoke-static {v0, v1}, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->a(Ljava/lang/StringBuilder;I)V
const-string v1, ")"
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
:cond_31
iget-object v1, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->j:Ljava/util/logging/Logger;
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
invoke-virtual {v1, v0}, Ljava/util/logging/Logger;->config(Ljava/lang/String;)V
iget v0, p0, Ljava/io/ByteArrayOutputStream;->count:I
if-eqz v0, :cond_53
iget-object v0, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->j:Ljava/util/logging/Logger;
iget-object v1, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->i:Ljava/util/logging/Level;
const-string v2, "UTF-8"
invoke-virtual {p0, v2}, Ljava/io/ByteArrayOutputStream;->toString(Ljava/lang/String;)Ljava/lang/String;
move-result-object v2
const-string v3, "[\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F]"
const-string v4, " "
invoke-virtual {v2, v3, v4}, Ljava/lang/String;->replaceAll(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object v2
invoke-virtual {v0, v1, v2}, Ljava/util/logging/Logger;->log(Ljava/util/logging/Level;Ljava/lang/String;)V
:cond_53
const/4 v0, 0x1
iput-boolean v0, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->h:Z
:try_end_56
.catchall {:try_start_1 .. :try_end_56} :catchall_58
:cond_56
monitor-exit p0
return-void
:catchall_58
move-exception v0
monitor-exit p0
throw v0
.end method
.method public declared-synchronized write(I)V
.registers 4
monitor-enter p0
:try_start_1
iget-boolean v0, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->h:Z
const/4 v1, 0x1
if-nez v0, :cond_8
const/4 v0, 0x1
goto :goto_9
:cond_8
const/4 v0, 0x0
:goto_9
invoke-static {v0}, Lcom/google/api/client/util/Preconditions;->a(Z)V
iget v0, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->f:I
add-int/2addr v0, v1
iput v0, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->f:I
iget v0, p0, Ljava/io/ByteArrayOutputStream;->count:I
iget v1, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->g:I
if-ge v0, v1, :cond_1a
invoke-super {p0, p1}, Ljava/io/ByteArrayOutputStream;->write(I)V
:try_end_1a
.catchall {:try_start_1 .. :try_end_1a} :catchall_1c
:cond_1a
monitor-exit p0
return-void
:catchall_1c
move-exception p1
monitor-exit p0
throw p1
.end method
.method public declared-synchronized write([BII)V
.registers 6
monitor-enter p0
:try_start_1
iget-boolean v0, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->h:Z
if-nez v0, :cond_7
const/4 v0, 0x1
goto :goto_8
:cond_7
const/4 v0, 0x0
:goto_8
invoke-static {v0}, Lcom/google/api/client/util/Preconditions;->a(Z)V
iget v0, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->f:I
add-int/2addr v0, p3
iput v0, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->f:I
iget v0, p0, Ljava/io/ByteArrayOutputStream;->count:I
iget v1, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->g:I
if-ge v0, v1, :cond_24
iget v0, p0, Ljava/io/ByteArrayOutputStream;->count:I
add-int/2addr v0, p3
iget v1, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->g:I
if-le v0, v1, :cond_21
iget v1, p0, Lcom/google/api/client/util/LoggingByteArrayOutputStream;->g:I
sub-int/2addr v1, v0
add-int/2addr p3, v1
:cond_21
invoke-super {p0, p1, p2, p3}, Ljava/io/ByteArrayOutputStream;->write([BII)V
:try_end_24
.catchall {:try_start_1 .. :try_end_24} :catchall_26
:cond_24
monitor-exit p0
return-void
:catchall_26
move-exception p1
monitor-exit p0
throw p1
.end method