/** * ** Gets args as RTProperties instance ** @return A new RTProperties instance with this URIArg's * key value pairs */ public RTProperties getArgProperties() { RTProperties rtp = new RTProperties(); for (Iterator i = this.getKeyValList().iterator(); i.hasNext(); ) { KeyVal kv = (KeyVal) i.next(); rtp.setString(kv.getKey(), this.decodeArg(kv.getValue())); } return rtp; }
/** * ** Returns a new URIArg with this URIArg's arguments encoded into a ** single RTProperties * added with a specified key [CHECK] ** @param rtpKey The key to add the encoded args at * ** @param exclKeys keys to exclude from encoding ** @return A new URIArg with non excluded * arguments encoded */ public URIArg rtpEncode(String rtpKey, String... exclKeys) { URIArg rtpUrl = new URIArg(this.getURI()); RTProperties rtp = new RTProperties(); for (KeyVal kv : this.getKeyValList()) { String kn = kv.getKey(); if (ListTools.contains(exclKeys, kn)) { rtpUrl.addArg(kv); } else { rtp.setString(kn, kv.getValue()); } } rtpUrl.addArg(rtpKey, rtp); return rtpUrl; }
/** * ** Returns a new URIArg with this URIArg's arguments decoded from a ** single RTProperties * added a specified key [CHECK] ** @param rtpKey The key of the RTProperties to decode the * encoded args from ** @return A new URIArg with non excluded arguments encoded */ public URIArg rtpDecode(String rtpKey) { URIArg cpyUrl = new URIArg(this.getURI()); for (KeyVal kv : this.getKeyValList()) { String kn = kv.getKey(); if (!kn.equals(rtpKey)) { cpyUrl.addArg(kv); } else { RTProperties rtp = URIArg.parseRTP(kv.getValue()); for (Object rpk : rtp.getPropertyKeys()) { String rk = rpk.toString(); String rv = rtp.getString(rk, ""); cpyUrl.addArg(rk, rv); } } } return cpyUrl; }
/** * ** Adds an argument to the URI ** @param key The key name of the argument to add ** @param rtp * The RTP encoded values of the new key ** @return This URIArg, with the argument added */ public URIArg addArg(String key, RTProperties rtp) { String r = (rtp != null) ? rtp.toString() : null; if (!StringTools.isBlank(r)) { return this._addArg(key, URIArg.encodeRTP(rtp), false /*encode*/, false /*obfuscate*/); } else { return this.addArg(key, ""); } }
/** ** RTP encodes an argument */ public static String encodeRTP(RTProperties rtp) { if (rtp != null) { return _ens64(rtp.toString()); } return null; }