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

COVERAGE SUMMARY FOR SOURCE FILE [AddrUtil.java]

nameclass, %method, %block, %line, %
AddrUtil.java100% (1/1)67%  (2/3)91%  (104/114)94%  (14/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AddrUtil100% (1/1)67%  (2/3)91%  (104/114)94%  (14/15)
AddrUtil (): void 0%   (0/1)0%   (0/3)0%   (0/1)
<static initializer> 100% (1/1)75%  (6/8)75%  (0.8/1)
getAddresses (String): List 100% (1/1)95%  (98/103)96%  (13.5/14)

1package net.spy.memcached;
2 
3import java.net.InetSocketAddress;
4import java.util.ArrayList;
5import java.util.List;
6 
7/**
8 * Convenience utilities for simplifying common address parsing.
9 */
10public class AddrUtil {
11 
12        /**
13         * Split a string in the form of "host:port host2:port" into a List of
14         * InetSocketAddress instances suitable for instantiating a MemcachedClient.
15         *
16         * Note that colon-delimited IPv6 is also supported.
17         * For example:  ::1:11211
18         */
19        public static List<InetSocketAddress> getAddresses(String s) {
20                if(s == null) {
21                        throw new NullPointerException("Null host list");
22                }
23                if(s.trim().equals("")) {
24                        throw new IllegalArgumentException("No hosts in list:  ``"
25                                        + s + "''");
26                }
27                ArrayList<InetSocketAddress> addrs=
28                        new ArrayList<InetSocketAddress>();
29 
30                for(String hoststuff : s.split(" ")) {
31                        int finalColon=hoststuff.lastIndexOf(':');
32                        if(finalColon < 1) {
33                                throw new IllegalArgumentException("Invalid server ``"
34                                        + hoststuff + "'' in list:  " + s);
35 
36                        }
37                        String hostPart=hoststuff.substring(0, finalColon);
38                        String portNum=hoststuff.substring(finalColon+1);
39 
40                        addrs.add(new InetSocketAddress(hostPart,
41                                        Integer.parseInt(portNum)));
42                }
43                assert !addrs.isEmpty() : "No addrs found";
44                return addrs;
45        }
46}

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