Loading core/java/android/content/ContentResolver.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -261,6 +261,13 @@ public abstract class ContentResolver { */ */ public static final String QUERY_ARG_SQL_SORT_ORDER = "android:query-arg-sql-sort-order"; public static final String QUERY_ARG_SQL_SORT_ORDER = "android:query-arg-sql-sort-order"; /** {@hide} */ public static final String QUERY_ARG_SQL_GROUP_BY = "android:query-arg-sql-group-by"; /** {@hide} */ public static final String QUERY_ARG_SQL_HAVING = "android:query-arg-sql-having"; /** {@hide} */ public static final String QUERY_ARG_SQL_LIMIT = "android:query-arg-sql-limit"; /** /** * Specifies the list of columns against which to sort results. When first column values * Specifies the list of columns against which to sort results. When first column values * are identical, records are then sorted based on second column values, and so on. * are identical, records are then sorted based on second column values, and so on. Loading core/java/android/content/ContentValues.java +68 −52 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.content; import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; import android.util.ArrayMap; import android.util.Log; import android.util.Log; import java.util.ArrayList; import java.util.ArrayList; Loading @@ -33,17 +34,21 @@ import java.util.Set; public final class ContentValues implements Parcelable { public final class ContentValues implements Parcelable { public static final String TAG = "ContentValues"; public static final String TAG = "ContentValues"; /** Holds the actual values */ /** * @hide * @deprecated kept around for lame people doing reflection */ @Deprecated @UnsupportedAppUsage @UnsupportedAppUsage private HashMap<String, Object> mValues; private HashMap<String, Object> mValues; private final ArrayMap<String, Object> mMap; /** /** * Creates an empty set of values using the default initial size * Creates an empty set of values using the default initial size */ */ public ContentValues() { public ContentValues() { // Choosing a default size of 8 based on analysis of typical mMap = new ArrayMap<>(); // consumption by applications. mValues = new HashMap<String, Object>(8); } } /** /** Loading @@ -52,7 +57,7 @@ public final class ContentValues implements Parcelable { * @param size the initial size of the set of values * @param size the initial size of the set of values */ */ public ContentValues(int size) { public ContentValues(int size) { mValues = new HashMap<String, Object>(size, 1.0f); mMap = new ArrayMap<>(size); } } /** /** Loading @@ -61,19 +66,24 @@ public final class ContentValues implements Parcelable { * @param from the values to copy * @param from the values to copy */ */ public ContentValues(ContentValues from) { public ContentValues(ContentValues from) { mValues = new HashMap<String, Object>(from.mValues); mMap = new ArrayMap<>(from.mMap); } } /** /** * Creates a set of values copied from the given HashMap. This is used * @hide * by the Parcel unmarshalling code. * @deprecated kept around for lame people doing reflection * * @param values the values to start with * {@hide} */ */ @Deprecated @UnsupportedAppUsage @UnsupportedAppUsage private ContentValues(HashMap<String, Object> values) { private ContentValues(HashMap<String, Object> from) { mValues = values; mMap = new ArrayMap<>(); mMap.putAll(from); } /** {@hide} */ private ContentValues(Parcel in) { mMap = new ArrayMap<>(in.readInt()); in.readArrayMap(mMap, null); } } @Override @Override Loading @@ -81,12 +91,17 @@ public final class ContentValues implements Parcelable { if (!(object instanceof ContentValues)) { if (!(object instanceof ContentValues)) { return false; return false; } } return mValues.equals(((ContentValues) object).mValues); return mMap.equals(((ContentValues) object).mMap); } /** {@hide} */ public ArrayMap<String, Object> getValues() { return mMap; } } @Override @Override public int hashCode() { public int hashCode() { return mValues.hashCode(); return mMap.hashCode(); } } /** /** Loading @@ -96,7 +111,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, String value) { public void put(String key, String value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -105,7 +120,7 @@ public final class ContentValues implements Parcelable { * @param other the ContentValues from which to copy * @param other the ContentValues from which to copy */ */ public void putAll(ContentValues other) { public void putAll(ContentValues other) { mValues.putAll(other.mValues); mMap.putAll(other.mMap); } } /** /** Loading @@ -115,7 +130,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Byte value) { public void put(String key, Byte value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -125,7 +140,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Short value) { public void put(String key, Short value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -135,7 +150,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Integer value) { public void put(String key, Integer value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -145,7 +160,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Long value) { public void put(String key, Long value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -155,7 +170,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Float value) { public void put(String key, Float value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -165,7 +180,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Double value) { public void put(String key, Double value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -175,7 +190,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Boolean value) { public void put(String key, Boolean value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -185,7 +200,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, byte[] value) { public void put(String key, byte[] value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -194,7 +209,7 @@ public final class ContentValues implements Parcelable { * @param key the name of the value to make null * @param key the name of the value to make null */ */ public void putNull(String key) { public void putNull(String key) { mValues.put(key, null); mMap.put(key, null); } } /** /** Loading @@ -203,7 +218,7 @@ public final class ContentValues implements Parcelable { * @return the number of values * @return the number of values */ */ public int size() { public int size() { return mValues.size(); return mMap.size(); } } /** /** Loading @@ -214,7 +229,7 @@ public final class ContentValues implements Parcelable { * TODO: consider exposing this new method publicly * TODO: consider exposing this new method publicly */ */ public boolean isEmpty() { public boolean isEmpty() { return mValues.isEmpty(); return mMap.isEmpty(); } } /** /** Loading @@ -223,14 +238,14 @@ public final class ContentValues implements Parcelable { * @param key the name of the value to remove * @param key the name of the value to remove */ */ public void remove(String key) { public void remove(String key) { mValues.remove(key); mMap.remove(key); } } /** /** * Removes all values. * Removes all values. */ */ public void clear() { public void clear() { mValues.clear(); mMap.clear(); } } /** /** Loading @@ -240,7 +255,7 @@ public final class ContentValues implements Parcelable { * @return {@code true} if the value is present, {@code false} otherwise * @return {@code true} if the value is present, {@code false} otherwise */ */ public boolean containsKey(String key) { public boolean containsKey(String key) { return mValues.containsKey(key); return mMap.containsKey(key); } } /** /** Loading @@ -252,7 +267,7 @@ public final class ContentValues implements Parcelable { * was previously added with the given {@code key} * was previously added with the given {@code key} */ */ public Object get(String key) { public Object get(String key) { return mValues.get(key); return mMap.get(key); } } /** /** Loading @@ -262,7 +277,7 @@ public final class ContentValues implements Parcelable { * @return the String for the value * @return the String for the value */ */ public String getAsString(String key) { public String getAsString(String key) { Object value = mValues.get(key); Object value = mMap.get(key); return value != null ? value.toString() : null; return value != null ? value.toString() : null; } } Loading @@ -273,7 +288,7 @@ public final class ContentValues implements Parcelable { * @return the Long value, or {@code null} if the value is missing or cannot be converted * @return the Long value, or {@code null} if the value is missing or cannot be converted */ */ public Long getAsLong(String key) { public Long getAsLong(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return value != null ? ((Number) value).longValue() : null; return value != null ? ((Number) value).longValue() : null; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading @@ -298,7 +313,7 @@ public final class ContentValues implements Parcelable { * @return the Integer value, or {@code null} if the value is missing or cannot be converted * @return the Integer value, or {@code null} if the value is missing or cannot be converted */ */ public Integer getAsInteger(String key) { public Integer getAsInteger(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return value != null ? ((Number) value).intValue() : null; return value != null ? ((Number) value).intValue() : null; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading @@ -323,7 +338,7 @@ public final class ContentValues implements Parcelable { * @return the Short value, or {@code null} if the value is missing or cannot be converted * @return the Short value, or {@code null} if the value is missing or cannot be converted */ */ public Short getAsShort(String key) { public Short getAsShort(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return value != null ? ((Number) value).shortValue() : null; return value != null ? ((Number) value).shortValue() : null; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading @@ -348,7 +363,7 @@ public final class ContentValues implements Parcelable { * @return the Byte value, or {@code null} if the value is missing or cannot be converted * @return the Byte value, or {@code null} if the value is missing or cannot be converted */ */ public Byte getAsByte(String key) { public Byte getAsByte(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return value != null ? ((Number) value).byteValue() : null; return value != null ? ((Number) value).byteValue() : null; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading @@ -373,7 +388,7 @@ public final class ContentValues implements Parcelable { * @return the Double value, or {@code null} if the value is missing or cannot be converted * @return the Double value, or {@code null} if the value is missing or cannot be converted */ */ public Double getAsDouble(String key) { public Double getAsDouble(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return value != null ? ((Number) value).doubleValue() : null; return value != null ? ((Number) value).doubleValue() : null; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading @@ -398,7 +413,7 @@ public final class ContentValues implements Parcelable { * @return the Float value, or {@code null} if the value is missing or cannot be converted * @return the Float value, or {@code null} if the value is missing or cannot be converted */ */ public Float getAsFloat(String key) { public Float getAsFloat(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return value != null ? ((Number) value).floatValue() : null; return value != null ? ((Number) value).floatValue() : null; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading @@ -423,7 +438,7 @@ public final class ContentValues implements Parcelable { * @return the Boolean value, or {@code null} if the value is missing or cannot be converted * @return the Boolean value, or {@code null} if the value is missing or cannot be converted */ */ public Boolean getAsBoolean(String key) { public Boolean getAsBoolean(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return (Boolean) value; return (Boolean) value; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading Loading @@ -451,7 +466,7 @@ public final class ContentValues implements Parcelable { * {@code byte[]} * {@code byte[]} */ */ public byte[] getAsByteArray(String key) { public byte[] getAsByteArray(String key) { Object value = mValues.get(key); Object value = mMap.get(key); if (value instanceof byte[]) { if (value instanceof byte[]) { return (byte[]) value; return (byte[]) value; } else { } else { Loading @@ -465,7 +480,7 @@ public final class ContentValues implements Parcelable { * @return a set of all of the keys and values * @return a set of all of the keys and values */ */ public Set<Map.Entry<String, Object>> valueSet() { public Set<Map.Entry<String, Object>> valueSet() { return mValues.entrySet(); return mMap.entrySet(); } } /** /** Loading @@ -474,30 +489,31 @@ public final class ContentValues implements Parcelable { * @return a set of all of the keys * @return a set of all of the keys */ */ public Set<String> keySet() { public Set<String> keySet() { return mValues.keySet(); return mMap.keySet(); } } public static final Parcelable.Creator<ContentValues> CREATOR = public static final Parcelable.Creator<ContentValues> CREATOR = new Parcelable.Creator<ContentValues>() { new Parcelable.Creator<ContentValues>() { @SuppressWarnings({"deprecation", "unchecked"}) @Override public ContentValues createFromParcel(Parcel in) { public ContentValues createFromParcel(Parcel in) { // TODO - what ClassLoader should be passed to readHashMap? return new ContentValues(in); HashMap<String, Object> values = in.readHashMap(null); return new ContentValues(values); } } @Override public ContentValues[] newArray(int size) { public ContentValues[] newArray(int size) { return new ContentValues[size]; return new ContentValues[size]; } } }; }; @Override public int describeContents() { public int describeContents() { return 0; return 0; } } @SuppressWarnings("deprecation") @Override public void writeToParcel(Parcel parcel, int flags) { public void writeToParcel(Parcel parcel, int flags) { parcel.writeMap(mValues); parcel.writeInt(mMap.size()); parcel.writeArrayMap(mMap); } } /** /** Loading @@ -507,7 +523,7 @@ public final class ContentValues implements Parcelable { @Deprecated @Deprecated @UnsupportedAppUsage @UnsupportedAppUsage public void putStringArrayList(String key, ArrayList<String> value) { public void putStringArrayList(String key, ArrayList<String> value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -518,7 +534,7 @@ public final class ContentValues implements Parcelable { @Deprecated @Deprecated @UnsupportedAppUsage @UnsupportedAppUsage public ArrayList<String> getStringArrayList(String key) { public ArrayList<String> getStringArrayList(String key) { return (ArrayList<String>) mValues.get(key); return (ArrayList<String>) mMap.get(key); } } /** /** Loading @@ -528,7 +544,7 @@ public final class ContentValues implements Parcelable { @Override @Override public String toString() { public String toString() { StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder(); for (String name : mValues.keySet()) { for (String name : mMap.keySet()) { String value = getAsString(name); String value = getAsString(name); if (sb.length() > 0) sb.append(" "); if (sb.length() > 0) sb.append(" "); sb.append(name + "=" + value); sb.append(name + "=" + value); Loading core/java/android/database/sqlite/SQLiteDatabase.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -193,8 +193,9 @@ public final class SQLiteDatabase extends SQLiteClosable { */ */ public static final int CONFLICT_NONE = 0; public static final int CONFLICT_NONE = 0; /** {@hide} */ @UnsupportedAppUsage @UnsupportedAppUsage private static final String[] CONFLICT_VALUES = new String[] public static final String[] CONFLICT_VALUES = new String[] {"", " OR ROLLBACK ", " OR ABORT ", " OR FAIL ", " OR IGNORE ", " OR REPLACE "}; {"", " OR ROLLBACK ", " OR ABORT ", " OR FAIL ", " OR IGNORE ", " OR REPLACE "}; /** /** Loading core/java/android/database/sqlite/SQLiteStatementBuilder.java 0 → 100644 +1036 −0 File added.Preview size limit exceeded, changes collapsed. Show changes core/java/com/android/internal/util/ArrayUtils.java +17 −0 Original line number Original line Diff line number Diff line Loading @@ -308,6 +308,23 @@ public class ArrayUtils { return array; return array; } } @SuppressWarnings("unchecked") public static @NonNull <T> T[] concat(Class<T> kind, @Nullable T[] a, @Nullable T[] b) { final int an = (a != null) ? a.length : 0; final int bn = (b != null) ? b.length : 0; if (an == 0 && bn == 0) { if (kind == String.class) { return (T[]) EmptyArray.STRING; } else if (kind == Object.class) { return (T[]) EmptyArray.OBJECT; } } final T[] res = (T[]) Array.newInstance(kind, an + bn); if (an > 0) System.arraycopy(a, 0, res, 0, an); if (bn > 0) System.arraycopy(b, 0, res, an, bn); return res; } /** /** * Adds value to given array if not already present, providing set-like * Adds value to given array if not already present, providing set-like * behavior. * behavior. Loading Loading
core/java/android/content/ContentResolver.java +7 −0 Original line number Original line Diff line number Diff line Loading @@ -261,6 +261,13 @@ public abstract class ContentResolver { */ */ public static final String QUERY_ARG_SQL_SORT_ORDER = "android:query-arg-sql-sort-order"; public static final String QUERY_ARG_SQL_SORT_ORDER = "android:query-arg-sql-sort-order"; /** {@hide} */ public static final String QUERY_ARG_SQL_GROUP_BY = "android:query-arg-sql-group-by"; /** {@hide} */ public static final String QUERY_ARG_SQL_HAVING = "android:query-arg-sql-having"; /** {@hide} */ public static final String QUERY_ARG_SQL_LIMIT = "android:query-arg-sql-limit"; /** /** * Specifies the list of columns against which to sort results. When first column values * Specifies the list of columns against which to sort results. When first column values * are identical, records are then sorted based on second column values, and so on. * are identical, records are then sorted based on second column values, and so on. Loading
core/java/android/content/ContentValues.java +68 −52 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.content; import android.annotation.UnsupportedAppUsage; import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; import android.util.ArrayMap; import android.util.Log; import android.util.Log; import java.util.ArrayList; import java.util.ArrayList; Loading @@ -33,17 +34,21 @@ import java.util.Set; public final class ContentValues implements Parcelable { public final class ContentValues implements Parcelable { public static final String TAG = "ContentValues"; public static final String TAG = "ContentValues"; /** Holds the actual values */ /** * @hide * @deprecated kept around for lame people doing reflection */ @Deprecated @UnsupportedAppUsage @UnsupportedAppUsage private HashMap<String, Object> mValues; private HashMap<String, Object> mValues; private final ArrayMap<String, Object> mMap; /** /** * Creates an empty set of values using the default initial size * Creates an empty set of values using the default initial size */ */ public ContentValues() { public ContentValues() { // Choosing a default size of 8 based on analysis of typical mMap = new ArrayMap<>(); // consumption by applications. mValues = new HashMap<String, Object>(8); } } /** /** Loading @@ -52,7 +57,7 @@ public final class ContentValues implements Parcelable { * @param size the initial size of the set of values * @param size the initial size of the set of values */ */ public ContentValues(int size) { public ContentValues(int size) { mValues = new HashMap<String, Object>(size, 1.0f); mMap = new ArrayMap<>(size); } } /** /** Loading @@ -61,19 +66,24 @@ public final class ContentValues implements Parcelable { * @param from the values to copy * @param from the values to copy */ */ public ContentValues(ContentValues from) { public ContentValues(ContentValues from) { mValues = new HashMap<String, Object>(from.mValues); mMap = new ArrayMap<>(from.mMap); } } /** /** * Creates a set of values copied from the given HashMap. This is used * @hide * by the Parcel unmarshalling code. * @deprecated kept around for lame people doing reflection * * @param values the values to start with * {@hide} */ */ @Deprecated @UnsupportedAppUsage @UnsupportedAppUsage private ContentValues(HashMap<String, Object> values) { private ContentValues(HashMap<String, Object> from) { mValues = values; mMap = new ArrayMap<>(); mMap.putAll(from); } /** {@hide} */ private ContentValues(Parcel in) { mMap = new ArrayMap<>(in.readInt()); in.readArrayMap(mMap, null); } } @Override @Override Loading @@ -81,12 +91,17 @@ public final class ContentValues implements Parcelable { if (!(object instanceof ContentValues)) { if (!(object instanceof ContentValues)) { return false; return false; } } return mValues.equals(((ContentValues) object).mValues); return mMap.equals(((ContentValues) object).mMap); } /** {@hide} */ public ArrayMap<String, Object> getValues() { return mMap; } } @Override @Override public int hashCode() { public int hashCode() { return mValues.hashCode(); return mMap.hashCode(); } } /** /** Loading @@ -96,7 +111,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, String value) { public void put(String key, String value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -105,7 +120,7 @@ public final class ContentValues implements Parcelable { * @param other the ContentValues from which to copy * @param other the ContentValues from which to copy */ */ public void putAll(ContentValues other) { public void putAll(ContentValues other) { mValues.putAll(other.mValues); mMap.putAll(other.mMap); } } /** /** Loading @@ -115,7 +130,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Byte value) { public void put(String key, Byte value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -125,7 +140,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Short value) { public void put(String key, Short value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -135,7 +150,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Integer value) { public void put(String key, Integer value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -145,7 +160,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Long value) { public void put(String key, Long value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -155,7 +170,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Float value) { public void put(String key, Float value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -165,7 +180,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Double value) { public void put(String key, Double value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -175,7 +190,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, Boolean value) { public void put(String key, Boolean value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -185,7 +200,7 @@ public final class ContentValues implements Parcelable { * @param value the data for the value to put * @param value the data for the value to put */ */ public void put(String key, byte[] value) { public void put(String key, byte[] value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -194,7 +209,7 @@ public final class ContentValues implements Parcelable { * @param key the name of the value to make null * @param key the name of the value to make null */ */ public void putNull(String key) { public void putNull(String key) { mValues.put(key, null); mMap.put(key, null); } } /** /** Loading @@ -203,7 +218,7 @@ public final class ContentValues implements Parcelable { * @return the number of values * @return the number of values */ */ public int size() { public int size() { return mValues.size(); return mMap.size(); } } /** /** Loading @@ -214,7 +229,7 @@ public final class ContentValues implements Parcelable { * TODO: consider exposing this new method publicly * TODO: consider exposing this new method publicly */ */ public boolean isEmpty() { public boolean isEmpty() { return mValues.isEmpty(); return mMap.isEmpty(); } } /** /** Loading @@ -223,14 +238,14 @@ public final class ContentValues implements Parcelable { * @param key the name of the value to remove * @param key the name of the value to remove */ */ public void remove(String key) { public void remove(String key) { mValues.remove(key); mMap.remove(key); } } /** /** * Removes all values. * Removes all values. */ */ public void clear() { public void clear() { mValues.clear(); mMap.clear(); } } /** /** Loading @@ -240,7 +255,7 @@ public final class ContentValues implements Parcelable { * @return {@code true} if the value is present, {@code false} otherwise * @return {@code true} if the value is present, {@code false} otherwise */ */ public boolean containsKey(String key) { public boolean containsKey(String key) { return mValues.containsKey(key); return mMap.containsKey(key); } } /** /** Loading @@ -252,7 +267,7 @@ public final class ContentValues implements Parcelable { * was previously added with the given {@code key} * was previously added with the given {@code key} */ */ public Object get(String key) { public Object get(String key) { return mValues.get(key); return mMap.get(key); } } /** /** Loading @@ -262,7 +277,7 @@ public final class ContentValues implements Parcelable { * @return the String for the value * @return the String for the value */ */ public String getAsString(String key) { public String getAsString(String key) { Object value = mValues.get(key); Object value = mMap.get(key); return value != null ? value.toString() : null; return value != null ? value.toString() : null; } } Loading @@ -273,7 +288,7 @@ public final class ContentValues implements Parcelable { * @return the Long value, or {@code null} if the value is missing or cannot be converted * @return the Long value, or {@code null} if the value is missing or cannot be converted */ */ public Long getAsLong(String key) { public Long getAsLong(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return value != null ? ((Number) value).longValue() : null; return value != null ? ((Number) value).longValue() : null; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading @@ -298,7 +313,7 @@ public final class ContentValues implements Parcelable { * @return the Integer value, or {@code null} if the value is missing or cannot be converted * @return the Integer value, or {@code null} if the value is missing or cannot be converted */ */ public Integer getAsInteger(String key) { public Integer getAsInteger(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return value != null ? ((Number) value).intValue() : null; return value != null ? ((Number) value).intValue() : null; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading @@ -323,7 +338,7 @@ public final class ContentValues implements Parcelable { * @return the Short value, or {@code null} if the value is missing or cannot be converted * @return the Short value, or {@code null} if the value is missing or cannot be converted */ */ public Short getAsShort(String key) { public Short getAsShort(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return value != null ? ((Number) value).shortValue() : null; return value != null ? ((Number) value).shortValue() : null; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading @@ -348,7 +363,7 @@ public final class ContentValues implements Parcelable { * @return the Byte value, or {@code null} if the value is missing or cannot be converted * @return the Byte value, or {@code null} if the value is missing or cannot be converted */ */ public Byte getAsByte(String key) { public Byte getAsByte(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return value != null ? ((Number) value).byteValue() : null; return value != null ? ((Number) value).byteValue() : null; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading @@ -373,7 +388,7 @@ public final class ContentValues implements Parcelable { * @return the Double value, or {@code null} if the value is missing or cannot be converted * @return the Double value, or {@code null} if the value is missing or cannot be converted */ */ public Double getAsDouble(String key) { public Double getAsDouble(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return value != null ? ((Number) value).doubleValue() : null; return value != null ? ((Number) value).doubleValue() : null; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading @@ -398,7 +413,7 @@ public final class ContentValues implements Parcelable { * @return the Float value, or {@code null} if the value is missing or cannot be converted * @return the Float value, or {@code null} if the value is missing or cannot be converted */ */ public Float getAsFloat(String key) { public Float getAsFloat(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return value != null ? ((Number) value).floatValue() : null; return value != null ? ((Number) value).floatValue() : null; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading @@ -423,7 +438,7 @@ public final class ContentValues implements Parcelable { * @return the Boolean value, or {@code null} if the value is missing or cannot be converted * @return the Boolean value, or {@code null} if the value is missing or cannot be converted */ */ public Boolean getAsBoolean(String key) { public Boolean getAsBoolean(String key) { Object value = mValues.get(key); Object value = mMap.get(key); try { try { return (Boolean) value; return (Boolean) value; } catch (ClassCastException e) { } catch (ClassCastException e) { Loading Loading @@ -451,7 +466,7 @@ public final class ContentValues implements Parcelable { * {@code byte[]} * {@code byte[]} */ */ public byte[] getAsByteArray(String key) { public byte[] getAsByteArray(String key) { Object value = mValues.get(key); Object value = mMap.get(key); if (value instanceof byte[]) { if (value instanceof byte[]) { return (byte[]) value; return (byte[]) value; } else { } else { Loading @@ -465,7 +480,7 @@ public final class ContentValues implements Parcelable { * @return a set of all of the keys and values * @return a set of all of the keys and values */ */ public Set<Map.Entry<String, Object>> valueSet() { public Set<Map.Entry<String, Object>> valueSet() { return mValues.entrySet(); return mMap.entrySet(); } } /** /** Loading @@ -474,30 +489,31 @@ public final class ContentValues implements Parcelable { * @return a set of all of the keys * @return a set of all of the keys */ */ public Set<String> keySet() { public Set<String> keySet() { return mValues.keySet(); return mMap.keySet(); } } public static final Parcelable.Creator<ContentValues> CREATOR = public static final Parcelable.Creator<ContentValues> CREATOR = new Parcelable.Creator<ContentValues>() { new Parcelable.Creator<ContentValues>() { @SuppressWarnings({"deprecation", "unchecked"}) @Override public ContentValues createFromParcel(Parcel in) { public ContentValues createFromParcel(Parcel in) { // TODO - what ClassLoader should be passed to readHashMap? return new ContentValues(in); HashMap<String, Object> values = in.readHashMap(null); return new ContentValues(values); } } @Override public ContentValues[] newArray(int size) { public ContentValues[] newArray(int size) { return new ContentValues[size]; return new ContentValues[size]; } } }; }; @Override public int describeContents() { public int describeContents() { return 0; return 0; } } @SuppressWarnings("deprecation") @Override public void writeToParcel(Parcel parcel, int flags) { public void writeToParcel(Parcel parcel, int flags) { parcel.writeMap(mValues); parcel.writeInt(mMap.size()); parcel.writeArrayMap(mMap); } } /** /** Loading @@ -507,7 +523,7 @@ public final class ContentValues implements Parcelable { @Deprecated @Deprecated @UnsupportedAppUsage @UnsupportedAppUsage public void putStringArrayList(String key, ArrayList<String> value) { public void putStringArrayList(String key, ArrayList<String> value) { mValues.put(key, value); mMap.put(key, value); } } /** /** Loading @@ -518,7 +534,7 @@ public final class ContentValues implements Parcelable { @Deprecated @Deprecated @UnsupportedAppUsage @UnsupportedAppUsage public ArrayList<String> getStringArrayList(String key) { public ArrayList<String> getStringArrayList(String key) { return (ArrayList<String>) mValues.get(key); return (ArrayList<String>) mMap.get(key); } } /** /** Loading @@ -528,7 +544,7 @@ public final class ContentValues implements Parcelable { @Override @Override public String toString() { public String toString() { StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder(); for (String name : mValues.keySet()) { for (String name : mMap.keySet()) { String value = getAsString(name); String value = getAsString(name); if (sb.length() > 0) sb.append(" "); if (sb.length() > 0) sb.append(" "); sb.append(name + "=" + value); sb.append(name + "=" + value); Loading
core/java/android/database/sqlite/SQLiteDatabase.java +2 −1 Original line number Original line Diff line number Diff line Loading @@ -193,8 +193,9 @@ public final class SQLiteDatabase extends SQLiteClosable { */ */ public static final int CONFLICT_NONE = 0; public static final int CONFLICT_NONE = 0; /** {@hide} */ @UnsupportedAppUsage @UnsupportedAppUsage private static final String[] CONFLICT_VALUES = new String[] public static final String[] CONFLICT_VALUES = new String[] {"", " OR ROLLBACK ", " OR ABORT ", " OR FAIL ", " OR IGNORE ", " OR REPLACE "}; {"", " OR ROLLBACK ", " OR ABORT ", " OR FAIL ", " OR IGNORE ", " OR REPLACE "}; /** /** Loading
core/java/android/database/sqlite/SQLiteStatementBuilder.java 0 → 100644 +1036 −0 File added.Preview size limit exceeded, changes collapsed. Show changes
core/java/com/android/internal/util/ArrayUtils.java +17 −0 Original line number Original line Diff line number Diff line Loading @@ -308,6 +308,23 @@ public class ArrayUtils { return array; return array; } } @SuppressWarnings("unchecked") public static @NonNull <T> T[] concat(Class<T> kind, @Nullable T[] a, @Nullable T[] b) { final int an = (a != null) ? a.length : 0; final int bn = (b != null) ? b.length : 0; if (an == 0 && bn == 0) { if (kind == String.class) { return (T[]) EmptyArray.STRING; } else if (kind == Object.class) { return (T[]) EmptyArray.OBJECT; } } final T[] res = (T[]) Array.newInstance(kind, an + bn); if (an > 0) System.arraycopy(a, 0, res, 0, an); if (bn > 0) System.arraycopy(b, 0, res, an, bn); return res; } /** /** * Adds value to given array if not already present, providing set-like * Adds value to given array if not already present, providing set-like * behavior. * behavior. Loading