Back to project page ls-vertretungsplan.
The source code is released under:
GNU General Public License
If you think the Android project ls-vertretungsplan listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.joejernst.http; //from ww w . j a va2s . c o m import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /* Copyright 2012 Joe J. Ernst Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /** * This class represents an HTTP Message, which could either be a Request or a Response. Message is an abstract * class that contains fields and methods that are common to both types of Messages. * * @param <T> A Type that extends Message (either {@link Request} or {@link Response}) */ public abstract class Message<T extends Message<T>> { Map<String, List<String>> headers = new HashMap<String, List<String>>(); String body; /** * The default constructor is a no-op constructor. */ public Message() { // No-arg, No-op constructor } /** * Returns the Message body (also known as the Entity body). * * @return The body of the HTTP Message. It will typically be HTML, JSON, or XML. */ public String getBody() { return this.body; } /** * Sets the body of the Message. * * @param body This is typically the JSON, XML, or Form Parameters being sent to the server. * @return this Message, to support chained method calls */ @SuppressWarnings("unchecked") public T setBody(String body) { this.body = body; return (T) this; } /** * Adds a single header value to the Message. * * @param name The header name. * @param value The header value * @return this Message, to support chained method calls */ @SuppressWarnings("unchecked") public T addHeader(String name, String value) { List<String> values = new ArrayList<String>(); values.add(value); this.headers.put(name, values); return (T) this; } /** * Removes the specified header. * * @param name The name of the header to remove. * @return this Message, to support chained method calls */ @SuppressWarnings("unchecked") public T removeHeader(String name) { this.headers.remove(name); return (T) this; } /** * Sets all of the headers in one call. * * @param headers A Map of headers, where the header name is a String, and the value is a List of one or more * values. * @return this Message, to support chained method calls */ @SuppressWarnings("unchecked") public T setHeaders(Map<String, List<String>> headers) { this.headers = headers; return (T) this; } }