SyncStats.java revision 54b6cfa9a9e5b861a9930af873580d6dc20f773c
1/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.content;
18
19import android.os.Parcelable;
20import android.os.Parcel;
21
22/**
23 * @hide
24 */
25public class SyncStats implements Parcelable {
26    public long numAuthExceptions;
27    public long numIoExceptions;
28    public long numParseExceptions;
29    public long numConflictDetectedExceptions;
30    public long numInserts;
31    public long numUpdates;
32    public long numDeletes;
33    public long numEntries;
34    public long numSkippedEntries;
35
36    public SyncStats() {
37        numAuthExceptions = 0;
38        numIoExceptions = 0;
39        numParseExceptions = 0;
40        numConflictDetectedExceptions = 0;
41        numInserts = 0;
42        numUpdates = 0;
43        numDeletes = 0;
44        numEntries = 0;
45        numSkippedEntries = 0;
46    }
47
48    public SyncStats(Parcel in) {
49        numAuthExceptions = in.readLong();
50        numIoExceptions = in.readLong();
51        numParseExceptions = in.readLong();
52        numConflictDetectedExceptions = in.readLong();
53        numInserts = in.readLong();
54        numUpdates = in.readLong();
55        numDeletes = in.readLong();
56        numEntries = in.readLong();
57        numSkippedEntries = in.readLong();
58    }
59
60    @Override
61    public String toString() {
62        StringBuilder sb = new StringBuilder();
63        sb.append("numAuthExceptions: ").append(numAuthExceptions);
64        sb.append(" numIoExceptions: ").append(numIoExceptions);
65        sb.append(" numParseExceptions: ").append(numParseExceptions);
66        sb.append(" numConflictDetectedExceptions: ").append(numConflictDetectedExceptions);
67        sb.append(" numInserts: ").append(numInserts);
68        sb.append(" numUpdates: ").append(numUpdates);
69        sb.append(" numDeletes: ").append(numDeletes);
70        sb.append(" numEntries: ").append(numEntries);
71        sb.append(" numSkippedEntries: ").append(numSkippedEntries);
72        return sb.toString();
73    }
74
75    public void clear() {
76        numAuthExceptions = 0;
77        numIoExceptions = 0;
78        numParseExceptions = 0;
79        numConflictDetectedExceptions = 0;
80        numInserts = 0;
81        numUpdates = 0;
82        numDeletes = 0;
83        numEntries = 0;
84        numSkippedEntries = 0;
85    }
86
87    public int describeContents() {
88        return 0;
89    }
90
91    public void writeToParcel(Parcel dest, int flags) {
92        dest.writeLong(numAuthExceptions);
93        dest.writeLong(numIoExceptions);
94        dest.writeLong(numParseExceptions);
95        dest.writeLong(numConflictDetectedExceptions);
96        dest.writeLong(numInserts);
97        dest.writeLong(numUpdates);
98        dest.writeLong(numDeletes);
99        dest.writeLong(numEntries);
100        dest.writeLong(numSkippedEntries);
101    }
102
103    public static final Creator<SyncStats> CREATOR = new Creator<SyncStats>() {
104        public SyncStats createFromParcel(Parcel in) {
105            return new SyncStats(in);
106        }
107
108        public SyncStats[] newArray(int size) {
109            return new SyncStats[size];
110        }
111    };
112}
113