MultipartBody$Builder.smali 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. .class public final Lokhttp3/MultipartBody$Builder;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/EnclosingClass;
  6. value = Lokhttp3/MultipartBody;
  7. .end annotation
  8. .annotation system Ldalvik/annotation/InnerClass;
  9. accessFlags = 0x19
  10. name = "Builder"
  11. .end annotation
  12. # instance fields
  13. .field private final boundary:Lokio/ByteString;
  14. .field private final parts:Ljava/util/List;
  15. .annotation system Ldalvik/annotation/Signature;
  16. value = {
  17. "Ljava/util/List<",
  18. "Lokhttp3/MultipartBody$Part;",
  19. ">;"
  20. }
  21. .end annotation
  22. .end field
  23. .field private type:Lokhttp3/MediaType;
  24. # direct methods
  25. .method public constructor <init>()V
  26. .locals 1
  27. invoke-static {}, Ljava/util/UUID;->randomUUID()Ljava/util/UUID;
  28. move-result-object v0
  29. invoke-virtual {v0}, Ljava/util/UUID;->toString()Ljava/lang/String;
  30. move-result-object v0
  31. invoke-direct {p0, v0}, Lokhttp3/MultipartBody$Builder;-><init>(Ljava/lang/String;)V
  32. return-void
  33. .end method
  34. .method public constructor <init>(Ljava/lang/String;)V
  35. .locals 1
  36. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  37. sget-object v0, Lokhttp3/MultipartBody;->MIXED:Lokhttp3/MediaType;
  38. iput-object v0, p0, Lokhttp3/MultipartBody$Builder;->type:Lokhttp3/MediaType;
  39. new-instance v0, Ljava/util/ArrayList;
  40. invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
  41. iput-object v0, p0, Lokhttp3/MultipartBody$Builder;->parts:Ljava/util/List;
  42. invoke-static {p1}, Lokio/ByteString;->encodeUtf8(Ljava/lang/String;)Lokio/ByteString;
  43. move-result-object p1
  44. iput-object p1, p0, Lokhttp3/MultipartBody$Builder;->boundary:Lokio/ByteString;
  45. return-void
  46. .end method
  47. # virtual methods
  48. .method public addFormDataPart(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/MultipartBody$Builder;
  49. .locals 0
  50. invoke-static {p1, p2}, Lokhttp3/MultipartBody$Part;->createFormData(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/MultipartBody$Part;
  51. move-result-object p1
  52. invoke-virtual {p0, p1}, Lokhttp3/MultipartBody$Builder;->addPart(Lokhttp3/MultipartBody$Part;)Lokhttp3/MultipartBody$Builder;
  53. move-result-object p1
  54. return-object p1
  55. .end method
  56. .method public addFormDataPart(Ljava/lang/String;Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Builder;
  57. .locals 0
  58. invoke-static {p1, p2, p3}, Lokhttp3/MultipartBody$Part;->createFormData(Ljava/lang/String;Ljava/lang/String;Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Part;
  59. move-result-object p1
  60. invoke-virtual {p0, p1}, Lokhttp3/MultipartBody$Builder;->addPart(Lokhttp3/MultipartBody$Part;)Lokhttp3/MultipartBody$Builder;
  61. move-result-object p1
  62. return-object p1
  63. .end method
  64. .method public addPart(Lokhttp3/Headers;Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Builder;
  65. .locals 0
  66. invoke-static {p1, p2}, Lokhttp3/MultipartBody$Part;->create(Lokhttp3/Headers;Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Part;
  67. move-result-object p1
  68. invoke-virtual {p0, p1}, Lokhttp3/MultipartBody$Builder;->addPart(Lokhttp3/MultipartBody$Part;)Lokhttp3/MultipartBody$Builder;
  69. move-result-object p1
  70. return-object p1
  71. .end method
  72. .method public addPart(Lokhttp3/MultipartBody$Part;)Lokhttp3/MultipartBody$Builder;
  73. .locals 1
  74. if-eqz p1, :cond_0
  75. iget-object v0, p0, Lokhttp3/MultipartBody$Builder;->parts:Ljava/util/List;
  76. invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  77. return-object p0
  78. :cond_0
  79. new-instance p1, Ljava/lang/NullPointerException;
  80. const-string v0, "part == null"
  81. invoke-direct {p1, v0}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  82. throw p1
  83. .end method
  84. .method public addPart(Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Builder;
  85. .locals 0
  86. invoke-static {p1}, Lokhttp3/MultipartBody$Part;->create(Lokhttp3/RequestBody;)Lokhttp3/MultipartBody$Part;
  87. move-result-object p1
  88. invoke-virtual {p0, p1}, Lokhttp3/MultipartBody$Builder;->addPart(Lokhttp3/MultipartBody$Part;)Lokhttp3/MultipartBody$Builder;
  89. move-result-object p1
  90. return-object p1
  91. .end method
  92. .method public build()Lokhttp3/MultipartBody;
  93. .locals 4
  94. iget-object v0, p0, Lokhttp3/MultipartBody$Builder;->parts:Ljava/util/List;
  95. invoke-interface {v0}, Ljava/util/List;->isEmpty()Z
  96. move-result v0
  97. if-nez v0, :cond_0
  98. new-instance v0, Lokhttp3/MultipartBody;
  99. iget-object v1, p0, Lokhttp3/MultipartBody$Builder;->boundary:Lokio/ByteString;
  100. iget-object v2, p0, Lokhttp3/MultipartBody$Builder;->type:Lokhttp3/MediaType;
  101. iget-object v3, p0, Lokhttp3/MultipartBody$Builder;->parts:Ljava/util/List;
  102. invoke-direct {v0, v1, v2, v3}, Lokhttp3/MultipartBody;-><init>(Lokio/ByteString;Lokhttp3/MediaType;Ljava/util/List;)V
  103. return-object v0
  104. :cond_0
  105. new-instance v0, Ljava/lang/IllegalStateException;
  106. const-string v1, "Multipart body must have at least one part."
  107. invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  108. throw v0
  109. .end method
  110. .method public setType(Lokhttp3/MediaType;)Lokhttp3/MultipartBody$Builder;
  111. .locals 3
  112. if-eqz p1, :cond_1
  113. invoke-virtual {p1}, Lokhttp3/MediaType;->type()Ljava/lang/String;
  114. move-result-object v0
  115. const-string v1, "multipart"
  116. invoke-virtual {v0, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  117. move-result v0
  118. if-eqz v0, :cond_0
  119. iput-object p1, p0, Lokhttp3/MultipartBody$Builder;->type:Lokhttp3/MediaType;
  120. return-object p0
  121. :cond_0
  122. new-instance v0, Ljava/lang/IllegalArgumentException;
  123. new-instance v1, Ljava/lang/StringBuilder;
  124. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  125. const-string v2, "multipart != "
  126. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  127. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  128. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  129. move-result-object p1
  130. invoke-direct {v0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  131. throw v0
  132. :cond_1
  133. new-instance p1, Ljava/lang/NullPointerException;
  134. const-string v0, "type == null"
  135. invoke-direct {p1, v0}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  136. throw p1
  137. .end method