bloritsch 2002/09/23 14:05:29
Modified: meta/src/java/org/apache/excalibur/meta/info
ReferenceDescriptor.java ServiceDefinition.java
ServiceDescriptor.java StageDescriptor.java
Log:
add methods to make the descriptors more friendly with hashmaps
Revision Changes Path
1.3 +32 -1
jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/ReferenceDescriptor.java
Index: ReferenceDescriptor.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/ReferenceDescriptor.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ReferenceDescriptor.java 21 Aug 2002 03:34:32 -0000 1.2
+++ ReferenceDescriptor.java 23 Sep 2002 21:05:29 -0000 1.3
@@ -111,4 +111,35 @@
{
return getClassname() + "/" + getVersion();
}
+
+ /**
+ * Make the ReferenceDescriptor friendly with Hashmaps.
+ */
+ public int hashCode()
+ {
+ return getClassname().hashCode() + getVersion().hashCode();
+ }
+
+ /**
+ * Make the ReferenceDescriptor friendly with Hashmaps.
+ */
+ public boolean equals(Object other)
+ {
+ boolean match = false;
+
+ if ( other instanceof ReferenceDescriptor )
+ {
+ match = ( (ReferenceDescriptor) other).matches( this );
+ }
+ else if ( other instanceof ServiceDefinition )
+ {
+ match = ( (ServiceDefinition) other).matches( this );
+ }
+ else if ( other instanceof ServiceDescriptor )
+ {
+ match = ( (ServiceDefinition) other).matches( this );
+ }
+
+ return match;
+ }
}
1.2 +35 -6
jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/ServiceDefinition.java
Index: ServiceDefinition.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/ServiceDefinition.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ServiceDefinition.java 22 Sep 2002 07:54:20 -0000 1.1
+++ ServiceDefinition.java 23 Sep 2002 21:05:29 -0000 1.2
@@ -56,7 +56,7 @@
}
/**
- * Creation of a new ServiceDefinition instance using a classname and
+ * Creation of a new ServiceDefinition instance using a classname and
* supplied properties argument.
*
* @param classname the classname of the service
@@ -69,16 +69,16 @@
}
/**
- * Creation of a new ServiceDefinition instance using a classname and
+ * Creation of a new ServiceDefinition instance using a classname and
* supplied properties argument.
*
* @param classname the classname of the service
* @param version the service version
* @param attributes the set of attributes to assign to the descriptor
*/
- public ServiceDefinition(
- final String classname,
- final Version version,
+ public ServiceDefinition(
+ final String classname,
+ final Version version,
final Properties attributes )
{
super( attributes );
@@ -128,5 +128,34 @@
return
reference.getClassname().equals( getClassname() ) &&
reference.getVersion().complies( getVersion() );
+ }
+
+ /**
+ * Make the ServiceDefinition friendly with Hashmaps.
+ */
+ public int hashCode()
+ {
+ return getClassname().hashCode() + getVersion().hashCode();
+ }
+
+ /**
+ * Make the ServiceDefinition friendly with Hashmaps.
+ */
+ public boolean equals( Object other )
+ {
+ boolean match = false;
+
+ if ( other instanceof ReferenceDescriptor )
+ {
+ match = matches( (ReferenceDescriptor) other );
+ }
+ else if ( other instanceof ServiceDefinition )
+ {
+ ServiceDefinition ref = (ServiceDefinition) other;
+ match = ref.getClassname().equals( getClassname() ) &&
+ ref.getVersion().complies( getVersion() );
+ }
+
+ return match;
}
}
1.4 +9 -2
jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/ServiceDescriptor.java
Index: ServiceDescriptor.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/ServiceDescriptor.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ServiceDescriptor.java 13 Sep 2002 20:31:22 -0000 1.3
+++ ServiceDescriptor.java 23 Sep 2002 21:05:29 -0000 1.4
@@ -43,7 +43,7 @@
/**
* Construct a service descriptor for specified ReferenceDescriptor
*
- * @param designator the service reference
+ * @param designator the service reference
* @exception NullPointerException if the designator argument is null
*/
public ServiceDescriptor( final ReferenceDescriptor designator )
@@ -94,4 +94,11 @@
return m_designator;
}
+ /**
+ * Make the ReferenceDescriptor friendly with Hashmaps.
+ */
+ public int hashCode()
+ {
+ return getReference().hashCode();
+ }
}
1.2 +8 -1
jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/StageDescriptor.java
Index: StageDescriptor.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/meta/src/java/org/apache/excalibur/meta/info/StageDescriptor.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StageDescriptor.java 22 Aug 2002 13:55:31 -0000 1.1
+++ StageDescriptor.java 23 Sep 2002 21:05:29 -0000 1.2
@@ -63,4 +63,11 @@
return m_reference;
}
+ /**
+ * Make the ReferenceDescriptor friendly with Hashmaps.
+ */
+ public int hashCode()
+ {
+ return getReference().hashCode();
+ }
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>