~trb143/openlp/a2

« back to all changes in this revision

Viewing changes to OpenLP/src/org/openlp/android2/common/OpenLPHttpReturn.java

  • Committer: Tim Bentley
  • Date: 2014-09-28 09:20:26 UTC
  • Revision ID: tim.bentley@gmail.com-20140928092026-s0v6xnxa34y0jx6d
Missed a bit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * OpenLP - Open Source Lyrics Projection                                      *
 
3
 * --------------------------------------------------------------------------- *
 
4
 * Copyright (c) 2011-2013 Raoul Snyman                                        *
 
5
 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel        *
 
6
 * Sjöbergsson                                                                 *
 
7
 * --------------------------------------------------------------------------- *
 
8
 * This program is free software; you can redistribute it and/or modify it     *
 
9
 * under the terms of the GNU General Public License as published by the Free  *
 
10
 * Software Foundation; version 2 of the License.                              *
 
11
 *                                                                             *
 
12
 * This program is distributed in the hope that it will be useful, but WITHOUT *
 
13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
 
14
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    *
 
15
 * more details.                                                               *
 
16
 *                                                                             *
 
17
 * You should have received a copy of the GNU General Public License along     *
 
18
 * with this program; if not, write to the Free Software Foundation, Inc., 59  *
 
19
 * Temple Place, Suite 330, Boston, MA 02111-1307 USA                          *
 
20
 *******************************************************************************/
 
21
package org.openlp.android2.common;
 
22
 
 
23
import android.content.Context;
 
24
import org.openlp.android2.R;
 
25
 
 
26
public class OpenLPHttpReturn {
 
27
    private int return_code = 0;
 
28
    private String data = null;
 
29
    private Context context;
 
30
 
 
31
    public OpenLPHttpReturn() {
 
32
        this.return_code = 401;
 
33
        this.data = "";
 
34
        this.context = null;
 
35
    }
 
36
 
 
37
    public OpenLPHttpReturn(int return_code, String data, Context context) {
 
38
        this.return_code = return_code;
 
39
        this.data = data;
 
40
        this.context = context;
 
41
    }
 
42
 
 
43
    public String getData() {
 
44
        return this.data;
 
45
    }
 
46
 
 
47
    public boolean isError() {
 
48
        return return_code != 0;
 
49
    }
 
50
 
 
51
    public String getErrorMessage(String message) {
 
52
        return return_code == 401 ? this.context.getString(R.string.httpreturn_unauthorised) : message;
 
53
    }
 
54
 
 
55
    @Override
 
56
    public String toString() {
 
57
        return "HttpReturn{" + "data='" + data + '\'' + ", return code=" + return_code + '}';
 
58
    }
 
59
}