donaldp 01/11/19 02:57:30
Modified: src/scratchpad/org/apache/avalon/excalibur/extension
Extension.java
Log:
Added support for checking the level of compatability and the reason for
which it is inco patible.
Revision Changes Path
1.4 +50 -12
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/extension/Extension.java
Index: Extension.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/extension/Extension.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Extension.java 2001/11/17 11:32:55 1.3
+++ Extension.java 2001/11/19 10:57:30 1.4
@@ -30,10 +30,21 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Craig R. McClanahan</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
- * @version $Revision: 1.3 $ $Date: 2001/11/17 11:32:55 $
+ * @version $Revision: 1.4 $ $Date: 2001/11/19 10:57:30 $
*/
public final class Extension
{
+ public static final Compatability COMPATIBLE =
+ new Compatability( "COMPATIBLE" );
+ public static final Compatability REQUIRE_SPECIFICATION_UPGRADE =
+ new Compatability( "REQUIRE_SPECIFICATION_UPGRADE" );
+ public static final Compatability REQUIRE_VENDOR_SWITCH =
+ new Compatability( "REQUIRE_VENDOR_SWITCH" );
+ public static final Compatability REQUIRE_IMPLEMENTATION_UPGRADE =
+ new Compatability( "REQUIRE_IMPLEMENTATION_UPGRADE" );
+ public static final Compatability INCOMPATIBLE =
+ new Compatability( "INCOMPATIBLE" );
+
/**
* The name of the optional package being made available, or required.
*/
@@ -272,21 +283,19 @@
return m_implementationVersion;
}
+
/**
- * Return <code>true</code> if the specified <code>Extension</code>
- * (which represents an optional package required by an application)
- * is satisfied by this <code>Extension</code> (which represents an
- * optional package that is already installed. Otherwise, return
- * <code>false</code>.
+ * Return a Compatibility enum indicating the relationship of this
+ * <code>Extension</code> with the specified <code>Extension</code>.
*
* @param required Description of the required optional package
*/
- public boolean isCompatibleWith( final Extension required )
+ public Compatability getCompatibilityWith( final Extension required )
{
// Extension Name must match
if( false == m_extensionName.equals( required.getExtensionName() ) )
{
- return false;
+ return INCOMPATIBLE;
}
// Available specification version must be >= required
@@ -296,7 +305,7 @@
if( null == m_specificationVersion ||
false == isCompatible( m_specificationVersion,
specificationVersion ) )
{
- return false;
+ return REQUIRE_SPECIFICATION_UPGRADE;
}
}
@@ -307,7 +316,7 @@
if( null == m_implementationVendorId ||
false == m_implementationVendorId.equals(
implementationVendorId ) )
{
- return false;
+ return REQUIRE_VENDOR_SWITCH;
}
}
@@ -318,15 +327,29 @@
if( null == m_implementationVersion ||
false == isCompatible( m_implementationVersion,
implementationVersion ) )
{
- return false;
+ return REQUIRE_IMPLEMENTATION_UPGRADE;
}
}
// This available optional package satisfies the requirements
- return true;
+ return COMPATIBLE;
}
/**
+ * Return <code>true</code> if the specified <code>Extension</code>
+ * (which represents an optional package required by an application)
+ * is satisfied by this <code>Extension</code> (which represents an
+ * optional package that is already installed. Otherwise, return
+ * <code>false</code>.
+ *
+ * @param required Description of the required optional package
+ */
+ public boolean isCompatibleWith( final Extension required )
+ {
+ return ( COMPATIBLE == getCompatibilityWith( required ) );
+ }
+
+ /**
* Return a String representation of this object.
*/
public String toString()
@@ -387,5 +410,20 @@
private boolean isCompatible( final DeweyDecimal first, final
DeweyDecimal second )
{
return first.isGreaterThanOrEqual( second );
+ }
+
+ public static final class Compatability
+ {
+ private final String m_name;
+
+ protected Compatability( final String name )
+ {
+ m_name = name;
+ }
+
+ public String toString()
+ {
+ return m_name;
+ }
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>