// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.olio.olios.model; import android.content.ContentResolver; import android.content.ContentUris; import android.content.ContentValues; import android.content.UriMatcher; import android.database.Cursor; import android.database.MatrixCursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; import com.olio.olios.model.record.DatabaseRecord; import com.olio.olios.model.record.DatabaseRecordMixins; import com.olio.util.ALog; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; // Referenced classes of package com.olio.olios.model: // DataContract, OlioDatabaseHelper public class OlioDatabaseUtils { private static final int REQUEST = 1; private static final int REQUEST_ID = 2; private static final int REQUEST_ID_PATH_POSITION = 1; private static final Map uriMatchers; public OlioDatabaseUtils() { } public static Cursor cursorForContentValues(String as[], ContentValues acontentvalues[]) { if (acontentvalues.length > 0) { MatrixCursor matrixcursor = new MatrixCursor(as, acontentvalues.length); int l = acontentvalues.length; for (int i = 0; i < l; i++) { ContentValues contentvalues = acontentvalues[i]; Object aobj[] = new Object[as.length]; int k = 0; int i1 = as.length; for (int j = 0; j < i1; j++) { aobj[k] = contentvalues.get(as[j]); k++; } matrixcursor.addRow(aobj); } matrixcursor.moveToPosition(-1); return matrixcursor; } else { return new MatrixCursor(new String[] { "" }); } } public static int delete(ContentResolver contentresolver, Uri uri, String s, String as[], OlioDatabaseHelper oliodatabasehelper) { SQLiteDatabase sqlitedatabase; boolean flag; flag = false; ALog.d((new StringBuilder()).append("delete called for uri: ").append(uri.toString()).toString(), new Object[0]); sqlitedatabase = oliodatabasehelper.getWritableDatabase(); if (!Objects.equals(uri.getQueryParameter("shouldNotify"), "NO")) { flag = true; } oliodatabasehelper = uriMatchers.keySet().iterator(); _L4: if (!oliodatabasehelper.hasNext()) goto _L2; else goto _L1 _L1: UriMatcher urimatcher; int i; urimatcher = (UriMatcher)oliodatabasehelper.next(); i = urimatcher.match(uri); if (i == -1) goto _L4; else goto _L3 _L3: DatabaseRecord databaserecord = ((com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory)uriMatchers.get(urimatcher)).getRecordInstance(); i; JVM INSTR tableswitch 1 2: default 152 // 1 179 // 2 222; goto _L5 _L6 _L7 _L5: throw new IllegalArgumentException((new StringBuilder()).append("Unknown URI ").append(uri).toString()); _L6: i = sqlitedatabase.delete(databaserecord.tableName(), s, as); _L8: if (flag) { contentresolver.notifyChange(uri.buildUpon().appendQueryParameter("operation", "deleted").build(), null); } return i; _L7: String s1 = (new StringBuilder()).append(databaserecord.indexColumn()).append("=").append((String)uri.getPathSegments().get(1)).toString(); oliodatabasehelper = s1; if (s != null) { oliodatabasehelper = (new StringBuilder()).append(s1).append(" AND ").append(s).toString(); } i = sqlitedatabase.delete(databaserecord.tableName(), oliodatabasehelper, as); if (true) goto _L8; else goto _L2 _L2: throw new IllegalArgumentException((new StringBuilder()).append("Unknown URI ").append(uri).toString()); } public static Uri insert(ContentResolver contentresolver, Uri uri, ContentValues contentvalues, OlioDatabaseHelper oliodatabasehelper) { ALog.d((new StringBuilder()).append("insert called for uri: ").append(uri.toString()).toString(), new Object[0]); Object obj1 = null; Iterator iterator = uriMatchers.keySet().iterator(); Object obj; do { obj = obj1; if (!iterator.hasNext()) { break; } obj = (UriMatcher)iterator.next(); } while (((UriMatcher) (obj)).match(uri) != 1); if (obj == null) { throw new IllegalArgumentException((new StringBuilder()).append("Unknown URI ").append(uri).toString()); } boolean flag; long l; if (!Objects.equals(uri.getQueryParameter("shouldNotify"), "NO")) { flag = true; } else { flag = false; } if (contentvalues != null) { contentvalues = new ContentValues(contentvalues); } else { contentvalues = new ContentValues(); } l = System.currentTimeMillis(); if (!contentvalues.containsKey("date_created") || contentvalues.containsKey("date_created") && contentvalues.getAsLong("date_created") == null) { contentvalues.put("date_created", Long.valueOf(l)); } if (!contentvalues.containsKey("date_modified") || contentvalues.containsKey("date_modified") && contentvalues.getAsLong("date_modified") == null) { contentvalues.put("date_modified", Long.valueOf(l)); } oliodatabasehelper = oliodatabasehelper.getWritableDatabase(); obj = (com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory)uriMatchers.get(obj); l = oliodatabasehelper.insertWithOnConflict(((com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory) (obj)).getRecordInstance().tableName(), null, contentvalues, 2); if (l > 0L) { contentvalues = ContentUris.withAppendedId(DatabaseRecordMixins.baseUriForTable(((com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory) (obj))), l); oliodatabasehelper = uri.getQueryParameter("typeName"); uri = contentvalues; if (oliodatabasehelper != null) { uri = contentvalues.buildUpon().appendQueryParameter("typeName", oliodatabasehelper).build(); } contentvalues = uri; if (flag) { contentvalues = uri.buildUpon().appendQueryParameter("operation", "inserted").build(); contentresolver.notifyChange(contentvalues, null); } ALog.d("Record inserted: %s", new Object[] { contentvalues.toString() }); return contentvalues; } else { throw new SQLException((new StringBuilder()).append("Failed to insert row into ").append(uri).toString()); } } public static Cursor query(ContentResolver contentresolver, Uri uri, String as[], String s, String as1[], OlioDatabaseHelper oliodatabasehelper) { Object obj1 = uriMatchers.keySet().iterator(); _L4: if (!((Iterator) (obj1)).hasNext()) goto _L2; else goto _L1 _L1: Object obj; int i; obj = (UriMatcher)((Iterator) (obj1)).next(); i = ((UriMatcher) (obj)).match(uri); if (i == -1) goto _L4; else goto _L3 _L3: obj1 = new SQLiteQueryBuilder(); obj = ((com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory)uriMatchers.get(obj)).getRecordInstance(); ((SQLiteQueryBuilder) (obj1)).setTables(((DatabaseRecord) (obj)).tableName()); i; JVM INSTR tableswitch 1 2: default 116 // 1 116 // 2 150; goto _L5 _L5 _L6 _L5: as = ((SQLiteQueryBuilder) (obj1)).query(oliodatabasehelper.getReadableDatabase(), as, s, as1, null, null, ((DatabaseRecord) (obj)).defaultOrderBy()); as.setNotificationUri(contentresolver, uri); return as; _L6: ((SQLiteQueryBuilder) (obj1)).appendWhere((new StringBuilder()).append(((DatabaseRecord) (obj)).indexColumn()).append("=").append((String)uri.getPathSegments().get(1)).toString()); if (true) goto _L5; else goto _L2 _L2: throw new IllegalArgumentException((new StringBuilder()).append("Unknown URI ").append(uri).toString()); } public static int update(ContentResolver contentresolver, Uri uri, ContentValues contentvalues, String s, String as[], OlioDatabaseHelper oliodatabasehelper) { SQLiteDatabase sqlitedatabase; DatabaseRecord databaserecord; boolean flag; int i; ALog.d((new StringBuilder()).append("update called for uri: ").append(uri.toString()).toString(), new Object[0]); sqlitedatabase = oliodatabasehelper.getWritableDatabase(); UriMatcher urimatcher; long l; if (!Objects.equals(uri.getQueryParameter("shouldNotify"), "NO")) { flag = true; } else { flag = false; } if (flag) { oliodatabasehelper = "YES"; } else { oliodatabasehelper = "NO"; } ALog.d("shouldNotify query param = %s", new Object[] { oliodatabasehelper }); l = System.currentTimeMillis(); if (!contentvalues.containsKey("date_modified") || contentvalues.containsKey("date_modified") && contentvalues.getAsLong("date_modified") == null) { contentvalues.put("date_modified", Long.valueOf(l)); } oliodatabasehelper = uriMatchers.keySet().iterator(); do { if (!oliodatabasehelper.hasNext()) { break MISSING_BLOCK_LABEL_467; } urimatcher = (UriMatcher)oliodatabasehelper.next(); i = urimatcher.match(uri); ALog.d("matches = %d", new Object[] { Integer.valueOf(i) }); } while (i == -1); databaserecord = ((com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory)uriMatchers.get(urimatcher)).getRecordInstance(); ALog.d("found a record", new Object[0]); switch (i) { default: throw new IllegalArgumentException((new StringBuilder()).append("Unknown URI ").append(uri).toString()); case 2: // '\002' break MISSING_BLOCK_LABEL_361; case 1: // '\001' i = sqlitedatabase.update(databaserecord.tableName(), contentvalues, s, as); break; } _L1: String s1; if (flag) { contentvalues = "true"; } else { contentvalues = "false"; } ALog.d("count: %d\tshouldNotify: %s", new Object[] { Integer.valueOf(i), contentvalues }); if (flag) { contentresolver.notifyChange(uri.buildUpon().appendQueryParameter("operation", "updated").build(), null); } return i; s1 = (new StringBuilder()).append(databaserecord.indexColumn()).append("=").append((String)uri.getPathSegments().get(1)).toString(); oliodatabasehelper = s1; if (s != null) { oliodatabasehelper = (new StringBuilder()).append(s1).append(" AND ").append(s).toString(); } i = sqlitedatabase.update(databaserecord.tableName(), contentvalues, oliodatabasehelper, as); goto _L1 throw new IllegalArgumentException((new StringBuilder()).append("Unknown URI ").append(uri).toString()); } static { uriMatchers = new HashMap(); com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory adatabaserecordfactory[] = DataContract.getDatabaseTables(); int j = adatabaserecordfactory.length; for (int i = 0; i < j; i++) { com.olio.olios.model.record.DatabaseRecord.DatabaseRecordFactory databaserecordfactory = adatabaserecordfactory[i]; UriMatcher urimatcher = new UriMatcher(-1); urimatcher.addURI("com.olio.olios.model.Data", databaserecordfactory.getRecordInstance().tableName(), 1); urimatcher.addURI("com.olio.olios.model.Data", (new StringBuilder()).append(databaserecordfactory.getRecordInstance().tableName()).append("/#").toString(), 2); uriMatchers.put(urimatcher, databaserecordfactory); } } }