.class public Lcom/ea/nimble/ByteBufferIOStream; .super Ljava/lang/Object; .source "SourceFile" # annotations .annotation system Ldalvik/annotation/MemberClasses; value = { Lcom/ea/nimble/ByteBufferIOStream$ByteBufferInputStream;, Lcom/ea/nimble/ByteBufferIOStream$ByteBufferOutputStream; } .end annotation # static fields .field protected static final SEGMENT_SIZE:I = 0x1000 # instance fields .field protected m_availableSegment:I .field protected m_buffer:Ljava/util/LinkedList; .annotation system Ldalvik/annotation/Signature; value = { "Ljava/util/LinkedList<", "[B>;" } .end annotation .end field .field protected m_closed:Z .field protected m_input:Lcom/ea/nimble/ByteBufferIOStream$ByteBufferInputStream; .field protected m_output:Lcom/ea/nimble/ByteBufferIOStream$ByteBufferOutputStream; .field protected m_readPosition:I .field protected m_writePosition:I # direct methods .method public constructor ()V .locals 1 const/4 v0, 0x1 .line 22 invoke-direct {p0, v0}, Lcom/ea/nimble/ByteBufferIOStream;->(I)V return-void .end method .method public constructor (I)V .locals 4 .line 27 invoke-direct {p0}, Ljava/lang/Object;->()V const/4 v0, 0x0 iput-boolean v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_closed:Z iput v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_availableSegment:I iput v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_writePosition:I iput v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_readPosition:I .line 32 new-instance v1, Ljava/util/LinkedList; invoke-direct {v1}, Ljava/util/LinkedList;->()V iput-object v1, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_buffer:Ljava/util/LinkedList; .line 33 new-instance v1, Lcom/ea/nimble/ByteBufferIOStream$ByteBufferInputStream; invoke-direct {v1, p0}, Lcom/ea/nimble/ByteBufferIOStream$ByteBufferInputStream;->(Lcom/ea/nimble/ByteBufferIOStream;)V iput-object v1, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_input:Lcom/ea/nimble/ByteBufferIOStream$ByteBufferInputStream; .line 34 new-instance v1, Lcom/ea/nimble/ByteBufferIOStream$ByteBufferOutputStream; invoke-direct {v1, p0}, Lcom/ea/nimble/ByteBufferIOStream$ByteBufferOutputStream;->(Lcom/ea/nimble/ByteBufferIOStream;)V iput-object v1, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_output:Lcom/ea/nimble/ByteBufferIOStream$ByteBufferOutputStream; const/4 v1, 0x1 if-gtz p1, :cond_0 move p1, v1 :cond_0 sub-int/2addr p1, v1 const/16 v2, 0x1000 .line 39 div-int/2addr p1, v2 add-int/2addr p1, v1 :goto_0 if-ge v0, p1, :cond_1 iget-object v1, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_buffer:Ljava/util/LinkedList; new-array v3, v2, [B .line 42 invoke-virtual {v1, v3}, Ljava/util/LinkedList;->add(Ljava/lang/Object;)Z add-int/lit8 v0, v0, 0x1 goto :goto_0 :cond_1 return-void .end method # virtual methods .method public appendSegmentToBuffer([BI)V .locals 4 .annotation system Ldalvik/annotation/Throws; value = { Ljava/io/IOException; } .end annotation iget v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_writePosition:I const/4 v1, 0x0 if-nez v0, :cond_2 .line 94 array-length v0, p1 const/16 v2, 0x1000 if-ne v0, v2, :cond_2 iget-object v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_buffer:Ljava/util/LinkedList; .line 96 invoke-virtual {v0}, Ljava/util/AbstractList;->listIterator()Ljava/util/ListIterator; move-result-object v0 :goto_0 iget v3, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_availableSegment:I if-ge v1, v3, :cond_0 .line 99 invoke-interface {v0}, Ljava/util/ListIterator;->next()Ljava/lang/Object; add-int/lit8 v1, v1, 0x1 goto :goto_0 .line 102 :cond_0 invoke-interface {v0, p1}, Ljava/util/ListIterator;->add(Ljava/lang/Object;)V if-eq p2, v2, :cond_1 iput p2, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_writePosition:I goto :goto_1 :cond_1 iget p1, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_availableSegment:I add-int/lit8 p1, p1, 0x1 iput p1, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_availableSegment:I goto :goto_1 .line 114 :cond_2 invoke-virtual {p0}, Lcom/ea/nimble/ByteBufferIOStream;->getOutputStream()Ljava/io/OutputStream; move-result-object v0 invoke-virtual {v0, p1, v1, p2}, Ljava/io/OutputStream;->write([BII)V :goto_1 return-void .end method .method public available()I .locals 1 .annotation system Ldalvik/annotation/Throws; value = { Ljava/io/IOException; } .end annotation iget-object v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_input:Lcom/ea/nimble/ByteBufferIOStream$ByteBufferInputStream; .line 73 invoke-virtual {v0}, Lcom/ea/nimble/ByteBufferIOStream$ByteBufferInputStream;->available()I move-result v0 return v0 .end method .method public clear()V .locals 1 const/4 v0, 0x0 iput-boolean v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_closed:Z iput v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_availableSegment:I iput v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_writePosition:I iput v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_readPosition:I return-void .end method .method public closeIOStream()V .locals 1 const/4 v0, 0x1 iput-boolean v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_closed:Z return-void .end method .method public getInputStream()Ljava/io/InputStream; .locals 1 iget-object v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_input:Lcom/ea/nimble/ByteBufferIOStream$ByteBufferInputStream; return-object v0 .end method .method public getOutputStream()Ljava/io/OutputStream; .locals 1 iget-object v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_output:Lcom/ea/nimble/ByteBufferIOStream$ByteBufferOutputStream; return-object v0 .end method .method public growBufferBySegment()[B .locals 3 .annotation system Ldalvik/annotation/Throws; value = { Ljava/io/IOException; } .end annotation iget v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_writePosition:I if-nez v0, :cond_1 iget-object v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_buffer:Ljava/util/LinkedList; .line 126 invoke-virtual {v0}, Ljava/util/AbstractList;->listIterator()Ljava/util/ListIterator; move-result-object v0 const/4 v1, 0x0 :goto_0 iget v2, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_availableSegment:I if-ge v1, v2, :cond_0 .line 129 invoke-interface {v0}, Ljava/util/ListIterator;->next()Ljava/lang/Object; add-int/lit8 v1, v1, 0x1 goto :goto_0 :cond_0 const/16 v1, 0x1000 new-array v1, v1, [B .line 133 invoke-interface {v0, v1}, Ljava/util/ListIterator;->add(Ljava/lang/Object;)V iget v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_availableSegment:I add-int/lit8 v0, v0, 0x1 iput v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_availableSegment:I return-object v1 .line 123 :cond_1 new-instance v0, Ljava/io/IOException; const-string v1, "Bad location to grow buffer" invoke-direct {v0, v1}, Ljava/io/IOException;->(Ljava/lang/String;)V throw v0 .end method .method public prepareSegment()[B .locals 2 iget v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_availableSegment:I add-int/lit8 v0, v0, 0x1 iget-object v1, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_buffer:Ljava/util/LinkedList; .line 80 invoke-virtual {v1}, Ljava/util/LinkedList;->size()I move-result v1 if-lt v0, v1, :cond_0 const/16 v0, 0x1000 new-array v0, v0, [B return-object v0 :cond_0 iget-object v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_buffer:Ljava/util/LinkedList; .line 86 invoke-virtual {v0}, Ljava/util/LinkedList;->size()I move-result v0 if-nez v0, :cond_1 const/4 v0, 0x0 goto :goto_0 :cond_1 iget-object v0, p0, Lcom/ea/nimble/ByteBufferIOStream;->m_buffer:Ljava/util/LinkedList; invoke-virtual {v0}, Ljava/util/LinkedList;->removeLast()Ljava/lang/Object; move-result-object v0 check-cast v0, [B :goto_0 return-object v0 .end method