W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
DataHandler<T>
是數(shù)據(jù)處理器定義描述,定義了請求結(jié)果處理能力。該接口的所有代碼如下。
/*
* Copyright (C) 2016-2017 mzlion(mzllon@qq.com).
*
* 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 com.mzlion.easyokhttp.response.handle;
import java.io.IOException;
/**
* 數(shù)據(jù)處理定義接口,將得到的響應(yīng)結(jié)果轉(zhuǎn)為所需的數(shù)據(jù)
*
* @author mzlion on 2016/12/14.
* @see JsonDataHandler
* @see StringDataHandler
*/
public interface DataHandler<T> {
/**
* 得到相應(yīng)結(jié)果后,將相應(yīng)數(shù)據(jù)轉(zhuǎn)為需要的數(shù)據(jù)格式
*
* @param response 需要轉(zhuǎn)換的對象
* @return 轉(zhuǎn)換結(jié)果
* @throws IOException 出現(xiàn)異常
*/
T handle(final okhttp3.Response response) throws IOException;
}
所以該接口只有一個函數(shù),該函數(shù)提供了將原始數(shù)據(jù)格式轉(zhuǎn)為業(yè)務(wù)所需數(shù)據(jù)格式,框架提供了常用接口處理器實現(xiàn),若以下的處理器無法滿足需求可以自己實現(xiàn)一個處理器。Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: