1 /*
2  * Copyright (C) 2006 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.webkit;
18 
19 import android.annotation.Nullable;
20 
21 import java.io.Serializable;
22 
23 /**
24  * This class contains the back/forward list for a WebView.
25  * WebView.copyBackForwardList() will return a copy of this class used to
26  * inspect the entries in the list.
27  */
28 public abstract class WebBackForwardList implements Cloneable, Serializable {
29     /**
30      * Return the current history item. This method returns {@code null} if the list is
31      * empty.
32      * @return The current history item.
33      */
34     @Nullable
getCurrentItem()35     public abstract WebHistoryItem getCurrentItem();
36 
37     /**
38      * Get the index of the current history item. This index can be used to
39      * directly index into the array list.
40      * @return The current index from 0...n or -1 if the list is empty.
41      */
getCurrentIndex()42     public abstract int getCurrentIndex();
43 
44     /**
45      * Get the history item at the given index. The index range is from 0...n
46      * where 0 is the first item and n is the last item.
47      * @param index The index to retrieve.
48      */
getItemAtIndex(int index)49     public abstract WebHistoryItem getItemAtIndex(int index);
50 
51     /**
52      * Get the total size of the back/forward list.
53      * @return The size of the list.
54      */
getSize()55     public abstract int getSize();
56 
57     /**
58      * Clone the entire object to be used in the UI thread by clients of
59      * WebView. This creates a copy that should never be modified by any of the
60      * webkit package classes. On Android 4.4 and later there is no need to use
61      * this, as the object is already a read-only copy of the internal state.
62      */
clone()63     protected abstract WebBackForwardList clone();
64 }
65