Revisão | 120 (tree) |
---|---|
Hora | 2016-02-19 14:10:54 |
Autor | ![]() |
フォーマッターを実行。
@@ -16,12 +16,6 @@ | ||
16 | 16 | |
17 | 17 | package jp.co.formation.provider; |
18 | 18 | |
19 | -import jp.co.formation.provider.FormationContract.Member; | |
20 | -import jp.co.formation.provider.FormationContract.Point; | |
21 | -import jp.co.formation.provider.FormationContract.Result; | |
22 | -import jp.co.formation.provider.FormationContract.Team; | |
23 | -import jp.co.formation.provider.FormationContract.TeamMember; | |
24 | -import jp.co.formation.provider.FormationDatabaseHelper.Tables; | |
25 | 19 | import android.content.ContentUris; |
26 | 20 | import android.content.ContentValues; |
27 | 21 | import android.content.Context; |
@@ -33,6 +27,13 @@ | ||
33 | 27 | import android.provider.BaseColumns; |
34 | 28 | import android.util.Log; |
35 | 29 | |
30 | +import jp.co.formation.provider.FormationContract.Member; | |
31 | +import jp.co.formation.provider.FormationContract.Point; | |
32 | +import jp.co.formation.provider.FormationContract.Result; | |
33 | +import jp.co.formation.provider.FormationContract.Team; | |
34 | +import jp.co.formation.provider.FormationContract.TeamMember; | |
35 | +import jp.co.formation.provider.FormationDatabaseHelper.Tables; | |
36 | + | |
36 | 37 | public class FormationProvider extends AbstractFormationProvider { |
37 | 38 | |
38 | 39 | private static final String TAG = "FormationProvider"; |
@@ -62,10 +63,10 @@ | ||
62 | 63 | } |
63 | 64 | |
64 | 65 | // The database tag to use for representing the contacts DB in formation transactions. |
65 | - /* package */ static final String VERSUS_DB_TAG = "formation"; | |
66 | + /* package */static final String VERSUS_DB_TAG = "formation"; | |
66 | 67 | |
67 | 68 | /** |
68 | - * The thread-local holder of the active transaction. Shared between this and the profile | |
69 | + * The thread-local holder of the active transaction. Shared between this and the profile | |
69 | 70 | * provider, to keep transactions on both databases synchronized. |
70 | 71 | */ |
71 | 72 | private final ThreadLocal<FormationTransaction> mTransactionHolder = |
@@ -182,7 +183,7 @@ | ||
182 | 183 | int count = 0; |
183 | 184 | |
184 | 185 | final int match = sUriMatcher.match(uri); |
185 | - switch(match) { | |
186 | + switch (match) { | |
186 | 187 | case MEMBER: |
187 | 188 | return mDbHelper.get().getWritableDatabase().update(Tables.MEMBER, values, |
188 | 189 | selection, selectionArgs); |
@@ -269,7 +270,8 @@ | ||
269 | 270 | mDbHelper.set(mFormationHelper); |
270 | 271 | |
271 | 272 | Cursor cursor = |
272 | - query(mDbHelper.get().getReadableDatabase(), qb, projection, selection, selectionArgs, sortOrder, groupBy, | |
273 | + query(mDbHelper.get().getReadableDatabase(), qb, projection, selection, | |
274 | + selectionArgs, sortOrder, groupBy, | |
273 | 275 | limit); |
274 | 276 | return cursor; |
275 | 277 | } |
@@ -292,8 +294,8 @@ | ||
292 | 294 | /** |
293 | 295 | * Gets the value of the "limit" URI query parameter. |
294 | 296 | * |
295 | - * @return A string containing a non-negative integer, or <code>null</code> if | |
296 | - * the parameter is not set, or is set to an invalid value. | |
297 | + * @return A string containing a non-negative integer, or <code>null</code> if the parameter is | |
298 | + * not set, or is set to an invalid value. | |
297 | 299 | */ |
298 | 300 | private String getLimit(Uri uri) { |
299 | 301 | String limitParam = getQueryParameter(uri, FormationContract.LIMIT_PARAM_KEY); |
@@ -317,7 +319,7 @@ | ||
317 | 319 | /** |
318 | 320 | * A fast re-implementation of {@link Uri#getQueryParameter} |
319 | 321 | */ |
320 | - /* package */ static String getQueryParameter(Uri uri, String parameter) { | |
322 | + /* package */static String getQueryParameter(Uri uri, String parameter) { | |
321 | 323 | String query = uri.getEncodedQuery(); |
322 | 324 | if (query == null) { |
323 | 325 | return null; |
@@ -21,7 +21,7 @@ | ||
21 | 21 | import java.util.Map; |
22 | 22 | |
23 | 23 | /** |
24 | - * A convenience wrapper for a projection map. Makes it easier to create and use projection maps. | |
24 | + * A convenience wrapper for a projection map. Makes it easier to create and use projection maps. | |
25 | 25 | */ |
26 | 26 | public class ProjectionMap extends HashMap<String, String> { |
27 | 27 | private static final long serialVersionUID = 1L; |
@@ -26,8 +26,8 @@ | ||
26 | 26 | public static final Uri AUTHORITY_URI = Uri.parse("content://" + AUTHORITY); |
27 | 27 | |
28 | 28 | /** |
29 | - * A query parameter that limits the number of results returned. The | |
30 | - * parameter value should be an integer. | |
29 | + * A query parameter that limits the number of results returned. The parameter value should be | |
30 | + * an integer. | |
31 | 31 | */ |
32 | 32 | public static final String LIMIT_PARAM_KEY = "limit"; |
33 | 33 |
@@ -40,15 +40,14 @@ | ||
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | - * The content:// style URI for this table. Requests to this URI can be | |
44 | - * performed on the UI thread because they are always unblocking. | |
43 | + * The content:// style URI for this table. Requests to this URI can be performed on the UI | |
44 | + * thread because they are always unblocking. | |
45 | 45 | */ |
46 | 46 | public static final Uri CONTENT_URI = |
47 | 47 | Uri.withAppendedPath(AUTHORITY_URI, "member"); |
48 | 48 | |
49 | 49 | /** |
50 | - * The MIME-type of {@link #CONTENT_URI} providing a directory of | |
51 | - * contact directories. | |
50 | + * The MIME-type of {@link #CONTENT_URI} providing a directory of contact directories. | |
52 | 51 | */ |
53 | 52 | public static final String CONTENT_TYPE = |
54 | 53 | "vnd.android.cursor.dir/formation_member"; |
@@ -71,15 +70,14 @@ | ||
71 | 70 | } |
72 | 71 | |
73 | 72 | /** |
74 | - * The content:// style URI for this table. Requests to this URI can be | |
75 | - * performed on the UI thread because they are always unblocking. | |
73 | + * The content:// style URI for this table. Requests to this URI can be performed on the UI | |
74 | + * thread because they are always unblocking. | |
76 | 75 | */ |
77 | 76 | public static final Uri CONTENT_URI = |
78 | 77 | Uri.withAppendedPath(AUTHORITY_URI, "team"); |
79 | 78 | |
80 | 79 | /** |
81 | - * The MIME-type of {@link #CONTENT_URI} providing a directory of | |
82 | - * contact directories. | |
80 | + * The MIME-type of {@link #CONTENT_URI} providing a directory of contact directories. | |
83 | 81 | */ |
84 | 82 | public static final String CONTENT_TYPE = |
85 | 83 | "vnd.android.cursor.dir/formation_team"; |
@@ -102,15 +100,14 @@ | ||
102 | 100 | } |
103 | 101 | |
104 | 102 | /** |
105 | - * The content:// style URI for this table. Requests to this URI can be | |
106 | - * performed on the UI thread because they are always unblocking. | |
103 | + * The content:// style URI for this table. Requests to this URI can be performed on the UI | |
104 | + * thread because they are always unblocking. | |
107 | 105 | */ |
108 | 106 | public static final Uri CONTENT_URI = |
109 | 107 | Uri.withAppendedPath(AUTHORITY_URI, "teammember"); |
110 | 108 | |
111 | 109 | /** |
112 | - * The MIME-type of {@link #CONTENT_URI} providing a directory of | |
113 | - * contact directories. | |
110 | + * The MIME-type of {@link #CONTENT_URI} providing a directory of contact directories. | |
114 | 111 | */ |
115 | 112 | public static final String CONTENT_TYPE = |
116 | 113 | "vnd.android.cursor.dir/formation_teammember"; |
@@ -135,15 +132,14 @@ | ||
135 | 132 | } |
136 | 133 | |
137 | 134 | /** |
138 | - * The content:// style URI for this table. Requests to this URI can be | |
139 | - * performed on the UI thread because they are always unblocking. | |
135 | + * The content:// style URI for this table. Requests to this URI can be performed on the UI | |
136 | + * thread because they are always unblocking. | |
140 | 137 | */ |
141 | 138 | public static final Uri CONTENT_URI = |
142 | 139 | Uri.withAppendedPath(AUTHORITY_URI, "result"); |
143 | 140 | |
144 | 141 | /** |
145 | - * The MIME-type of {@link #CONTENT_URI} providing a directory of | |
146 | - * contact directories. | |
142 | + * The MIME-type of {@link #CONTENT_URI} providing a directory of contact directories. | |
147 | 143 | */ |
148 | 144 | public static final String CONTENT_TYPE = |
149 | 145 | "vnd.android.cursor.dir/formation_result"; |
@@ -173,15 +169,14 @@ | ||
173 | 169 | } |
174 | 170 | |
175 | 171 | /** |
176 | - * The content:// style URI for this table. Requests to this URI can be | |
177 | - * performed on the UI thread because they are always unblocking. | |
172 | + * The content:// style URI for this table. Requests to this URI can be performed on the UI | |
173 | + * thread because they are always unblocking. | |
178 | 174 | */ |
179 | 175 | public static final Uri CONTENT_URI = |
180 | 176 | Uri.withAppendedPath(AUTHORITY_URI, "point"); |
181 | 177 | |
182 | 178 | /** |
183 | - * The MIME-type of {@link #CONTENT_URI} providing a directory of | |
184 | - * contact directories. | |
179 | + * The MIME-type of {@link #CONTENT_URI} providing a directory of contact directories. | |
185 | 180 | */ |
186 | 181 | public static final String CONTENT_TYPE = |
187 | 182 | "vnd.android.cursor.dir/formation_point"; |
@@ -201,5 +196,4 @@ | ||
201 | 196 | public static final String ASSIST = "assist"; |
202 | 197 | } |
203 | 198 | |
204 | - | |
205 | 199 | } |
@@ -29,10 +29,10 @@ | ||
29 | 29 | import java.util.ArrayList; |
30 | 30 | |
31 | 31 | /** |
32 | - * A common base class for the contacts and profile providers. This handles much of the same | |
33 | - * logic that SQLiteContentProvider does (i.e. starting transactions on the appropriate database), | |
34 | - * but exposes awareness of batch operations to the subclass so that cross-database operations | |
35 | - * can be supported. | |
32 | + * A common base class for the contacts and profile providers. This handles much of the same logic | |
33 | + * that SQLiteContentProvider does (i.e. starting transactions on the appropriate database), but | |
34 | + * exposes awareness of batch operations to the subclass so that cross-database operations can be | |
35 | + * supported. | |
36 | 36 | */ |
37 | 37 | public abstract class AbstractFormationProvider extends ContentProvider |
38 | 38 | implements SQLiteTransactionListener { |
@@ -63,10 +63,10 @@ | ||
63 | 63 | private SQLiteOpenHelper mDbHelper; |
64 | 64 | |
65 | 65 | /** |
66 | - * The database helper to serialize all transactions on. If non-null, any new transaction | |
67 | - * created by this provider will automatically retrieve a writable database from this helper | |
68 | - * and initiate a transaction on that database. This should be used to ensure that operations | |
69 | - * across multiple databases are all blocked on a single DB lock (to prevent deadlock cases). | |
66 | + * The database helper to serialize all transactions on. If non-null, any new transaction | |
67 | + * created by this provider will automatically retrieve a writable database from this helper and | |
68 | + * initiate a transaction on that database. This should be used to ensure that operations across | |
69 | + * multiple databases are all blocked on a single DB lock (to prevent deadlock cases). | |
70 | 70 | */ |
71 | 71 | private SQLiteOpenHelper mSerializeOnDbHelper; |
72 | 72 |
@@ -89,6 +89,7 @@ | ||
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Specifies a database helper (and corresponding tag) to serialize all transactions on. |
92 | + * | |
92 | 93 | * @param serializeOnDbHelper The database helper to use for serializing transactions. |
93 | 94 | * @param tag The tag for this database. |
94 | 95 | */ |
@@ -211,8 +212,9 @@ | ||
211 | 212 | |
212 | 213 | /** |
213 | 214 | * If we are not yet already in a transaction, this starts one (on the DB to serialize on, if |
214 | - * present) and sets the thread-local transaction variable for tracking. If we are already in | |
215 | - * a transaction, this returns that transaction, and the batch parameter is ignored. | |
215 | + * present) and sets the thread-local transaction variable for tracking. If we are already in a | |
216 | + * transaction, this returns that transaction, and the batch parameter is ignored. | |
217 | + * | |
216 | 218 | * @param callerIsBatch Whether the caller is operating in batch mode. |
217 | 219 | */ |
218 | 220 | private FormationTransaction startTransaction(boolean callerIsBatch) { |
@@ -229,8 +231,9 @@ | ||
229 | 231 | } |
230 | 232 | |
231 | 233 | /** |
232 | - * Ends the current transaction and clears out the member variable. This does not set the | |
234 | + * Ends the current transaction and clears out the member variable. This does not set the | |
233 | 235 | * transaction as being successful. |
236 | + * | |
234 | 237 | * @param callerIsBatch Whether the caller is operating in batch mode. |
235 | 238 | */ |
236 | 239 | private void endTransaction(boolean callerIsBatch) { |
@@ -249,14 +252,14 @@ | ||
249 | 252 | } |
250 | 253 | |
251 | 254 | /** |
252 | - * Gets the database helper for this contacts provider. This is called once, during onCreate(). | |
255 | + * Gets the database helper for this contacts provider. This is called once, during onCreate(). | |
253 | 256 | */ |
254 | 257 | protected abstract SQLiteOpenHelper getDatabaseHelper(Context context); |
255 | 258 | |
256 | 259 | /** |
257 | - * Gets the thread-local transaction holder to use for keeping track of the transaction. This | |
258 | - * is called once, in onCreate(). If multiple classes are inheriting from this class that need | |
259 | - * to be kept in sync on the same transaction, they must all return the same thread-local. | |
260 | + * Gets the thread-local transaction holder to use for keeping track of the transaction. This is | |
261 | + * called once, in onCreate(). If multiple classes are inheriting from this class that need to | |
262 | + * be kept in sync on the same transaction, they must all return the same thread-local. | |
260 | 263 | */ |
261 | 264 | protected abstract ThreadLocal<FormationTransaction> getTransactionHolder(); |
262 | 265 |
@@ -20,8 +20,8 @@ | ||
20 | 20 | import java.util.Collections; |
21 | 21 | |
22 | 22 | /** |
23 | - * Provides static methods for creating {@code List} instances easily, and other | |
24 | - * utility methods for working with lists. | |
23 | + * Provides static methods for creating {@code List} instances easily, and other utility methods for | |
24 | + * working with lists. | |
25 | 25 | */ |
26 | 26 | public class Lists { |
27 | 27 |
@@ -28,7 +28,8 @@ | ||
28 | 28 | /** |
29 | 29 | * Creates an empty {@code ArrayList} instance. |
30 | 30 | * |
31 | - * <p><b>Note:</b> if you only need an <i>immutable</i> empty List, use | |
31 | + * <p> | |
32 | + * <b>Note:</b> if you only need an <i>immutable</i> empty List, use | |
32 | 33 | * {@link Collections#emptyList} instead. |
33 | 34 | * |
34 | 35 | * @return a newly-created, initially-empty {@code ArrayList} |
@@ -38,19 +39,20 @@ | ||
38 | 39 | } |
39 | 40 | |
40 | 41 | /** |
41 | - * Creates a resizable {@code ArrayList} instance containing the given | |
42 | - * elements. | |
42 | + * Creates a resizable {@code ArrayList} instance containing the given elements. | |
43 | 43 | * |
44 | - * <p><b>Note:</b> due to a bug in javac 1.5.0_06, we cannot support the | |
45 | - * following: | |
44 | + * <p> | |
45 | + * <b>Note:</b> due to a bug in javac 1.5.0_06, we cannot support the following: | |
46 | 46 | * |
47 | - * <p>{@code List<Base> list = Lists.newArrayList(sub1, sub2);} | |
47 | + * <p> | |
48 | + * {@code List<Base> list = Lists.newArrayList(sub1, sub2);} | |
48 | 49 | * |
49 | - * <p>where {@code sub1} and {@code sub2} are references to subtypes of | |
50 | - * {@code Base}, not of {@code Base} itself. To get around this, you must | |
51 | - * use: | |
50 | + * <p> | |
51 | + * where {@code sub1} and {@code sub2} are references to subtypes of {@code Base}, not of | |
52 | + * {@code Base} itself. To get around this, you must use: | |
52 | 53 | * |
53 | - * <p>{@code List<Base> list = Lists.<Base>newArrayList(sub1, sub2);} | |
54 | + * <p> | |
55 | + * {@code List<Base> list = Lists.<Base>newArrayList(sub1, sub2);} | |
54 | 56 | * |
55 | 57 | * @param elements the elements that the list should contain, in order |
56 | 58 | * @return a newly-created {@code ArrayList} containing those elements |
@@ -16,15 +16,16 @@ | ||
16 | 16 | |
17 | 17 | package jp.co.formation.provider; |
18 | 18 | |
19 | +import android.content.Context; | |
20 | +import android.database.sqlite.SQLiteDatabase; | |
21 | +import android.database.sqlite.SQLiteOpenHelper; | |
22 | +import android.util.Log; | |
23 | + | |
19 | 24 | import jp.co.formation.provider.FormationContract.Member; |
20 | 25 | import jp.co.formation.provider.FormationContract.Point; |
21 | 26 | import jp.co.formation.provider.FormationContract.Result; |
22 | 27 | import jp.co.formation.provider.FormationContract.Team; |
23 | 28 | import jp.co.formation.provider.FormationContract.TeamMember; |
24 | -import android.content.Context; | |
25 | -import android.database.sqlite.SQLiteDatabase; | |
26 | -import android.database.sqlite.SQLiteOpenHelper; | |
27 | -import android.util.Log; | |
28 | 29 | |
29 | 30 | public class FormationDatabaseHelper extends SQLiteOpenHelper { |
30 | 31 | private static final String TAG = "FormationDatabaseHelper"; |
@@ -47,30 +48,30 @@ | ||
47 | 48 | } |
48 | 49 | |
49 | 50 | public interface TeamColumns { |
50 | - public static final String _ID = Team._ID; | |
51 | - public static final String TEAM = Team.TEAM; | |
51 | + public static final String _ID = Team._ID; | |
52 | + public static final String TEAM = Team.TEAM; | |
52 | 53 | } |
53 | 54 | |
54 | 55 | public interface TeamMemberColumns { |
55 | - public static final String _ID = TeamMember._ID; | |
56 | - public static final String MEMBERID = TeamMember.MEMBERID; | |
57 | - public static final String TEAMID = TeamMember.TEAMID; | |
56 | + public static final String _ID = TeamMember._ID; | |
57 | + public static final String MEMBERID = TeamMember.MEMBERID; | |
58 | + public static final String TEAMID = TeamMember.TEAMID; | |
58 | 59 | } |
59 | 60 | |
60 | 61 | public interface ResultColumns { |
61 | - public static final String _ID = Result._ID; | |
62 | - public static final String RESULTID = Result.RESULTID; | |
63 | - public static final String DATE = Result.DATE; | |
64 | - public static final String TEAM1 = Result.TEAM1; | |
65 | - public static final String TEAM2 = Result.TEAM2; | |
62 | + public static final String _ID = Result._ID; | |
63 | + public static final String RESULTID = Result.RESULTID; | |
64 | + public static final String DATE = Result.DATE; | |
65 | + public static final String TEAM1 = Result.TEAM1; | |
66 | + public static final String TEAM2 = Result.TEAM2; | |
66 | 67 | } |
67 | 68 | |
68 | 69 | public interface PointColumns { |
69 | - public static final String _ID = Point._ID; | |
70 | - public static final String RESULTID = Point.RESULTID; | |
71 | - public static final String TEAMID = Point.TEAMID; | |
72 | - public static final String SCORER = Point.SCORER; | |
73 | - public static final String ASSIST = Point.ASSIST; | |
70 | + public static final String _ID = Point._ID; | |
71 | + public static final String RESULTID = Point.RESULTID; | |
72 | + public static final String TEAMID = Point.TEAMID; | |
73 | + public static final String SCORER = Point.SCORER; | |
74 | + public static final String ASSIST = Point.ASSIST; | |
74 | 75 | } |
75 | 76 | |
76 | 77 | private static FormationDatabaseHelper sSingleton = null; |
@@ -102,18 +103,18 @@ | ||
102 | 103 | db.execSQL("CREATE TABLE " + Tables.MEMBER + " (" + |
103 | 104 | MemberColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + |
104 | 105 | MemberColumns.NAME + " TEXT NOT NULL" + |
105 | - ");"); | |
106 | + ");"); | |
106 | 107 | |
107 | 108 | db.execSQL("CREATE TABLE " + Tables.TEAM + " (" + |
108 | 109 | TeamColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + |
109 | 110 | TeamColumns.TEAM + " TEXT NOT NULL" + |
110 | - ");"); | |
111 | + ");"); | |
111 | 112 | |
112 | 113 | db.execSQL("CREATE TABLE " + Tables.TEAMMEMBER + " (" + |
113 | 114 | TeamMemberColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + |
114 | 115 | TeamMemberColumns.MEMBERID + " INTEGER NOT NULL," + |
115 | 116 | TeamMemberColumns.TEAMID + " INTEGER NOT NULL" + |
116 | - ");"); | |
117 | + ");"); | |
117 | 118 | |
118 | 119 | db.execSQL("CREATE TABLE " + Tables.RESULT + " (" + |
119 | 120 | ResultColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + |
@@ -121,7 +122,7 @@ | ||
121 | 122 | ResultColumns.RESULTID + " INTEGER NOT NULL," + |
122 | 123 | ResultColumns.TEAM1 + " INTEGER NOT NULL," + |
123 | 124 | ResultColumns.TEAM2 + " INTEGER NOT NULL" + |
124 | - ");"); | |
125 | + ");"); | |
125 | 126 | |
126 | 127 | db.execSQL("CREATE TABLE " + Tables.POINT + " (" + |
127 | 128 | PointColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," + |
@@ -129,7 +130,7 @@ | ||
129 | 130 | PointColumns.TEAMID + " INTEGER NOT NULL," + |
130 | 131 | PointColumns.SCORER + " INTEGER NOT NULL," + |
131 | 132 | PointColumns.ASSIST + " INTEGER" + |
132 | - ");"); | |
133 | + ");"); | |
133 | 134 | |
134 | 135 | } |
135 | 136 |
@@ -26,7 +26,7 @@ | ||
26 | 26 | import java.util.Map; |
27 | 27 | |
28 | 28 | /** |
29 | - * A transaction for interacting with a Contacts provider. This is used to pass state around | |
29 | + * A transaction for interacting with a Contacts provider. This is used to pass state around | |
30 | 30 | * throughout the operations comprising the transaction, including which databases the overall |
31 | 31 | * transaction is involved in, and whether the operation being performed is a batch operation. |
32 | 32 | */ |
@@ -33,7 +33,7 @@ | ||
33 | 33 | public class FormationTransaction { |
34 | 34 | |
35 | 35 | /** |
36 | - * Whether this transaction is encompassing a batch of operations. If we're in batch mode, | |
36 | + * Whether this transaction is encompassing a batch of operations. If we're in batch mode, | |
37 | 37 | * transactional operations from non-batch callers are ignored. |
38 | 38 | */ |
39 | 39 | private final boolean mBatch; |
@@ -54,14 +54,15 @@ | ||
54 | 54 | private boolean mIsDirty; |
55 | 55 | |
56 | 56 | /** |
57 | - * Whether a yield operation failed with an exception. If this occurred, we may not have a | |
58 | - * lock on one of the databases that we started the transaction with (the yield code cleans | |
59 | - * that up itself), so we should do an extra check before ending transactions. | |
57 | + * Whether a yield operation failed with an exception. If this occurred, we may not have a lock | |
58 | + * on one of the databases that we started the transaction with (the yield code cleans that up | |
59 | + * itself), so we should do an extra check before ending transactions. | |
60 | 60 | */ |
61 | 61 | private boolean mYieldFailed; |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Creates a new transaction object, optionally marked as a batch transaction. |
65 | + * | |
65 | 66 | * @param batch Whether the transaction is in batch mode. |
66 | 67 | */ |
67 | 68 | public FormationTransaction(boolean batch) { |
@@ -88,12 +89,13 @@ | ||
88 | 89 | } |
89 | 90 | |
90 | 91 | /** |
91 | - * If the given database has not already been enlisted in this transaction, adds it to our | |
92 | - * list of affected databases and starts a transaction on it. If we already have the given | |
93 | - * database in this transaction, this is a no-op. | |
92 | + * If the given database has not already been enlisted in this transaction, adds it to our list | |
93 | + * of affected databases and starts a transaction on it. If we already have the given database | |
94 | + * in this transaction, this is a no-op. | |
95 | + * | |
94 | 96 | * @param db The database to start a transaction on, if necessary. |
95 | 97 | * @param tag A constant that can be used to retrieve the DB instance in this transaction. |
96 | - * @param listener A transaction listener to attach to this transaction. May be null. | |
98 | + * @param listener A transaction listener to attach to this transaction. May be null. | |
97 | 99 | */ |
98 | 100 | public void startTransactionForDb(SQLiteDatabase db, String tag, |
99 | 101 | SQLiteTransactionListener listener) { |
@@ -117,9 +119,10 @@ | ||
117 | 119 | |
118 | 120 | /** |
119 | 121 | * Retrieves the database enlisted in the transaction corresponding to the given tag. |
122 | + * | |
120 | 123 | * @param tag The tag of the database to look up. |
121 | 124 | * @return The database corresponding to the tag, or null if no database with that tag has been |
122 | - * enlisted in this transaction. | |
125 | + * enlisted in this transaction. | |
123 | 126 | */ |
124 | 127 | public SQLiteDatabase getDbForTag(String tag) { |
125 | 128 | return mDatabaseTagMap.get(tag); |
@@ -126,12 +129,13 @@ | ||
126 | 129 | } |
127 | 130 | |
128 | 131 | /** |
129 | - * Removes the database corresponding to the given tag from this transaction. It is now the | |
130 | - * caller's responsibility to do whatever needs to happen with this database - it is no longer | |
131 | - * a part of this transaction. | |
132 | + * Removes the database corresponding to the given tag from this transaction. It is now the | |
133 | + * caller's responsibility to do whatever needs to happen with this database - it is no longer a | |
134 | + * part of this transaction. | |
135 | + * | |
132 | 136 | * @param tag The tag of the database to remove. |
133 | 137 | * @return The database corresponding to the tag, or null if no database with that tag has been |
134 | - * enlisted in this transaction. | |
138 | + * enlisted in this transaction. | |
135 | 139 | */ |
136 | 140 | public SQLiteDatabase removeDbForTag(String tag) { |
137 | 141 | SQLiteDatabase db = mDatabaseTagMap.get(tag); |
@@ -142,8 +146,9 @@ | ||
142 | 146 | |
143 | 147 | /** |
144 | 148 | * Marks all active DB transactions as successful. |
145 | - * @param callerIsBatch Whether this is being performed in the context of a batch operation. | |
146 | - * If it is not, and the transaction is marked as batch, this call is a no-op. | |
149 | + * | |
150 | + * @param callerIsBatch Whether this is being performed in the context of a batch operation. If | |
151 | + * it is not, and the transaction is marked as batch, this call is a no-op. | |
147 | 152 | */ |
148 | 153 | public void markSuccessful(boolean callerIsBatch) { |
149 | 154 | if (!mBatch || callerIsBatch) { |
@@ -155,8 +160,9 @@ | ||
155 | 160 | |
156 | 161 | /** |
157 | 162 | * Completes the transaction, ending the DB transactions for all associated databases. |
158 | - * @param callerIsBatch Whether this is being performed in the context of a batch operation. | |
159 | - * If it is not, and the transaction is marked as batch, this call is a no-op. | |
163 | + * | |
164 | + * @param callerIsBatch Whether this is being performed in the context of a batch operation. If | |
165 | + * it is not, and the transaction is marked as batch, this call is a no-op. | |
160 | 166 | */ |
161 | 167 | public void finish(boolean callerIsBatch) { |
162 | 168 | if (!mBatch || callerIsBatch) { |
@@ -163,7 +169,7 @@ | ||
163 | 169 | for (SQLiteDatabase db : mDatabasesForTransaction) { |
164 | 170 | // If an exception was thrown while yielding, it's possible that we no longer have |
165 | 171 | // a lock on this database, so we need to check before attempting to end its |
166 | - // transaction. Otherwise, we should always expect to be in a transaction (and will | |
172 | + // transaction. Otherwise, we should always expect to be in a transaction (and will | |
167 | 173 | // throw an exception if this is not the case). |
168 | 174 | if (mYieldFailed && !db.isDbLockedByCurrentThread()) { |
169 | 175 | // We no longer hold the lock, so don't do anything with this database. |
@@ -71,7 +71,7 @@ | ||
71 | 71 | if (tokens != null) { |
72 | 72 | |
73 | 73 | // Keep track of whether we've passed a "lookup" token in the path; wildcards after |
74 | - // that token will be interpreted as lookup keys. For our purposes, vcard paths | |
74 | + // that token will be interpreted as lookup keys. For our purposes, vcard paths | |
75 | 75 | // also count as lookup tokens, since the vcard is specified by lookup key. |
76 | 76 | boolean afterLookup = false; |
77 | 77 | for (int i = 0; i < tokens.length; i++) { |