5602 |
07 Apr 11 |
nicklas |
1 |
/** |
5602 |
07 Apr 11 |
nicklas |
$Id$ |
5602 |
07 Apr 11 |
nicklas |
3 |
|
5602 |
07 Apr 11 |
nicklas |
Copyright (C) 2011 Nicklas Nordborg |
5602 |
07 Apr 11 |
nicklas |
5 |
|
5602 |
07 Apr 11 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
5602 |
07 Apr 11 |
nicklas |
Available at http://base.thep.lu.se/ |
5602 |
07 Apr 11 |
nicklas |
8 |
|
5602 |
07 Apr 11 |
nicklas |
BASE is free software; you can redistribute it and/or |
5602 |
07 Apr 11 |
nicklas |
modify it under the terms of the GNU General Public License |
5602 |
07 Apr 11 |
nicklas |
as published by the Free Software Foundation; either version 3 |
5602 |
07 Apr 11 |
nicklas |
of the License, or (at your option) any later version. |
5602 |
07 Apr 11 |
nicklas |
13 |
|
5602 |
07 Apr 11 |
nicklas |
BASE is distributed in the hope that it will be useful, |
5602 |
07 Apr 11 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
5602 |
07 Apr 11 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5602 |
07 Apr 11 |
nicklas |
GNU General Public License for more details. |
5602 |
07 Apr 11 |
nicklas |
18 |
|
5602 |
07 Apr 11 |
nicklas |
You should have received a copy of the GNU General Public License |
5602 |
07 Apr 11 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
5602 |
07 Apr 11 |
nicklas |
21 |
*/ |
5602 |
07 Apr 11 |
nicklas |
22 |
package net.sf.basedb.util.extensions.manager; |
5602 |
07 Apr 11 |
nicklas |
23 |
|
5602 |
07 Apr 11 |
nicklas |
24 |
/** |
5602 |
07 Apr 11 |
nicklas |
Key implementation used for configuration parameters for factories. |
5602 |
07 Apr 11 |
nicklas |
This is used for both action, renderer and error handler factories |
5602 |
07 Apr 11 |
nicklas |
registered for extensions and extension points. |
5602 |
07 Apr 11 |
nicklas |
<p> |
5602 |
07 Apr 11 |
nicklas |
29 |
|
5602 |
07 Apr 11 |
nicklas |
The parameters are stored as metadata on the extensions file that |
5602 |
07 Apr 11 |
nicklas |
loaded the extensions and can be accessed via |
5602 |
07 Apr 11 |
nicklas |
{@link ExtensionsFile#getMetadata(ObjectKey)}. The returned value is |
5602 |
07 Apr 11 |
nicklas |
an XML representation of the parameters as they appear in the |
5602 |
07 Apr 11 |
nicklas |
definitions file. |
5602 |
07 Apr 11 |
nicklas |
<p> |
5602 |
07 Apr 11 |
nicklas |
36 |
|
5602 |
07 Apr 11 |
nicklas |
The key is the factory instance itself. |
5602 |
07 Apr 11 |
nicklas |
38 |
|
5602 |
07 Apr 11 |
nicklas |
@author Nicklas |
5602 |
07 Apr 11 |
nicklas |
@since 3.0 |
5602 |
07 Apr 11 |
nicklas |
@base.modified $Date$ |
5602 |
07 Apr 11 |
nicklas |
42 |
*/ |
5602 |
07 Apr 11 |
nicklas |
43 |
public class FactoryParametersKey |
5602 |
07 Apr 11 |
nicklas |
44 |
implements ObjectKey<String> |
5602 |
07 Apr 11 |
nicklas |
45 |
{ |
5602 |
07 Apr 11 |
nicklas |
46 |
|
5602 |
07 Apr 11 |
nicklas |
47 |
private final Object factory; |
5602 |
07 Apr 11 |
nicklas |
48 |
|
5602 |
07 Apr 11 |
nicklas |
49 |
/** |
5602 |
07 Apr 11 |
nicklas |
Create a new key for the given factory. |
5602 |
07 Apr 11 |
nicklas |
@param factory The factory (required) |
5602 |
07 Apr 11 |
nicklas |
52 |
*/ |
5602 |
07 Apr 11 |
nicklas |
53 |
public FactoryParametersKey(Object factory) |
5602 |
07 Apr 11 |
nicklas |
54 |
{ |
5602 |
07 Apr 11 |
nicklas |
55 |
if (factory == null) throw new NullPointerException("factory"); |
5602 |
07 Apr 11 |
nicklas |
56 |
this.factory = factory; |
5602 |
07 Apr 11 |
nicklas |
57 |
} |
5602 |
07 Apr 11 |
nicklas |
58 |
|
5602 |
07 Apr 11 |
nicklas |
59 |
/* |
5606 |
14 Apr 11 |
nicklas |
From the ObjectKey interface |
5606 |
14 Apr 11 |
nicklas |
61 |
---------------------------- |
5606 |
14 Apr 11 |
nicklas |
62 |
*/ |
5606 |
14 Apr 11 |
nicklas |
63 |
@Override |
5606 |
14 Apr 11 |
nicklas |
64 |
public String toDescription() |
5606 |
14 Apr 11 |
nicklas |
65 |
{ |
5606 |
14 Apr 11 |
nicklas |
66 |
return "Factory '" + factory + "'"; |
5606 |
14 Apr 11 |
nicklas |
67 |
} |
5606 |
14 Apr 11 |
nicklas |
68 |
// ----------------------------- |
5606 |
14 Apr 11 |
nicklas |
69 |
|
5606 |
14 Apr 11 |
nicklas |
70 |
|
5606 |
14 Apr 11 |
nicklas |
71 |
/* |
5602 |
07 Apr 11 |
nicklas |
From the Object class |
5602 |
07 Apr 11 |
nicklas |
73 |
--------------------- |
5602 |
07 Apr 11 |
nicklas |
74 |
*/ |
5602 |
07 Apr 11 |
nicklas |
75 |
@Override |
5602 |
07 Apr 11 |
nicklas |
76 |
public int hashCode() |
5602 |
07 Apr 11 |
nicklas |
77 |
{ |
5602 |
07 Apr 11 |
nicklas |
78 |
return factory.hashCode(); |
5602 |
07 Apr 11 |
nicklas |
79 |
} |
5602 |
07 Apr 11 |
nicklas |
80 |
|
5602 |
07 Apr 11 |
nicklas |
81 |
@Override |
5602 |
07 Apr 11 |
nicklas |
82 |
public boolean equals(Object obj) |
5602 |
07 Apr 11 |
nicklas |
83 |
{ |
5602 |
07 Apr 11 |
nicklas |
84 |
if (this == obj) return true; |
5602 |
07 Apr 11 |
nicklas |
85 |
if (obj == null || obj.getClass() != this.getClass()) return false; |
5602 |
07 Apr 11 |
nicklas |
86 |
FactoryParametersKey other = (FactoryParametersKey)obj; |
5602 |
07 Apr 11 |
nicklas |
87 |
return other.factory.equals(this.factory); |
5602 |
07 Apr 11 |
nicklas |
88 |
} |
5602 |
07 Apr 11 |
nicklas |
89 |
|
5602 |
07 Apr 11 |
nicklas |
90 |
@Override |
5602 |
07 Apr 11 |
nicklas |
91 |
public String toString() |
5602 |
07 Apr 11 |
nicklas |
92 |
{ |
5602 |
07 Apr 11 |
nicklas |
93 |
return "FactoryParametersKey@" + System.identityHashCode(this) + "[" + factory + "]"; |
5602 |
07 Apr 11 |
nicklas |
94 |
} |
5602 |
07 Apr 11 |
nicklas |
95 |
// ----------------------- |
5602 |
07 Apr 11 |
nicklas |
96 |
|
5602 |
07 Apr 11 |
nicklas |
97 |
|
5602 |
07 Apr 11 |
nicklas |
98 |
|
5602 |
07 Apr 11 |
nicklas |
99 |
} |