FileDocCategorySizeDatePackage
HttpConnectionMetricsImpl.javaAPI DocAndroid 1.5 API5024Wed May 06 22:41:10 BST 2009org.apache.http.impl

HttpConnectionMetricsImpl

public class HttpConnectionMetricsImpl extends Object implements HttpConnectionMetrics
Implementation of the metrics interface.

Fields Summary
public static final String
REQUEST_COUNT
public static final String
RESPONSE_COUNT
public static final String
SENT_BYTES_COUNT
public static final String
RECEIVED_BYTES_COUNT
private final HttpTransportMetrics
inTransportMetric
private final HttpTransportMetrics
outTransportMetric
private long
requestCount
private long
responseCount
private HashMap
metricsCache
The cache map for all metrics values.
Constructors Summary
public HttpConnectionMetricsImpl(HttpTransportMetrics inTransportMetric, HttpTransportMetrics outTransportMetric)

    
     
              
               
        super();
        this.inTransportMetric = inTransportMetric;
        this.outTransportMetric = outTransportMetric;
    
Methods Summary
public java.lang.ObjectgetMetric(java.lang.String metricName)

        Object value = null;
        if (this.metricsCache != null) {
            value = this.metricsCache.get(metricName);
        }
        if (value == null) {
            if (REQUEST_COUNT.equals(metricName)) {
                value = new Long(requestCount);
            } else if (RESPONSE_COUNT.equals(metricName)) {
                value = new Long(responseCount);
            } else if (RECEIVED_BYTES_COUNT.equals(metricName)) {
                if (this.inTransportMetric != null) {
                    return new Long(this.inTransportMetric.getBytesTransferred());
                } else {
                    return null;
                }
            } else if (SENT_BYTES_COUNT.equals(metricName)) {
                if (this.outTransportMetric != null) {
                    return new Long(this.outTransportMetric.getBytesTransferred());
                } else {
                    return null;
                }
            }
        }
        return value;
    
public longgetReceivedBytesCount()

        if (this.inTransportMetric != null) {
            return this.inTransportMetric.getBytesTransferred();
        } else {
            return -1;
        }
    
public longgetRequestCount()

        return this.requestCount;
    
public longgetResponseCount()

        return this.responseCount;
    
public longgetSentBytesCount()

        if (this.outTransportMetric != null) {
            return this.outTransportMetric.getBytesTransferred();
        } else {
            return -1;
        }
    
public voidincrementRequestCount()

        this.requestCount++;
    
public voidincrementResponseCount()

        this.responseCount++;
    
public voidreset()

        if (this.outTransportMetric != null) {
            this.outTransportMetric.reset();
        }
        if (this.inTransportMetric != null) {
            this.inTransportMetric.reset();
        }
        this.requestCount = 0;
        this.responseCount = 0;
        this.metricsCache = null;
    
public voidsetMetric(java.lang.String metricName, java.lang.Object obj)

        if (this.metricsCache == null) {
            this.metricsCache = new HashMap();
        }
        this.metricsCache.put(metricName, obj);