Headers$Builder.smali 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. .class public final Lokhttp3/Headers$Builder;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/EnclosingClass;
  6. value = Lokhttp3/Headers;
  7. .end annotation
  8. .annotation system Ldalvik/annotation/InnerClass;
  9. accessFlags = 0x19
  10. name = "Builder"
  11. .end annotation
  12. # instance fields
  13. .field final namesAndValues:Ljava/util/List;
  14. .annotation system Ldalvik/annotation/Signature;
  15. value = {
  16. "Ljava/util/List<",
  17. "Ljava/lang/String;",
  18. ">;"
  19. }
  20. .end annotation
  21. .end field
  22. # direct methods
  23. .method public constructor <init>()V
  24. .locals 2
  25. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  26. new-instance v0, Ljava/util/ArrayList;
  27. const/16 v1, 0x14
  28. invoke-direct {v0, v1}, Ljava/util/ArrayList;-><init>(I)V
  29. iput-object v0, p0, Lokhttp3/Headers$Builder;->namesAndValues:Ljava/util/List;
  30. return-void
  31. .end method
  32. .method private checkNameAndValue(Ljava/lang/String;Ljava/lang/String;)V
  33. .locals 9
  34. if-eqz p1, :cond_7
  35. invoke-virtual {p1}, Ljava/lang/String;->isEmpty()Z
  36. move-result v0
  37. if-nez v0, :cond_6
  38. invoke-virtual {p1}, Ljava/lang/String;->length()I
  39. move-result v0
  40. const/4 v1, 0x0
  41. const/4 v2, 0x0
  42. :goto_0
  43. const/16 v3, 0x7f
  44. const/4 v4, 0x2
  45. const/4 v5, 0x3
  46. const/4 v6, 0x1
  47. if-ge v2, v0, :cond_1
  48. invoke-virtual {p1, v2}, Ljava/lang/String;->charAt(I)C
  49. move-result v7
  50. const/16 v8, 0x20
  51. if-le v7, v8, :cond_0
  52. if-ge v7, v3, :cond_0
  53. add-int/lit8 v2, v2, 0x1
  54. goto :goto_0
  55. :cond_0
  56. new-instance p2, Ljava/lang/IllegalArgumentException;
  57. new-array v0, v5, [Ljava/lang/Object;
  58. invoke-static {v7}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  59. move-result-object v3
  60. aput-object v3, v0, v1
  61. invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  62. move-result-object v1
  63. aput-object v1, v0, v6
  64. aput-object p1, v0, v4
  65. const-string p1, "Unexpected char %#04x at %d in header name: %s"
  66. invoke-static {p1, v0}, Lokhttp3/internal/Util;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
  67. move-result-object p1
  68. invoke-direct {p2, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  69. throw p2
  70. :cond_1
  71. if-eqz p2, :cond_5
  72. invoke-virtual {p2}, Ljava/lang/String;->length()I
  73. move-result v0
  74. const/4 v2, 0x0
  75. :goto_1
  76. if-ge v2, v0, :cond_4
  77. invoke-virtual {p2, v2}, Ljava/lang/String;->charAt(I)C
  78. move-result v7
  79. const/16 v8, 0x1f
  80. if-gt v7, v8, :cond_2
  81. const/16 v8, 0x9
  82. if-ne v7, v8, :cond_3
  83. :cond_2
  84. if-ge v7, v3, :cond_3
  85. add-int/lit8 v2, v2, 0x1
  86. goto :goto_1
  87. :cond_3
  88. new-instance v0, Ljava/lang/IllegalArgumentException;
  89. const/4 v3, 0x4
  90. new-array v3, v3, [Ljava/lang/Object;
  91. invoke-static {v7}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  92. move-result-object v7
  93. aput-object v7, v3, v1
  94. invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
  95. move-result-object v1
  96. aput-object v1, v3, v6
  97. aput-object p1, v3, v4
  98. aput-object p2, v3, v5
  99. const-string p1, "Unexpected char %#04x at %d in %s value: %s"
  100. invoke-static {p1, v3}, Lokhttp3/internal/Util;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
  101. move-result-object p1
  102. invoke-direct {v0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  103. throw v0
  104. :cond_4
  105. return-void
  106. :cond_5
  107. new-instance p2, Ljava/lang/NullPointerException;
  108. new-instance v0, Ljava/lang/StringBuilder;
  109. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  110. const-string v1, "value for name "
  111. invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  112. invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  113. const-string p1, " == null"
  114. invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  115. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  116. move-result-object p1
  117. invoke-direct {p2, p1}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  118. throw p2
  119. :cond_6
  120. new-instance p1, Ljava/lang/IllegalArgumentException;
  121. const-string p2, "name is empty"
  122. invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  123. throw p1
  124. :cond_7
  125. new-instance p1, Ljava/lang/NullPointerException;
  126. const-string p2, "name == null"
  127. invoke-direct {p1, p2}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  128. goto :goto_3
  129. :goto_2
  130. throw p1
  131. :goto_3
  132. goto :goto_2
  133. .end method
  134. # virtual methods
  135. .method public add(Ljava/lang/String;)Lokhttp3/Headers$Builder;
  136. .locals 3
  137. const-string v0, ":"
  138. invoke-virtual {p1, v0}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I
  139. move-result v0
  140. const/4 v1, -0x1
  141. if-eq v0, v1, :cond_0
  142. const/4 v1, 0x0
  143. invoke-virtual {p1, v1, v0}, Ljava/lang/String;->substring(II)Ljava/lang/String;
  144. move-result-object v1
  145. invoke-virtual {v1}, Ljava/lang/String;->trim()Ljava/lang/String;
  146. move-result-object v1
  147. add-int/lit8 v0, v0, 0x1
  148. invoke-virtual {p1, v0}, Ljava/lang/String;->substring(I)Ljava/lang/String;
  149. move-result-object p1
  150. invoke-virtual {p0, v1, p1}, Lokhttp3/Headers$Builder;->add(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
  151. move-result-object p1
  152. return-object p1
  153. :cond_0
  154. new-instance v0, Ljava/lang/IllegalArgumentException;
  155. new-instance v1, Ljava/lang/StringBuilder;
  156. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  157. const-string v2, "Unexpected header: "
  158. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  159. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  160. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  161. move-result-object p1
  162. invoke-direct {v0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  163. throw v0
  164. .end method
  165. .method public add(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
  166. .locals 0
  167. invoke-direct {p0, p1, p2}, Lokhttp3/Headers$Builder;->checkNameAndValue(Ljava/lang/String;Ljava/lang/String;)V
  168. invoke-virtual {p0, p1, p2}, Lokhttp3/Headers$Builder;->addLenient(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
  169. move-result-object p1
  170. return-object p1
  171. .end method
  172. .method addLenient(Ljava/lang/String;)Lokhttp3/Headers$Builder;
  173. .locals 4
  174. const-string v0, ":"
  175. const/4 v1, 0x1
  176. invoke-virtual {p1, v0, v1}, Ljava/lang/String;->indexOf(Ljava/lang/String;I)I
  177. move-result v2
  178. const/4 v3, -0x1
  179. if-eq v2, v3, :cond_0
  180. const/4 v0, 0x0
  181. invoke-virtual {p1, v0, v2}, Ljava/lang/String;->substring(II)Ljava/lang/String;
  182. move-result-object v0
  183. add-int/2addr v2, v1
  184. invoke-virtual {p1, v2}, Ljava/lang/String;->substring(I)Ljava/lang/String;
  185. move-result-object p1
  186. invoke-virtual {p0, v0, p1}, Lokhttp3/Headers$Builder;->addLenient(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
  187. move-result-object p1
  188. return-object p1
  189. :cond_0
  190. invoke-virtual {p1, v0}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z
  191. move-result v0
  192. const-string v2, ""
  193. if-eqz v0, :cond_1
  194. invoke-virtual {p1, v1}, Ljava/lang/String;->substring(I)Ljava/lang/String;
  195. move-result-object p1
  196. invoke-virtual {p0, v2, p1}, Lokhttp3/Headers$Builder;->addLenient(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
  197. move-result-object p1
  198. return-object p1
  199. :cond_1
  200. invoke-virtual {p0, v2, p1}, Lokhttp3/Headers$Builder;->addLenient(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
  201. move-result-object p1
  202. return-object p1
  203. .end method
  204. .method addLenient(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
  205. .locals 1
  206. iget-object v0, p0, Lokhttp3/Headers$Builder;->namesAndValues:Ljava/util/List;
  207. invoke-interface {v0, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  208. iget-object p1, p0, Lokhttp3/Headers$Builder;->namesAndValues:Ljava/util/List;
  209. invoke-virtual {p2}, Ljava/lang/String;->trim()Ljava/lang/String;
  210. move-result-object p2
  211. invoke-interface {p1, p2}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  212. return-object p0
  213. .end method
  214. .method public build()Lokhttp3/Headers;
  215. .locals 1
  216. new-instance v0, Lokhttp3/Headers;
  217. invoke-direct {v0, p0}, Lokhttp3/Headers;-><init>(Lokhttp3/Headers$Builder;)V
  218. return-object v0
  219. .end method
  220. .method public get(Ljava/lang/String;)Ljava/lang/String;
  221. .locals 2
  222. iget-object v0, p0, Lokhttp3/Headers$Builder;->namesAndValues:Ljava/util/List;
  223. invoke-interface {v0}, Ljava/util/List;->size()I
  224. move-result v0
  225. add-int/lit8 v0, v0, -0x2
  226. :goto_0
  227. if-ltz v0, :cond_1
  228. iget-object v1, p0, Lokhttp3/Headers$Builder;->namesAndValues:Ljava/util/List;
  229. invoke-interface {v1, v0}, Ljava/util/List;->get(I)Ljava/lang/Object;
  230. move-result-object v1
  231. check-cast v1, Ljava/lang/String;
  232. invoke-virtual {p1, v1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
  233. move-result v1
  234. if-eqz v1, :cond_0
  235. iget-object p1, p0, Lokhttp3/Headers$Builder;->namesAndValues:Ljava/util/List;
  236. add-int/lit8 v0, v0, 0x1
  237. invoke-interface {p1, v0}, Ljava/util/List;->get(I)Ljava/lang/Object;
  238. move-result-object p1
  239. check-cast p1, Ljava/lang/String;
  240. return-object p1
  241. :cond_0
  242. add-int/lit8 v0, v0, -0x2
  243. goto :goto_0
  244. :cond_1
  245. const/4 p1, 0x0
  246. return-object p1
  247. .end method
  248. .method public removeAll(Ljava/lang/String;)Lokhttp3/Headers$Builder;
  249. .locals 2
  250. const/4 v0, 0x0
  251. :goto_0
  252. iget-object v1, p0, Lokhttp3/Headers$Builder;->namesAndValues:Ljava/util/List;
  253. invoke-interface {v1}, Ljava/util/List;->size()I
  254. move-result v1
  255. if-ge v0, v1, :cond_1
  256. iget-object v1, p0, Lokhttp3/Headers$Builder;->namesAndValues:Ljava/util/List;
  257. invoke-interface {v1, v0}, Ljava/util/List;->get(I)Ljava/lang/Object;
  258. move-result-object v1
  259. check-cast v1, Ljava/lang/String;
  260. invoke-virtual {p1, v1}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
  261. move-result v1
  262. if-eqz v1, :cond_0
  263. iget-object v1, p0, Lokhttp3/Headers$Builder;->namesAndValues:Ljava/util/List;
  264. invoke-interface {v1, v0}, Ljava/util/List;->remove(I)Ljava/lang/Object;
  265. iget-object v1, p0, Lokhttp3/Headers$Builder;->namesAndValues:Ljava/util/List;
  266. invoke-interface {v1, v0}, Ljava/util/List;->remove(I)Ljava/lang/Object;
  267. add-int/lit8 v0, v0, -0x2
  268. :cond_0
  269. add-int/lit8 v0, v0, 0x2
  270. goto :goto_0
  271. :cond_1
  272. return-object p0
  273. .end method
  274. .method public set(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
  275. .locals 0
  276. invoke-direct {p0, p1, p2}, Lokhttp3/Headers$Builder;->checkNameAndValue(Ljava/lang/String;Ljava/lang/String;)V
  277. invoke-virtual {p0, p1}, Lokhttp3/Headers$Builder;->removeAll(Ljava/lang/String;)Lokhttp3/Headers$Builder;
  278. invoke-virtual {p0, p1, p2}, Lokhttp3/Headers$Builder;->addLenient(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Headers$Builder;
  279. return-object p0
  280. .end method