Okio$1.smali 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. .class final Lokio/Okio$1;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # interfaces
  5. .implements Lokio/Sink;
  6. # annotations
  7. .annotation system Ldalvik/annotation/EnclosingMethod;
  8. value = Lokio/Okio;->sink(Ljava/io/OutputStream;Lokio/Timeout;)Lokio/Sink;
  9. .end annotation
  10. .annotation system Ldalvik/annotation/InnerClass;
  11. accessFlags = 0x0
  12. name = null
  13. .end annotation
  14. # instance fields
  15. .field final synthetic val$out:Ljava/io/OutputStream;
  16. .field final synthetic val$timeout:Lokio/Timeout;
  17. # direct methods
  18. .method constructor <init>(Lokio/Timeout;Ljava/io/OutputStream;)V
  19. .locals 0
  20. iput-object p1, p0, Lokio/Okio$1;->val$timeout:Lokio/Timeout;
  21. iput-object p2, p0, Lokio/Okio$1;->val$out:Ljava/io/OutputStream;
  22. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  23. return-void
  24. .end method
  25. # virtual methods
  26. .method public close()V
  27. .locals 1
  28. .annotation system Ldalvik/annotation/Throws;
  29. value = {
  30. Ljava/io/IOException;
  31. }
  32. .end annotation
  33. iget-object v0, p0, Lokio/Okio$1;->val$out:Ljava/io/OutputStream;
  34. invoke-virtual {v0}, Ljava/io/OutputStream;->close()V
  35. return-void
  36. .end method
  37. .method public flush()V
  38. .locals 1
  39. .annotation system Ldalvik/annotation/Throws;
  40. value = {
  41. Ljava/io/IOException;
  42. }
  43. .end annotation
  44. iget-object v0, p0, Lokio/Okio$1;->val$out:Ljava/io/OutputStream;
  45. invoke-virtual {v0}, Ljava/io/OutputStream;->flush()V
  46. return-void
  47. .end method
  48. .method public timeout()Lokio/Timeout;
  49. .locals 1
  50. iget-object v0, p0, Lokio/Okio$1;->val$timeout:Lokio/Timeout;
  51. return-object v0
  52. .end method
  53. .method public toString()Ljava/lang/String;
  54. .locals 2
  55. new-instance v0, Ljava/lang/StringBuilder;
  56. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  57. const-string v1, "sink("
  58. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  59. iget-object v1, p0, Lokio/Okio$1;->val$out:Ljava/io/OutputStream;
  60. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  61. const-string v1, ")"
  62. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  63. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  64. move-result-object v0
  65. return-object v0
  66. .end method
  67. .method public write(Lokio/Buffer;J)V
  68. .locals 6
  69. .annotation system Ldalvik/annotation/Throws;
  70. value = {
  71. Ljava/io/IOException;
  72. }
  73. .end annotation
  74. iget-wide v0, p1, Lokio/Buffer;->size:J
  75. const-wide/16 v2, 0x0
  76. move-wide v4, p2
  77. invoke-static/range {v0 .. v5}, Lokio/Util;->checkOffsetAndCount(JJJ)V
  78. :cond_0
  79. :goto_0
  80. const-wide/16 v0, 0x0
  81. cmp-long v2, p2, v0
  82. if-lez v2, :cond_1
  83. iget-object v0, p0, Lokio/Okio$1;->val$timeout:Lokio/Timeout;
  84. invoke-virtual {v0}, Lokio/Timeout;->throwIfReached()V
  85. iget-object v0, p1, Lokio/Buffer;->head:Lokio/Segment;
  86. iget v1, v0, Lokio/Segment;->limit:I
  87. iget v2, v0, Lokio/Segment;->pos:I
  88. sub-int/2addr v1, v2
  89. int-to-long v1, v1
  90. invoke-static {p2, p3, v1, v2}, Ljava/lang/Math;->min(JJ)J
  91. move-result-wide v1
  92. long-to-int v2, v1
  93. iget-object v1, p0, Lokio/Okio$1;->val$out:Ljava/io/OutputStream;
  94. iget-object v3, v0, Lokio/Segment;->data:[B
  95. iget v4, v0, Lokio/Segment;->pos:I
  96. invoke-virtual {v1, v3, v4, v2}, Ljava/io/OutputStream;->write([BII)V
  97. iget v1, v0, Lokio/Segment;->pos:I
  98. add-int/2addr v1, v2
  99. iput v1, v0, Lokio/Segment;->pos:I
  100. int-to-long v1, v2
  101. sub-long/2addr p2, v1
  102. iget-wide v3, p1, Lokio/Buffer;->size:J
  103. sub-long/2addr v3, v1
  104. iput-wide v3, p1, Lokio/Buffer;->size:J
  105. iget v1, v0, Lokio/Segment;->pos:I
  106. iget v2, v0, Lokio/Segment;->limit:I
  107. if-ne v1, v2, :cond_0
  108. invoke-virtual {v0}, Lokio/Segment;->pop()Lokio/Segment;
  109. move-result-object v1
  110. iput-object v1, p1, Lokio/Buffer;->head:Lokio/Segment;
  111. invoke-static {v0}, Lokio/SegmentPool;->recycle(Lokio/Segment;)V
  112. goto :goto_0
  113. :cond_1
  114. return-void
  115. .end method