KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > phoenix > metainfo > ServiceDescriptor


1 /*
2  * Copyright (C) The Apache Software Foundation. All rights reserved.
3  *
4  * This software is published under the terms of the Apache Software License
5  * version 1.1, a copy of which has been included with this distribution in
6  * the LICENSE.txt file.
7  */

8 package org.apache.avalon.phoenix.metainfo;
9
10 import org.apache.avalon.framework.Version;
11
12 /**
13  * This class describes the meta info of a service offered by a Block.
14  * Each service is defined by an interface name and the version of that
15  * interface.
16  *
17  * @author <a HREF="mailto:peter at apache.org">Peter Donald</a>
18  */

19 public final class ServiceDescriptor
20 {
21     private final Version m_version;
22
23     private final String JavaDoc m_name;
24
25     /**
26      * Construct a service with specified name and version.
27      *
28      * @param name the name of the service
29      * @param version the version of service
30      */

31     public ServiceDescriptor( final String JavaDoc name, final Version version )
32     {
33         m_name = name;
34         m_version = version;
35     }
36
37     /**
38      * Return the version of interface
39      *
40      * @return the version of interface
41      */

42     public Version getVersion()
43     {
44         return m_version;
45     }
46
47     /**
48      * Return name of Service (which coresponds to the interface
49      * name eg org.apache.block.WebServer)
50      *
51      * @return the name of the Service
52      */

53     public String JavaDoc getName()
54     {
55         return m_name;
56     }
57
58     /**
59      * Determine if specified service will match this service.
60      * To match a service has to have same name and must comply with version.
61      *
62      * @param other the other ServiceInfo
63      * @return true if matches, false otherwise
64      */

65     public boolean matches( final ServiceDescriptor other )
66     {
67         return
68             other.getName().equals( m_name )
69             && other.getVersion().complies( m_version );
70     }
71
72     /**
73      * Convert to a string of format name/version
74      *
75      * @return string describing service
76      */

77     public String JavaDoc toString()
78     {
79         return m_name + "/" + m_version;
80     }
81 }
82
Popular Tags