EMMA Coverage Report (generated Tue Oct 27 11:32:50 PDT 2009)
[all classes][net.spy.memcached.protocol.ascii]

COVERAGE SUMMARY FOR SOURCE FILE [StatsOperationImpl.java]

nameclass, %method, %block, %line, %
StatsOperationImpl.java100% (1/1)80%  (4/5)88%  (80/91)88%  (17.6/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class StatsOperationImpl100% (1/1)80%  (4/5)88%  (80/91)88%  (17.6/20)
wasCancelled (): void 0%   (0/1)0%   (0/5)0%   (0/2)
<static initializer> 100% (1/1)88%  (15/17)96%  (2.9/3)
handleLine (String): void 100% (1/1)89%  (33/37)96%  (6.7/7)
StatsOperationImpl (String, StatsOperation$Callback): void 100% (1/1)100% (26/26)100% (6/6)
initialize (): void 100% (1/1)100% (6/6)100% (2/2)

1// Copyright (c) 2006  Dustin Sallings <dustin@spy.net>
2 
3package net.spy.memcached.protocol.ascii;
4 
5import java.nio.ByteBuffer;
6 
7import net.spy.memcached.ops.OperationState;
8import net.spy.memcached.ops.OperationStatus;
9import net.spy.memcached.ops.StatsOperation;
10 
11/**
12 * Operation to retrieve statistics from a memcached server.
13 */
14final class StatsOperationImpl extends OperationImpl
15        implements StatsOperation {
16 
17        private static final OperationStatus END=new OperationStatus(true, "END");
18 
19        private static final byte[] MSG="stats\r\n".getBytes();
20 
21        private final byte[] msg;
22        private final StatsOperation.Callback cb;
23 
24        public StatsOperationImpl(String arg, StatsOperation.Callback c) {
25                super(c);
26                cb=c;
27                if(arg == null) {
28                        msg=MSG;
29                } else {
30                        msg=("stats " + arg + "\r\n").getBytes();
31                }
32        }
33 
34        @Override
35        public void handleLine(String line) {
36                if(line.equals("END")) {
37                        cb.receivedStatus(END);
38                        transitionState(OperationState.COMPLETE);
39                } else {
40                        String[] parts=line.split(" ", 3);
41                        assert parts.length == 3;
42                        cb.gotStat(parts[1], parts[2]);
43                }
44        }
45 
46        @Override
47        public void initialize() {
48                setBuffer(ByteBuffer.wrap(msg));
49        }
50 
51        @Override
52        protected void wasCancelled() {
53                cb.receivedStatus(CANCELLED);
54        }
55 
56}

[all classes][net.spy.memcached.protocol.ascii]
EMMA 2.0.5312 (C) Vladimir Roubtsov