SyncStats.java revision 77709755b74bcc852cd511ff833c2827c0f0e1aa
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(" stats ["); 64 if (numAuthExceptions > 0) sb.append(" numAuthExceptions: ").append(numAuthExceptions); 65 if (numIoExceptions > 0) sb.append(" numIoExceptions: ").append(numIoExceptions); 66 if (numParseExceptions > 0) sb.append(" numParseExceptions: ").append(numParseExceptions); 67 if (numConflictDetectedExceptions > 0) 68 sb.append(" numConflictDetectedExceptions: ").append(numConflictDetectedExceptions); 69 if (numInserts > 0) sb.append(" numInserts: ").append(numInserts); 70 if (numUpdates > 0) sb.append(" numUpdates: ").append(numUpdates); 71 if (numDeletes > 0) sb.append(" numDeletes: ").append(numDeletes); 72 if (numEntries > 0) sb.append(" numEntries: ").append(numEntries); 73 if (numSkippedEntries > 0) sb.append(" numSkippedEntries: ").append(numSkippedEntries); 74 sb.append("]"); 75 return sb.toString(); 76 } 77 78 public void clear() { 79 numAuthExceptions = 0; 80 numIoExceptions = 0; 81 numParseExceptions = 0; 82 numConflictDetectedExceptions = 0; 83 numInserts = 0; 84 numUpdates = 0; 85 numDeletes = 0; 86 numEntries = 0; 87 numSkippedEntries = 0; 88 } 89 90 public int describeContents() { 91 return 0; 92 } 93 94 public void writeToParcel(Parcel dest, int flags) { 95 dest.writeLong(numAuthExceptions); 96 dest.writeLong(numIoExceptions); 97 dest.writeLong(numParseExceptions); 98 dest.writeLong(numConflictDetectedExceptions); 99 dest.writeLong(numInserts); 100 dest.writeLong(numUpdates); 101 dest.writeLong(numDeletes); 102 dest.writeLong(numEntries); 103 dest.writeLong(numSkippedEntries); 104 } 105 106 public static final Creator<SyncStats> CREATOR = new Creator<SyncStats>() { 107 public SyncStats createFromParcel(Parcel in) { 108 return new SyncStats(in); 109 } 110 111 public SyncStats[] newArray(int size) { 112 return new SyncStats[size]; 113 } 114 }; 115} 116