KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > impl > container > ContainerKeyPair


1 /*
2  * $Id: ContainerKeyPair.java 4259 2006-12-14 03:12:07Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.impl.container;
12
13 /**
14  * <code>ContainerKeyPair</code> is a key strategy that binds a container reference
15  * with a container name. This object isn't used directly by users, but it is used
16  * when the the Mule XML configuration is processed.
17  */

18 public class ContainerKeyPair
19 {
20     private final String JavaDoc containerName;
21     private final Object JavaDoc key;
22     private final boolean required;
23
24     public ContainerKeyPair(String JavaDoc containerName, Object JavaDoc key)
25     {
26         this.containerName = containerName;
27         this.key = key;
28         this.required = true;
29     }
30
31     public ContainerKeyPair(String JavaDoc containerName, Object JavaDoc key, boolean required)
32     {
33         this.containerName = containerName;
34         this.key = key;
35         this.required = required;
36     }
37
38     public String JavaDoc getContainerName()
39     {
40         return containerName;
41     }
42
43     public Object JavaDoc getKey()
44     {
45         return key;
46     }
47
48     public boolean isRequired()
49     {
50         return required;
51     }
52
53     // here we only return the key value as string so that
54
// containers that have no notion of this object can still
55
// look up objects by calling the toString method on this object
56
public String JavaDoc toString()
57     {
58         return key.toString();
59     }
60
61     public String JavaDoc toFullString()
62     {
63         return "Container Key{key=" + key.toString() + ", container=" + containerName + ", required="
64                + required + "}";
65     }
66
67     public boolean equals(Object JavaDoc o)
68     {
69         if (this == o) return true;
70         if (o == null || getClass() != o.getClass()) return false;
71
72         final ContainerKeyPair that = (ContainerKeyPair)o;
73
74         if (!containerName.equals(that.containerName)) return false;
75         if (!key.equals(that.key)) return false;
76
77         return true;
78     }
79
80     public int hashCode()
81     {
82         return 29 * containerName.hashCode() + key.hashCode();
83     }
84 }
85
Popular Tags