28import java.net.URISyntaxException;
29import java.util.HashMap;
30import java.util.Iterator;
32import java.util.Map.Entry;
50 private static final String QMARK =
"?";
51 private static final char ASSIG =
'=';
52 private static final String EMPTY =
"";
53 private final String query_separator;
55 private final HashMap<String, String> properties =
new HashMap<String, String>();
58 query_separator = String.valueOf(querySeparator);
65 boolean needsSep =
false;
66 final StringBuilder sb =
new StringBuilder();
67 if (
null != baseQuery ) {
68 if( baseQuery.startsWith(QMARK) ) {
69 baseQuery = baseQuery.substring(1);
71 sb.append(baseQuery.get());
72 if( !baseQuery.endsWith(query_separator) ) {
76 final Iterator<Entry<String, String>> entries = properties.entrySet().iterator();
77 while(entries.hasNext()) {
79 sb.append(query_separator);
81 final Entry<String, String> entry = entries.next();
82 sb.append(entry.getKey());
83 if( EMPTY != entry.getValue() ) {
84 sb.append(ASSIG).append(entry.getValue());
103 if(
';' != querySeparator &&
'&' != querySeparator ) {
104 throw new IllegalArgumentException(
"querySeparator is invalid: "+querySeparator);
108 final int q_l =
null != q ? q.length() : -1;
111 final int q_b = q_e + 1;
112 q_e = q.indexOf(querySeparator, q_b);
122 final String part = q.substring(q_b, q_e);
123 final int assignment = part.indexOf(ASSIG);
126 final String k = part.substring(0, assignment);
127 final String v = part.substring(assignment+1);
128 data.properties.put(k, v);
131 data.properties.put(part, EMPTY);
Helper class to process URI's query, handled as properties.
static final UriQueryProps create(final Uri uri, final char querySeparator)
final Uri.Encoded appendQuery(Uri.Encoded baseQuery)
final Uri appendQuery(final Uri base)
final char getQuerySeparator()
final Map< String, String > getProperties()
Immutable RFC3986 encoded string.
This class implements an immutable Uri as defined by RFC 2396.
static String decode(final Encoded encoded)
Safe Encoded#decode() call on optional encoded instance.
static final String QUERY_LEGAL
Valid charset for RFC 2396 query, additional to legal alphanum characters.
final Uri getNewQuery(final Encoded newQuery)
Returns a new Uri instance w/ the given new query newQuery.