• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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 com.android.documentsui.clipping;
18 
19 import android.net.Uri;
20 
21 import java.io.File;
22 import java.io.IOException;
23 
24 /**
25  * Interface for clip data URI storage.
26  */
27 public interface ClipStore {
28 
29     /**
30      * Gets a {@link File} instance given a tag.
31      *
32      * This method creates a symbolic link in the slot folder to the data file as a reference
33      * counting method. When someone is done using this symlink, it's responsible to delete it.
34      * Therefore we can have a neat way to track how many things are still using this slot.
35      */
getFile(int tag)36     File getFile(int tag) throws IOException;
37 
38     /**
39      * Returns a Reader. Callers must close the reader when finished.
40      */
createReader(File file)41     ClipStorageReader createReader(File file) throws IOException;
42 
43     /**
44      * Writes the uris to the next available slot, returning the tag for that slot.
45      *
46      * @return int the tag used to store the URIs.
47      */
persistUris(Iterable<Uri> uris)48     int persistUris(Iterable<Uri> uris);
49 }
50