001package co.codewizards.cloudstore.rest.client.internal; 002 003import java.io.UnsupportedEncodingException; 004import java.net.URLEncoder; 005 006import co.codewizards.cloudstore.core.util.IOUtil; 007 008/** 009 * @author Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de 010 */ 011public class QueryParameter extends RelativePathPart 012{ 013 private String key; 014 private String value; 015 016 public QueryParameter() { } 017 018 public QueryParameter(String key, String value) { 019 this.key = key; 020 this.value = value; 021 } 022 023 public String getKey() { 024 return key; 025 } 026 public void setKey(String key) { 027 this.key = key; 028 } 029 public String getValue() { 030 return value; 031 } 032 public void setValue(String value) { 033 this.value = value; 034 } 035 036 @Override 037 public String toString() { 038 try { 039 return ( 040 (key == null ? "" : URLEncoder.encode(key, IOUtil.CHARSET_NAME_UTF_8)) 041 + '=' 042 + (value == null ? "" : URLEncoder.encode(value, IOUtil.CHARSET_NAME_UTF_8)) 043 ); 044 } catch (UnsupportedEncodingException e) { 045 throw new RuntimeException(e); 046 } 047 } 048}