EMMA Coverage Report (generated Sat Sep 03 11:42:34 KST 2005)
[all classes][org.apache.mina.registry]

COVERAGE SUMMARY FOR SOURCE FILE [Service.java]

nameclass, %method, %block, %line, %
Service.java100% (1/1)56%  (5/9)34%  (52/154)44%  (13.5/31)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Service100% (1/1)56%  (5/9)34%  (52/154)44%  (13.5/31)
clone (): Object 0%   (0/1)0%   (0/8)0%   (0/3)
equals (Object): boolean 0%   (0/1)0%   (0/38)0%   (0/8)
getName (): String 0%   (0/1)0%   (0/3)0%   (0/1)
toString (): String 0%   (0/1)0%   (0/22)0%   (0/1)
Service (String, TransportType, SocketAddress): void 100% (1/1)40%  (21/52)65%  (8.5/13)
Service (String, TransportType, int): void 100% (1/1)100% (9/9)100% (2/2)
getAddress (): SocketAddress 100% (1/1)100% (3/3)100% (1/1)
getTransportType (): TransportType 100% (1/1)100% (3/3)100% (1/1)
hashCode (): int 100% (1/1)100% (16/16)100% (1/1)

1/*
2 *   @(#) $Id: Service.java 264677 2005-08-30 02:44:35Z trustin $
3 *
4 *   Copyright 2004 The Apache Software Foundation
5 *
6 *   Licensed under the Apache License, Version 2.0 (the "License");
7 *   you may not use this file except in compliance with the License.
8 *   You may obtain a copy of the License at
9 *
10 *       http://www.apache.org/licenses/LICENSE-2.0
11 *
12 *   Unless required by applicable law or agreed to in writing, software
13 *   distributed under the License is distributed on an "AS IS" BASIS,
14 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 *   See the License for the specific language governing permissions and
16 *   limitations under the License.
17 *
18 */
19package org.apache.mina.registry;
20 
21import java.io.Serializable;
22import java.net.InetSocketAddress;
23import java.net.SocketAddress;
24 
25import org.apache.mina.common.TransportType;
26import org.apache.mina.protocol.vmpipe.VmPipeAddress;
27 
28/**
29 * Represents a service that is registered to {@link ServiceRegistry}.
30 * 
31 * @author Trustin Lee (trustin@apache.org)
32 * @version $Rev: 264677 $, $Date: 2005-08-30 11:44:35 +0900 $
33 */
34public class Service implements Serializable, Cloneable
35{
36    private static final long serialVersionUID = 3258407344110383155L;
37 
38    private final String name;
39 
40    private final TransportType transportType;
41 
42    private final SocketAddress address;
43 
44    /**
45     * Creates a new instance with the specified protocol name, transport type,
46     * and port number to be bound.
47     */
48    public Service( String name, TransportType transportType, int port )
49    {
50        this( name, transportType, new InetSocketAddress( port ) );
51    }
52 
53    /**
54     * Creates a new instance with the specified protocol name, transport type,
55     * and socket address to be bound.
56     */
57    public Service( String name, TransportType transportType, SocketAddress address )
58    {
59        if( name == null )
60            throw new NullPointerException( "name" );
61        if( transportType == null )
62            throw new NullPointerException( "transportType" );
63        if( address == null )
64            throw new NullPointerException( "address" );
65 
66        if( transportType == TransportType.VM_PIPE &&
67            !( address instanceof VmPipeAddress ) )
68        {
69            throw new IllegalArgumentException(
70                    "VM_PIPE transport type accepts only VmPipeAddress: " + address.getClass() );
71        }
72 
73        this.name = name;
74        this.transportType = transportType;
75        this.address = address;
76    }
77 
78    /**
79     * Returns the name of this service (protocol).
80     */
81    public String getName()
82    {
83        return name;
84    }
85 
86    /**
87     * Returns the transport type this service uses.
88     */
89    public TransportType getTransportType()
90    {
91        return transportType;
92    }
93 
94    /**
95     * Returns the socket address this service is bound on.
96     */
97    public SocketAddress getAddress()
98    {
99        return address;
100    }
101 
102    public int hashCode()
103    {
104        return ( ( name.hashCode() * 37 ) ^ transportType.hashCode() * 37 )
105                ^ address.hashCode();
106    }
107 
108    public boolean equals( Object o )
109    {
110        if( o == null )
111            return false;
112        if( this == o )
113            return true;
114        if( !( o instanceof Service ) )
115            return false;
116 
117        Service that = ( Service ) o;
118        return this.name.equals( that.name )
119                && this.transportType == that.transportType
120                && this.address.equals( that.address );
121    }
122 
123    public Object clone()
124    {
125        try
126        {
127            return super.clone();
128        }
129        catch( CloneNotSupportedException e )
130        {
131            throw new InternalError();
132        }
133    }
134    
135    public String toString() {
136        return "(" + transportType + ", " + name + ", " + address + ')';
137    }
138}

[all classes][org.apache.mina.registry]
EMMA 2.0.4217 (C) Vladimir Roubtsov