Exemplo n.º 1
0
 /**
  * ** Gets a list of all the argument key names ** @return a list of all the argument key names
  */
 public java.util.List<String> getArgNames() {
   java.util.List<String> knList = new Vector<String>();
   for (KeyVal kv : this.getKeyValList()) {
     knList.add(kv.getKey());
   }
   return knList;
 }
Exemplo n.º 2
0
 /**
  * ** 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;
 }
Exemplo n.º 3
0
 /** ** Removes all arguments which have blank values ** @return This URIArg */
 public URIArg removeBlankValues() {
   for (Iterator<KeyVal> i = this.getKeyValList().iterator(); i.hasNext(); ) {
     KeyVal kv = i.next();
     if (!kv.hasValue()) {
       i.remove();
     }
   }
   return this;
 }
Exemplo n.º 4
0
 /**
  * ** If the specified argument exists, set the specified value and return true ** @param key The
  * key of the agrument ** @param value The value to set ** @param obfuscate True if the value
  * should be obfuscated ** @return True if the argument existed, else false
  */
 public boolean setArgValue(String key, String value, boolean obfuscate) {
   if (key != null) {
     KeyVal kv = this.getKeyVal(key);
     if (kv != null) {
       kv.setValue(this.encodeArg(value, obfuscate));
       return true;
     }
   }
   return false;
 }
Exemplo n.º 5
0
 /**
  * ** Removes all occurances of the specified key from the URI ** @param key The key to remove
  * ** @return This URIArg, with the argument added
  */
 public URIArg removeArg(String key) {
   if (key != null) {
     for (Iterator<KeyVal> i = this.getKeyValList().iterator(); i.hasNext(); ) {
       KeyVal kv = i.next();
       if (kv.getKey().equals(key)) {
         i.remove();
       }
     }
   }
   return this;
 }
Exemplo n.º 6
0
 /**
  * ** Gets an <code>OrderedMap</code> of the argument key/value pairs indexed ** by their keys
  * ** @return An <code>OrderedMap</code> of the argument key/value pairs
  */
 protected OrderedMap<String, KeyVal> getKeyValMap() {
   OrderedMap<String, KeyVal> kvMap = new OrderedMap<String, KeyVal>();
   for (KeyVal kv : this.getKeyValList()) {
     // only the first occurance is retained
     String kn = kv.getKey();
     if (!kvMap.containsKey(kn)) {
       kvMap.put(kn, kv);
     }
   }
   return kvMap;
 }
Exemplo n.º 7
0
 /**
  * ** Returns a String representation of all key/values ** @param sbuff The StringBuffer to write
  * the key/values to, or null ** for a new one ** @return A String representation of all
  * key/values
  */
 public StringBuffer getArgString(StringBuffer sbuff) {
   StringBuffer sb = (sbuff != null) ? sbuff : new StringBuffer();
   for (Iterator i = this.getKeyValList().iterator(); i.hasNext(); ) {
     KeyVal kv = (KeyVal) i.next();
     sb.append(kv.toString());
     if (i.hasNext()) {
       sb.append("&");
     }
   }
   return sb;
 }
Exemplo n.º 8
0
 /**
  * ** Gets the first occuring KeyVal of the specified key ** @param key The key to get ** @return
  * The KeyVal associated with <code>key</code>, if any
  */
 protected KeyVal getKeyVal(String key) {
   if (key != null) {
     Collection<KeyVal> kvList = this.getKeyValList();
     for (KeyVal kv : kvList) {
       if (kv.getKey().equals(key)) {
         return kv;
       }
     }
     return null;
   } else {
     return null;
   }
 }
Exemplo n.º 9
0
 /**
  * ** 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;
 }
Exemplo n.º 10
0
 /**
  * ** Returns a String representation of all key/values ** @param sbuff The StringBuffer to write
  * the key/values to, or null for a new one ** @param includeBlankValues True to include keys for
  * blank values. ** @return A String representation of all key/values
  */
 public StringBuffer getArgString(StringBuffer sbuff, boolean includeBlankValues) {
   StringBuffer sb = (sbuff != null) ? sbuff : new StringBuffer();
   int argCnt = 0;
   for (Iterator i = this.getKeyValList().iterator(); i.hasNext(); ) {
     KeyVal kv = (KeyVal) i.next();
     if (includeBlankValues || kv.hasValue()) {
       if (argCnt > 0) {
         sb.append("&");
       }
       sb.append(kv.toString());
       argCnt++;
     }
   }
   return sb;
 }
Exemplo n.º 11
0
 /**
  * ** 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;
 }
Exemplo n.º 12
0
 public KeyVal(KeyVal kv) {
   this.key = (kv != null) ? kv.getKey() : "";
   this.val = (kv != null) ? kv.getValue() : "";
 }
Exemplo n.º 13
0
 /**
  * ** Gets the first occuring value of the specified key ** @param keys The key list used to check
  * for the returned value ** @return The value associated with <code>key</code>, if any
  */
 public String getArgValue(String keys[]) {
   KeyVal kv = this.getKeyVal(keys);
   return (kv != null) ? kv.getValue() : null;
 }