Home | History | Annotate | Download | only in content
      1 /*
      2  * Copyright (C) 2013 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 /**
     20  * Representation of an owner of {@link UndoOperation} objects in an {@link UndoManager}.
     21  *
     22  * @hide
     23  */
     24 public class UndoOwner {
     25     final String mTag;
     26     final UndoManager mManager;
     27 
     28     Object mData;
     29     int mOpCount;
     30 
     31     // For saving/restoring state.
     32     int mStateSeq;
     33     int mSavedIdx;
     34 
     35     UndoOwner(String tag, UndoManager manager) {
     36         if (tag == null) {
     37             throw new NullPointerException("tag can't be null");
     38         }
     39         if (manager == null) {
     40             throw new NullPointerException("manager can't be null");
     41         }
     42         mTag = tag;
     43         mManager = manager;
     44     }
     45 
     46     /**
     47      * Return the unique tag name identifying this owner.  This is the tag
     48      * supplied to {@link UndoManager#getOwner(String, Object) UndoManager.getOwner}
     49      * and is immutable.
     50      */
     51     public String getTag() {
     52         return mTag;
     53     }
     54 
     55     /**
     56      * Return the actual data object of the owner.  This is the data object
     57      * supplied to {@link UndoManager#getOwner(String, Object) UndoManager.getOwner}.  An
     58      * owner may have a null data if it was restored from a previously saved state with
     59      * no getOwner call to associate it with its data.
     60      */
     61     public Object getData() {
     62         return mData;
     63     }
     64 
     65     @Override
     66     public String toString() {
     67         return "UndoOwner:[mTag=" + mTag +
     68                 " mManager=" + mManager +
     69                 " mData=" + mData +
     70                 " mData=" + mData +
     71                 " mOpCount=" + mOpCount +
     72                 " mStateSeq=" + mStateSeq +
     73                 " mSavedIdx=" + mSavedIdx + "]";
     74     }
     75 }
     76