コード例 #1
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** 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;
 }
コード例 #2
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** 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;
 }
コード例 #3
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /** ** 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;
 }
コード例 #4
0
ファイル: URIArg.java プロジェクト: colima/OpenDMTP
 /**
  * ** 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;
 }
コード例 #5
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** 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;
 }
コード例 #6
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** 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;
 }
コード例 #7
0
ファイル: URIArg.java プロジェクト: colima/OpenDMTP
 /**
  * ** 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;
 }
コード例 #8
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** 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;
   }
 }
コード例 #9
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** 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;
 }
コード例 #10
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** 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;
 }
コード例 #11
0
 public Connection data(Map<String, String> data) {
   Validate.notNull(data, "Data map must not be null");
   for (Map.Entry<String, String> entry : data.entrySet()) {
     req.data(KeyVal.create(entry.getKey(), entry.getValue()));
   }
   return this;
 }
コード例 #12
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** 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;
 }
コード例 #13
0
 public Connection data(String... keyvals) {
   Validate.notNull(keyvals, "Data key value pairs must not be null");
   Validate.isTrue(keyvals.length % 2 == 0, "Must supply an even number of key value pairs");
   for (int i = 0; i < keyvals.length; i += 2) {
     String key = keyvals[i];
     String value = keyvals[i + 1];
     Validate.notEmpty(key, "Data key must not be empty");
     Validate.notNull(value, "Data value must not be null");
     req.data(KeyVal.create(key, value));
   }
   return this;
 }
コード例 #14
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 public KeyVal(KeyVal kv) {
   this.key = (kv != null) ? kv.getKey() : "";
   this.val = (kv != null) ? kv.getValue() : "";
 }
コード例 #15
0
ファイル: URIArg.java プロジェクト: tedvals/fleetmng
 /**
  * ** 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;
 }
コード例 #16
0
 public Connection data(String key, String value) {
   req.data(KeyVal.create(key, value));
   return this;
 }