Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c41bda0 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Annotation for ContentProvider columns.

We have various "contract" classes across the OS which describe the
columns that are available for insert(), update(), and query() when
working with ContentProviders.

To help ensure that the underlying providers fully support the API
contracts being made, this change defines a new "@Column" annotation
which describes the underlying data type.

These annotations can then be used by the ContentProvider
implementations internally to ensure that they're fully meeting the
API contracts being made.

A future change will also wire up these annotations to be
automatically documented by doclava.

Bug: 120429729
Test: manual
Change-Id: Ie3d97937500cec05396c809ba2ea2e62d1b737fd
parent 0ec586b9
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -16,17 +16,18 @@

package android.provider;

public interface BaseColumns
{
import android.database.Cursor;

public interface BaseColumns {
    /**
     * The unique ID for a row.
     * <P>Type: INTEGER (long)</P>
     */
    @Column(Cursor.FIELD_TYPE_INTEGER)
    public static final String _ID = "_id";

    /**
     * The count of rows in a directory.
     * <P>Type: INTEGER</P>
     */
    // @Column(Cursor.FIELD_TYPE_INTEGER)
    public static final String _COUNT = "_count";
}
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.provider;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
 * Denotes that a field is a {@link ContentProvider} column. It can be used as a
 * key for {@link ContentValues} when inserting or updating data, or as a
 * projection when querying.
 *
 * @hide
 */
@Documented
@Retention(RUNTIME)
@Target({FIELD})
public @interface Column {
    /**
     * The {@link Cursor#getType(int)} of the data stored in this column.
     */
    int value();

    /**
     * This column is read-only and cannot be defined during insert or updates.
     */
    boolean readOnly() default false;
}
+168 −143

File changed.

Preview size limit exceeded, changes collapsed.