com.duowan.mobile.netroid.toolbox
Class BasicNetwork

java.lang.Object
  extended by com.duowan.mobile.netroid.toolbox.BasicNetwork
All Implemented Interfaces:
Network

public class BasicNetwork
extends java.lang.Object
implements Network

A network performing Netroid requests over an HttpStack.


Field Summary
protected static boolean DEBUG
           
 
Constructor Summary
BasicNetwork(HttpStack httpStack, int bytePoolSize, java.lang.String defaultCharset)
           
BasicNetwork(HttpStack httpStack, java.lang.String defaultCharset)
           
 
Method Summary
 java.lang.String getDefaultCharset()
           
protected  void logError(java.lang.String what, java.lang.String url, long start)
           
 NetworkResponse performRequest(Request<?> request)
          Performs the specified request.
 void setDelivery(Delivery delivery)
          Set the request delivery that use to post http networking callbacks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

protected static final boolean DEBUG
Constructor Detail

BasicNetwork

public BasicNetwork(HttpStack httpStack,
                    java.lang.String defaultCharset)
Parameters:
httpStack - HTTP stack to be used
defaultCharset - default charset if response does not provided.

BasicNetwork

public BasicNetwork(HttpStack httpStack,
                    int bytePoolSize,
                    java.lang.String defaultCharset)
Parameters:
httpStack - HTTP stack to be used
bytePoolSize - Size of buffer pool that improves GC performance in copy operations.
defaultCharset - when Http Header doesn't offer the 'Content-Type:Charset', it will be use.
Method Detail

setDelivery

public void setDelivery(Delivery delivery)
Description copied from interface: Network
Set the request delivery that use to post http networking callbacks.

Specified by:
setDelivery in interface Network

performRequest

public NetworkResponse performRequest(Request<?> request)
                               throws NetroidError
Description copied from interface: Network
Performs the specified request.

Specified by:
performRequest in interface Network
Parameters:
request - Request to process
Returns:
A NetworkResponse with data and caching metadata; will never be null
Throws:
NetroidError - on errors

logError

protected void logError(java.lang.String what,
                        java.lang.String url,
                        long start)

getDefaultCharset

public java.lang.String getDefaultCharset()