Android Open Source - ls-vertretungsplan Message






From Project

Back to project page ls-vertretungsplan.

License

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.

Java Source Code

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;
    }


}




Java Source Code List

com.joejernst.http.Message.java
com.joejernst.http.Request.java
com.joejernst.http.Response.java
com.johan.vertretungsplan.GCMIntentService.java
com.johan.vertretungsplan.LoginDialogFragment.java
com.johan.vertretungsplan.NachrichtenFragment.java
com.johan.vertretungsplan.SettingsActivity.java
com.johan.vertretungsplan.SettingsFragment.java
com.johan.vertretungsplan.StartActivity.java
com.johan.vertretungsplan.VertretungFragment.java
com.johan.vertretungsplan.VertretungsplanApplication.java
com.johan.vertretungsplan.VertretungsplanFragment.java
com.johan.vertretungsplan.additionalinfo.BaseAdditionalInfoParser.java
com.johan.vertretungsplan.additionalinfo.WinterShParser.java
com.johan.vertretungsplan.background.VertretungsplanService.java
com.johan.vertretungsplan.comparators.AlphabeticalSchoolComparator.java
com.johan.vertretungsplan.comparators.DistanceSchoolComparator.java
com.johan.vertretungsplan.objects.AdditionalInfo.java
com.johan.vertretungsplan.objects.KlassenVertretungsplan.java
com.johan.vertretungsplan.objects.Schule.java
com.johan.vertretungsplan.objects.Vertretung.java
com.johan.vertretungsplan.objects.VertretungsplanTag.java
com.johan.vertretungsplan.objects.Vertretungsplan.java
com.johan.vertretungsplan.parser.BackendConnectParser.java
com.johan.vertretungsplan.parser.BaseParser.java
com.johan.vertretungsplan.ui.LinkAlertDialog.java
com.johan.vertretungsplan.ui.TabSwipeActivity.java
com.johan.vertretungsplan.ui.WebViewAlertDialog.java
com.johan.vertretungsplan.utils.Animations.java
com.johan.vertretungsplan.utils.Utils.java
com.johan.vertretungsplan.widget.VertretungsplanWidgetProvider.java
com.johan.vertretungsplan.widget.VertretungsplanWidgetService.java