Debian Codegraph @

core/java/android/content/Entity.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2009 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
17 package android.content;
18
19 import android.compat.annotation.UnsupportedAppUsage;
20 import android.net.Uri;
21 import android.os.Build;
22
23 import java.util.ArrayList;
24
25 /**
26 * A representation of a item using ContentValues. It contains one top level ContentValue
27 * plus a collection of Uri, ContentValues tuples as subvalues. One example of its use
28 * is in Contacts, where the top level ContentValue contains the columns from the RawContacts
29 * table and the subvalues contain a ContentValues object for each row from the Data table that
30 * corresponds to that RawContact. The uri refers to the Data table uri for each row.
31 */
32 public final class Entity {
33 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
34 final private ContentValues mValues;
35 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
36 final private ArrayList<NamedContentValues> mSubValues;
37
38 public Entity(ContentValues values) {
39 mValues = values;
40 mSubValues = new ArrayList<NamedContentValues>();
41 }
42
43 public ContentValues getEntityValues() {
44 return mValues;
45 }
46
47 public ArrayList<NamedContentValues> getSubValues() {
48 return mSubValues;
49 }
50
51 public void addSubValue(Uri uri, ContentValues values) {
52 mSubValues.add(new Entity.NamedContentValues(uri, values));
53 }
54
55 public static class NamedContentValues {
56 public final Uri uri;
57 public final ContentValues values;
58
59 public NamedContentValues(Uri uri, ContentValues values) {
60 this.uri = uri;
61 this.values = values;
62 }
63 }
64
65 public String toString() {
66 final StringBuilder sb = new StringBuilder();
67 sb.append("Entity: ").append(getEntityValues());
68 for (Entity.NamedContentValues namedValue : getSubValues()) {
69 sb.append("\n ").append(namedValue.uri);
70 sb.append("\n -> ").append(namedValue.values);
71 }
72 return sb.toString();
73 }
74 }