2 * Copyright (c) 2014 NEC Corporation
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this
7 * distribution, and is available at http://www.eclipse.org/legal/epl-v10.html
10 package org.opendaylight.vtn.app.run.config.rest.parser;
12 import java.util.HashMap;
14 import java.util.Map.Entry;
16 public class RestRequest {
19 * Json Response Start Delimiter.
22 public static final String PARAM_DELIM_START = " {";
25 * Json Response End Delimiter.
27 public static final String PARAM_DELIM_END = "}";
30 * REST Service server URL address.
32 private String url = null;
35 * Response string value received from the request.
37 private String response = null;
40 * Map of Response parameters.
42 private Map<String, String> params = null;
47 public RestRequest() {
48 params = new HashMap<String, String>();
52 * getUrl - to get the server URL.
53 * @return {@link String}
55 public String getUrl() {
60 * setUrl - to set the server URL.
63 public void setUrl(String url) {
68 * getParams - to get the response parameter.
69 * @return {@link String}
71 public Map<String, String> getParams() {
76 * setParams - to set the response parameter.
79 public void setParams(Map<String, String> params) {
84 * getResponse - to get the response .
85 * @return {@link Map<String, String>}
87 public String getResponse() {
92 * setResponse - to set the response.
95 public void setResponse(String response) {
96 this.response = response;
100 * setResponse - to set the URL parameters.
103 public void setURLParams() {
104 for (Entry<String, String> entry : params.entrySet()) {
105 setURLParam(entry.getKey(), entry.getValue());
110 * setResponse - to set the response.
111 * @param paramName, paramValue
113 public void setURLParam(String paramName, String paramValue) {
114 if (url.contains(PARAM_DELIM_START + paramName + PARAM_DELIM_END)) {
115 url = url.replace(PARAM_DELIM_START + paramName + PARAM_DELIM_END,