Grundaufbau der App
[DHBWCampusApp.git] / app / src / main / java / com / codebutler / farebot / card / desfire / DesfireApplication.java
1 /*
2  * DesfireApplication.java
3  *
4  * Copyright (C) 2011 Eric Butler
5  *
6  * Authors:
7  * Eric Butler <eric@codebutler.com>
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  */
22
23 package com.codebutler.farebot.card.desfire;
24
25 import android.os.Parcel;
26 import android.os.Parcelable;
27
28 public class DesfireApplication implements Parcelable {
29     private int           mId;
30     private DesfireFile[] mFiles;
31
32     public DesfireApplication (int id, DesfireFile[] files) {
33         mId    = id;
34         mFiles = files;
35     }
36
37     public int getId () {
38         return mId;
39     }
40
41     public DesfireFile[] getFiles () {
42         return mFiles;
43     }
44
45     public DesfireFile getFile (int fileId) {
46         for (DesfireFile file : mFiles) {
47             if (file.getId() == fileId)
48                 return file;
49         }
50         return null;
51     }
52
53     public static final Parcelable.Creator<DesfireApplication> CREATOR = new Parcelable.Creator<DesfireApplication>() {
54         public DesfireApplication createFromParcel(Parcel source) {
55             int id = source.readInt();
56
57             DesfireFile[] files = new DesfireFile[source.readInt()];
58             source.readTypedArray(files, DesfireFile.CREATOR);
59
60             return new DesfireApplication(id, files);
61         }
62
63         public DesfireApplication[] newArray (int size) {
64             return new DesfireApplication[size];
65         }
66     };
67
68     public void writeToParcel (Parcel parcel, int flags) {
69         parcel.writeInt(mId);
70         parcel.writeInt(mFiles.length);
71         parcel.writeTypedArray(mFiles, flags);
72     }
73
74     public int describeContents () {
75         return 0;
76     }    
77 }