11package com .api .util .ApiSecurity ;
22import java .util .AbstractMap .SimpleEntry ;
33import java .util .ArrayList ;
4+ import java .util .Arrays ;
5+ import java .util .Collection ;
46import java .util .List ;
57import java .util .Map .Entry ;
68import java .util .stream .Collectors ;
@@ -24,14 +26,22 @@ public String toString(Boolean isBaseString) {
2426 String delimiter = "&" ;
2527 Boolean sort = true ;
2628 Boolean quote = false ;
27-
2829 return this .toString (delimiter , sort , quote , isBaseString );
2930 }
3031
32+ // public String toString(Boolean isBaseString, Boolean sort) {
33+ // String delimiter = "&";
34+ // Boolean quote = false;
35+ //
36+ // return this.toString(delimiter, sort, quote, isBaseString);
37+ // }
38+
3139 public String toString (String delimiter , Boolean sort , Boolean quote , Boolean isBaseString )
3240 {
3341 List <String > list = new ArrayList <String >();
34-
42+ for (Entry <String ,String > ent : this ) {
43+ System .out .println ("ToSTRING entry key:" + ent .getKey () + " val: " + ent .getValue ());
44+ }
3545 final String format = (quote ? "%s=\" %s\" " : "%s=%s" );
3646
3747 /* Sort key first then value*/
@@ -51,4 +61,48 @@ public String toString(String delimiter, Boolean sort, Boolean quote, Boolean is
5161
5262 return String .join (delimiter , list );
5363 }
64+
65+
66+ public FormList toFormList ()
67+ {
68+ FormList formList = new FormList ();
69+
70+ for (Entry <String ,String > item : this )
71+ {
72+ formList .add (item .getKey (), item .getValue ());
73+ System .out .println ("FORMLIST ITEM " + item .getValue () + "} key: {" +item .getKey () );
74+ }
75+ System .out .println ("FORMLIST" );
76+ System .out .println ("FORMLIST " + formList );
77+
78+ return formList ;
79+ }
80+
81+ //toFormList
82+
83+ //backup
84+ // public String toString(String delimiter, Boolean sort, Boolean quote, Boolean isBaseString)
85+ // {
86+ // List<String> list = new ArrayList<String>();
87+ //
88+ // final String format = (quote ? "%s=\"%s\"" : "%s=%s");
89+ //
90+ // /* Sort key first then value*/
91+ // if (sort){
92+ // list = this.stream()
93+ // .sorted((Entry<String,String> l1, Entry<String,String> l2) ->
94+ // {
95+ // return l1.getKey().equals(l2.getKey()) ? l1.getValue().compareTo(l2.getValue())
96+ // : l1.getKey().compareTo(l2.getKey());
97+ // })
98+ // .map(e -> (null== e.getValue() || (null!= e.getValue() && e.getValue().isEmpty()) && isBaseString) ? e.getKey() : String.format(format, e.getKey(), e.getValue()) )
99+ // .collect(Collectors.toList());
100+ // } else{
101+ // list = this.stream().map(e -> String.format(format, e.getKey(), e.getValue()))
102+ // .collect(Collectors.toList());
103+ // }
104+ //
105+ // return String.join(delimiter, list);
106+ // }
107+
54108}
0 commit comments