donaldp 01/12/02 07:16:22
Modified: src/scratchpad/org/apache/avalon/excalibur/util
ComponentStateValidator.java
Log:
Update to add all the methods that wer previously in COmponentUtil.
Revision Changes Path
1.2 +40 -2
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/util/ComponentStateValidator.java
Index: ComponentStateValidator.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/util/ComponentStateValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ComponentStateValidator.java 2001/12/02 15:03:04 1.1
+++ ComponentStateValidator.java 2001/12/02 15:16:22 1.2
@@ -5,7 +5,7 @@
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE file.
*/
-package org.apache.avalon.framework;
+package org.apache.avalon.excalibur.util;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
@@ -24,7 +24,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Michael McKibben</a>
- * @version CVS $Revision: 1.1 $ $Date: 2001/12/02 15:03:04 $
+ * @version CVS $Revision: 1.2 $ $Date: 2001/12/02 15:16:22 $
*/
public final class ComponentStateValidator
{
@@ -170,6 +170,7 @@
}
}
+
/**
* Throw an exception if the initialization is out of order. It tests
to see
* if the CONFIGURED state has already been set, if the component
implements
@@ -195,6 +196,29 @@
/**
* Throw an exception if the initialization is out of order. It tests
to see
+ * if the COMPOSED state has already been set, if the component
implements
+ * Composable, and if the state has progressed beyond the Configuration
stage.
+ *
+ * @param message the message to include in the thrown exception
+ * @throws IllegalStateException if the state is manage out of order
+ */
+ public void checkComposed( final String message )
+ {
+ if ( ( (m_state & m_mask & COMPOSED) > 0 ) ||
+ ( (m_mask & COMPOSED) == 0 ) || ( m_state > COMPOSED ) )
+ {
+ throw new IllegalStateException( message );
+ }
+
+ m_state |= COMPOSED;
+ if ( (m_state & INIT_MASK) == (m_mask & INIT_MASK) )
+ {
+ m_state |= ACTIVE;
+ }
+ }
+
+ /**
+ * Throw an exception if the initialization is out of order. It tests
to see
* if the INITIALIZED state has already been set, if the component
implements
* Initializable, and if the state has progressed beyond the
<code>initialize</code> stage.
*
@@ -333,6 +357,20 @@
}
throw new IllegalStateException( message );
+ }
+
+ /**
+ * Make sure object has not been assigned yet.
+ *
+ * @param message the message to include in the thrown exception
+ * @throws IllegalStateException if the state is manage out of order
+ */
+ public void checkNotAssigned( final Object object, final String message )
+ {
+ if ( null != object )
+ {
+ throw new IllegalStateException( message );
+ }
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>