Home | History | Annotate | Download | only in os
      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.os;
     18 
     19 import android.os.Message;
     20 
     21 /** @hide */
     22 public class AsyncResult
     23 {
     24 
     25     /*************************** Instance Variables **************************/
     26 
     27     // Expect either exception or result to be null
     28     public Object userObj;
     29     public Throwable exception;
     30     public Object result;
     31 
     32     /***************************** Class Methods *****************************/
     33 
     34     /** Saves and sets m.obj */
     35     public static AsyncResult
     36     forMessage(Message m, Object r, Throwable ex)
     37     {
     38         AsyncResult ret;
     39 
     40         ret = new AsyncResult (m.obj, r, ex);
     41 
     42         m.obj = ret;
     43 
     44         return ret;
     45     }
     46 
     47     /** Saves and sets m.obj */
     48     public static AsyncResult
     49     forMessage(Message m)
     50     {
     51         AsyncResult ret;
     52 
     53         ret = new AsyncResult (m.obj, null, null);
     54 
     55         m.obj = ret;
     56 
     57         return ret;
     58     }
     59 
     60     /** please note, this sets m.obj to be this */
     61     public
     62     AsyncResult (Object uo, Object r, Throwable ex)
     63     {
     64         userObj = uo;
     65         result = r;
     66         exception = ex;
     67     }
     68 }
     69