Skip to content

Commit b980995

Browse files
committed
Update RequestParams.java
Changed ConcurrentHashMap to ConcurrentSkipHashMap for sorting feature
1 parent f53deef commit b980995

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

library/src/main/java/com/loopj/android/http/RequestParams.java

+19-19
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import java.util.Locale;
3434
import java.util.Map;
3535
import java.util.Set;
36-
import java.util.concurrent.ConcurrentHashMap;
36+
import java.util.concurrent.ConcurrentSkipHashMap;
3737

3838
import cz.msebera.android.httpclient.HttpEntity;
3939
import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity;
@@ -99,11 +99,11 @@ public class RequestParams implements Serializable {
9999
"application/json";
100100

101101
protected final static String LOG_TAG = "RequestParams";
102-
protected final ConcurrentHashMap<String, String> urlParams = new ConcurrentHashMap<String, String>();
103-
protected final ConcurrentHashMap<String, StreamWrapper> streamParams = new ConcurrentHashMap<String, StreamWrapper>();
104-
protected final ConcurrentHashMap<String, FileWrapper> fileParams = new ConcurrentHashMap<String, FileWrapper>();
105-
protected final ConcurrentHashMap<String, List<FileWrapper>> fileArrayParams = new ConcurrentHashMap<String, List<FileWrapper>>();
106-
protected final ConcurrentHashMap<String, Object> urlParamsWithObjects = new ConcurrentHashMap<String, Object>();
102+
protected final ConcurrentSkipHashMap<String, String> urlParams = new ConcurrentSkipHashMap<String, String>();
103+
protected final ConcurrentSkipHashMap<String, StreamWrapper> streamParams = new ConcurrentSkipHashMap<String, StreamWrapper>();
104+
protected final ConcurrentSkipHashMap<String, FileWrapper> fileParams = new ConcurrentSkipHashMap<String, FileWrapper>();
105+
protected final ConcurrentSkipHashMap<String, List<FileWrapper>> fileArrayParams = new ConcurrentSkipHashMap<String, List<FileWrapper>>();
106+
protected final ConcurrentSkipHashMap<String, Object> urlParamsWithObjects = new ConcurrentSkipHashMap<String, Object>();
107107
protected boolean isRepeatable;
108108
protected boolean forceMultipartEntity = false;
109109
protected boolean useJsonStreamer;
@@ -425,7 +425,7 @@ public boolean has(String key) {
425425
@Override
426426
public String toString() {
427427
StringBuilder result = new StringBuilder();
428-
for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
428+
for (ConcurrentSkipHashMap.Entry<String, String> entry : urlParams.entrySet()) {
429429
if (result.length() > 0)
430430
result.append("&");
431431

@@ -434,7 +434,7 @@ public String toString() {
434434
result.append(entry.getValue());
435435
}
436436

437-
for (ConcurrentHashMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
437+
for (ConcurrentSkipHashMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
438438
if (result.length() > 0)
439439
result.append("&");
440440

@@ -443,7 +443,7 @@ public String toString() {
443443
result.append("STREAM");
444444
}
445445

446-
for (ConcurrentHashMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
446+
for (ConcurrentSkipHashMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
447447
if (result.length() > 0)
448448
result.append("&");
449449

@@ -452,7 +452,7 @@ public String toString() {
452452
result.append("FILE");
453453
}
454454

455-
for (ConcurrentHashMap.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
455+
for (ConcurrentSkipHashMap.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
456456
if (result.length() > 0)
457457
result.append("&");
458458

@@ -530,22 +530,22 @@ private HttpEntity createJsonStreamerEntity(ResponseHandlerInterface progressHan
530530
elapsedFieldInJsonStreamer);
531531

532532
// Add string params
533-
for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
533+
for (ConcurrentSkipHashMap.Entry<String, String> entry : urlParams.entrySet()) {
534534
entity.addPart(entry.getKey(), entry.getValue());
535535
}
536536

537537
// Add non-string params
538-
for (ConcurrentHashMap.Entry<String, Object> entry : urlParamsWithObjects.entrySet()) {
538+
for (ConcurrentSkipHashMap.Entry<String, Object> entry : urlParamsWithObjects.entrySet()) {
539539
entity.addPart(entry.getKey(), entry.getValue());
540540
}
541541

542542
// Add file params
543-
for (ConcurrentHashMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
543+
for (ConcurrentSkipHashMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
544544
entity.addPart(entry.getKey(), entry.getValue());
545545
}
546546

547547
// Add stream params
548-
for (ConcurrentHashMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
548+
for (ConcurrentSkipHashMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
549549
StreamWrapper stream = entry.getValue();
550550
if (stream.inputStream != null) {
551551
entity.addPart(entry.getKey(),
@@ -575,7 +575,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
575575
entity.setIsRepeatable(isRepeatable);
576576

577577
// Add string params
578-
for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
578+
for (ConcurrentSkipHashMap.Entry<String, String> entry : urlParams.entrySet()) {
579579
entity.addPartWithCharset(entry.getKey(), entry.getValue(), contentEncoding);
580580
}
581581

@@ -586,7 +586,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
586586
}
587587

588588
// Add stream params
589-
for (ConcurrentHashMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
589+
for (ConcurrentSkipHashMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
590590
StreamWrapper stream = entry.getValue();
591591
if (stream.inputStream != null) {
592592
entity.addPart(entry.getKey(), stream.name, stream.inputStream,
@@ -595,13 +595,13 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
595595
}
596596

597597
// Add file params
598-
for (ConcurrentHashMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
598+
for (ConcurrentSkipHashMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
599599
FileWrapper fileWrapper = entry.getValue();
600600
entity.addPart(entry.getKey(), fileWrapper.file, fileWrapper.contentType, fileWrapper.customFileName);
601601
}
602602

603603
// Add file collection
604-
for (ConcurrentHashMap.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
604+
for (ConcurrentSkipHashMap.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
605605
List<FileWrapper> fileWrapper = entry.getValue();
606606
for (FileWrapper fw : fileWrapper) {
607607
entity.addPart(entry.getKey(), fw.file, fw.contentType, fw.customFileName);
@@ -614,7 +614,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
614614
protected List<BasicNameValuePair> getParamsList() {
615615
List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>();
616616

617-
for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
617+
for (ConcurrentSkipHashMap.Entry<String, String> entry : urlParams.entrySet()) {
618618
lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
619619
}
620620

0 commit comments

Comments
 (0)