Skip to content

Commit e85590a

Browse files
committed
LIBff21121: Changed ConcurrentHashMap to ConcurrentSkipListMap for sorting feature
1 parent d12beff commit e85590a

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import java.util.Locale;
3232
import java.util.Map;
3333
import java.util.Set;
34-
import java.util.concurrent.ConcurrentHashMap;
34+
import java.util.concurrent.ConcurrentSkipListMap;
3535

3636
import cz.msebera.android.httpclient.HttpEntity;
3737
import cz.msebera.android.httpclient.client.entity.UrlEncodedFormEntity;
@@ -97,11 +97,11 @@ public class RequestParams implements Serializable {
9797
"application/json";
9898

9999
protected final static String LOG_TAG = "RequestParams";
100-
protected final ConcurrentHashMap<String, String> urlParams = new ConcurrentHashMap<String, String>();
101-
protected final ConcurrentHashMap<String, StreamWrapper> streamParams = new ConcurrentHashMap<String, StreamWrapper>();
102-
protected final ConcurrentHashMap<String, FileWrapper> fileParams = new ConcurrentHashMap<String, FileWrapper>();
103-
protected final ConcurrentHashMap<String, List<FileWrapper>> fileArrayParams = new ConcurrentHashMap<String, List<FileWrapper>>();
104-
protected final ConcurrentHashMap<String, Object> urlParamsWithObjects = new ConcurrentHashMap<String, Object>();
100+
protected final ConcurrentSkipListMap<String, String> urlParams = new ConcurrentSkipListMap<String, String>();
101+
protected final ConcurrentSkipListMap<String, StreamWrapper> streamParams = new ConcurrentSkipListMap<String, StreamWrapper>();
102+
protected final ConcurrentSkipListMap<String, FileWrapper> fileParams = new ConcurrentSkipListMap<String, FileWrapper>();
103+
protected final ConcurrentSkipListMap<String, List<FileWrapper>> fileArrayParams = new ConcurrentSkipListMap<String, List<FileWrapper>>();
104+
protected final ConcurrentSkipListMap<String, Object> urlParamsWithObjects = new ConcurrentSkipListMap<String, Object>();
105105
protected boolean isRepeatable;
106106
protected boolean forceMultipartEntity = false;
107107
protected boolean useJsonStreamer;
@@ -423,7 +423,7 @@ public boolean has(String key) {
423423
@Override
424424
public String toString() {
425425
StringBuilder result = new StringBuilder();
426-
for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
426+
for (ConcurrentSkipListMap.Entry<String, String> entry : urlParams.entrySet()) {
427427
if (result.length() > 0)
428428
result.append("&");
429429

@@ -432,7 +432,7 @@ public String toString() {
432432
result.append(entry.getValue());
433433
}
434434

435-
for (ConcurrentHashMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
435+
for (ConcurrentSkipListMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
436436
if (result.length() > 0)
437437
result.append("&");
438438

@@ -441,7 +441,7 @@ public String toString() {
441441
result.append("STREAM");
442442
}
443443

444-
for (ConcurrentHashMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
444+
for (ConcurrentSkipListMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
445445
if (result.length() > 0)
446446
result.append("&");
447447

@@ -450,7 +450,7 @@ public String toString() {
450450
result.append("FILE");
451451
}
452452

453-
for (ConcurrentHashMap.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
453+
for (ConcurrentSkipListMap.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
454454
if (result.length() > 0)
455455
result.append("&");
456456

@@ -528,22 +528,22 @@ private HttpEntity createJsonStreamerEntity(ResponseHandlerInterface progressHan
528528
elapsedFieldInJsonStreamer);
529529

530530
// Add string params
531-
for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
531+
for (ConcurrentSkipListMap.Entry<String, String> entry : urlParams.entrySet()) {
532532
entity.addPart(entry.getKey(), entry.getValue());
533533
}
534534

535535
// Add non-string params
536-
for (ConcurrentHashMap.Entry<String, Object> entry : urlParamsWithObjects.entrySet()) {
536+
for (ConcurrentSkipListMap.Entry<String, Object> entry : urlParamsWithObjects.entrySet()) {
537537
entity.addPart(entry.getKey(), entry.getValue());
538538
}
539539

540540
// Add file params
541-
for (ConcurrentHashMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
541+
for (ConcurrentSkipListMap.Entry<String, FileWrapper> entry : fileParams.entrySet()) {
542542
entity.addPart(entry.getKey(), entry.getValue());
543543
}
544544

545545
// Add stream params
546-
for (ConcurrentHashMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
546+
for (ConcurrentSkipListMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
547547
StreamWrapper stream = entry.getValue();
548548
if (stream.inputStream != null) {
549549
entity.addPart(entry.getKey(),
@@ -573,7 +573,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
573573
entity.setIsRepeatable(isRepeatable);
574574

575575
// Add string params
576-
for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
576+
for (ConcurrentSkipListMap.Entry<String, String> entry : urlParams.entrySet()) {
577577
entity.addPartWithCharset(entry.getKey(), entry.getValue(), contentEncoding);
578578
}
579579

@@ -584,7 +584,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
584584
}
585585

586586
// Add stream params
587-
for (ConcurrentHashMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
587+
for (ConcurrentSkipListMap.Entry<String, StreamWrapper> entry : streamParams.entrySet()) {
588588
StreamWrapper stream = entry.getValue();
589589
if (stream.inputStream != null) {
590590
entity.addPart(entry.getKey(), stream.name, stream.inputStream,
@@ -593,13 +593,13 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
593593
}
594594

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

601601
// Add file collection
602-
for (ConcurrentHashMap.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
602+
for (ConcurrentSkipListMap.Entry<String, List<FileWrapper>> entry : fileArrayParams.entrySet()) {
603603
List<FileWrapper> fileWrapper = entry.getValue();
604604
for (FileWrapper fw : fileWrapper) {
605605
entity.addPart(entry.getKey(), fw.file, fw.contentType, fw.customFileName);
@@ -612,7 +612,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
612612
protected List<BasicNameValuePair> getParamsList() {
613613
List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>();
614614

615-
for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
615+
for (ConcurrentSkipListMap.Entry<String, String> entry : urlParams.entrySet()) {
616616
lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
617617
}
618618

0 commit comments

Comments
 (0)