[CVS spice] Added methods for DNA interfaces

mauro-yCVjj/[email protected] 20 Jun 2004 12:48:45 -0000
Newsgroups gmane.comp.java.spice.cvs
Message-ID <[email protected]>
<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>spice/components/alchemist/src/java/org/codehaus/spice/alchemist</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt>activity/<a href="#file1">ActivityAlchemist.java</a></tt></td><td align="right" id="added">+34</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.1 -&gt; 1.2</td></tr>
<tr class="alt"><td><tt>configuration/<a href="#file2">ConfigurationAlchemist.java</a></tt></td><td align="right" id="added">+34</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.3 -&gt; 1.4</td></tr>
<tr><td><tt>logger/<a href="#file3">LoggerAlchemist.java</a></tt></td><td align="right" id="added">+33</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.2 -&gt; 1.3</td></tr>
<tr class="alt"><td><tt>instrument/<a href="#file4">DNAInstrumentManager.java</a></tt></td><td align="right" id="added">+6</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">1.3 -&gt; 1.4</td></tr>
<tr><td></td><td align="right" id="added">+107</td><td align="right" id="removed">-7</td><td></td></tr>
</table>
<small id="info">4 modified files</small><br />
<pre class="comment">
Added methods for DNA interfaces
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname">spice/components/alchemist/src/java/org/codehaus/spice/alchemist/activity<br /></span>
<div class="fileheader"><big><b>ActivityAlchemist.java</b></big> <small id="info">1.1 -&gt; 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- ActivityAlchemist.java	17 Jun 2004 22:27:22 -0000	1.1
+++ ActivityAlchemist.java	20 Jun 2004 12:48:45 -0000	1.2
@@ -7,11 +7,13 @@
</small></pre><pre class="diff" id="context">  */
 package org.codehaus.spice.alchemist.activity;
 
</pre><pre class="diff" id="added">+import org.codehaus.dna.Active;
+
</pre><pre class="diff" id="context"> /**
  * Utility class containing methods to transform Activity objects.
  * 
  * @author Mauro Talevi
</pre><pre class="diff" id="removed">- * @version $Revision: 1.1 $ $Date: 2004/06/17 22:27:22 $
</pre><pre class="diff" id="added">+ * @version $Revision: 1.2 $ $Date: 2004/06/20 12:48:45 $
</pre><pre class="diff" id="context">  */
 public class ActivityAlchemist {
 
</pre><pre class="diff"><small id="info">@@ -29,6 +31,21 @@
</small></pre><pre class="diff" id="context">         }
         return false;
     }
</pre><pre class="diff" id="added">+
+    /**
+     * Determines if an object is DNA Active
+     *  
+     * @param object the Object to check
+     * @return A boolean &lt;code&gt;true&lt;/code&gt; if the object is an instance of
+     * 		   {@link Active}
+     */
+    public static boolean isDNAActive( final Object object ){
+        if ( object instanceof Active )
+        {
+            return true;
+        }
+        return false;
+    }
</pre><pre class="diff" id="context">     
     /**
      * Casts an object to Avalon Initializable if possible.
</pre><pre class="diff"><small id="info">@@ -79,4 +96,20 @@
</small></pre><pre class="diff" id="context">         throw new IllegalArgumentException( message );
     }
 
</pre><pre class="diff" id="added">+    /**
+     * Casts an object to DNA Active if possible.
+     * 
+     * @param object the Object to cast
+     * @return A {@link Active} 
+     * @throws IllegalArgumentException if not DNA Active.
+     */
+    public static Active toDNAActive( final Object object ){
+        if ( isDNAActive( object ) )
+        {
+            return (Active)object; 
+        }
+        final String message = ( object != null ? object.getClass().getName() : "Object" )
+        						+ " is not DNA Active";
+        throw new IllegalArgumentException( message );
+    }
</pre><pre class="diff" id="context"> }
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname">spice/components/alchemist/src/java/org/codehaus/spice/alchemist/configuration<br /></span>
<div class="fileheader"><big><b>ConfigurationAlchemist.java</b></big> <small id="info">1.3 -&gt; 1.4</small></div>
<pre class="diff"><small id="info">diff -u -r1.3 -r1.4
--- ConfigurationAlchemist.java	19 Jun 2004 17:51:35 -0000	1.3
+++ ConfigurationAlchemist.java	20 Jun 2004 12:48:45 -0000	1.4
@@ -7,6 +7,7 @@
</small></pre><pre class="diff" id="context">  */
 package org.codehaus.spice.alchemist.configuration;
 
</pre><pre class="diff" id="added">+import org.codehaus.dna.Configurable;
</pre><pre class="diff" id="context"> import org.codehaus.dna.Configuration;
 import org.codehaus.dna.impl.DefaultConfiguration;
 
</pre><pre class="diff"><small id="info">@@ -14,7 +15,7 @@
</small></pre><pre class="diff" id="context">  * Utility class containing methods to transform Configuration objects.
  *
  * @author Mauro Talevi
</pre><pre class="diff" id="removed">- * @version $Revision: 1.3 $ $Date: 2004/06/19 17:51:35 $
</pre><pre class="diff" id="added">+ * @version $Revision: 1.4 $ $Date: 2004/06/20 12:48:45 $
</pre><pre class="diff" id="context">  */
 public class ConfigurationAlchemist
 {
</pre><pre class="diff"><small id="info">@@ -62,6 +63,21 @@
</small></pre><pre class="diff" id="context">     }
     
     /**
</pre><pre class="diff" id="added">+     * Determines if an object is DNA Configurable
+     * 
+     * @param object the Object to check
+     * @return A boolean &lt;code&gt;true&lt;/code&gt; if the object is an instance of
+     * 		   {@link Configurable}
+     */
+    public static boolean isDNAConfigurable( final Object object ){
+        if ( object instanceof Configurable )
+        {
+            return true;
+        }
+        return false;
+    }
+    
+    /**
</pre><pre class="diff" id="context">      * Casts an object to Avalon Configurable if possible.
      * 
      * @param object the Object to cast
</pre><pre class="diff"><small id="info">@@ -75,6 +91,23 @@
</small></pre><pre class="diff" id="context">         }
         final String message = ( object != null ? object.getClass().getName() : "Object" )
         						+ " is not Avalon Configurable";
</pre><pre class="diff" id="added">+        throw new IllegalArgumentException( message );
+    }
+
+    /**
+     * Casts an object to DNA Configurable if possible.
+     * 
+     * @param object the Object to cast
+     * @return A {@link Configurable}
+     * @throws IllegalArgumentException if not DNA Configurable.
+     */
+    public static Configurable toDNAConfigurable( final Object object ){
+        if ( isDNAConfigurable( object ) )
+        {
+            return (Configurable)object; 
+        }
+        final String message = ( object != null ? object.getClass().getName() : "Object" )
+        						+ " is not DNA Configurable";
</pre><pre class="diff" id="context">         throw new IllegalArgumentException( message );
     }
 }
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname">spice/components/alchemist/src/java/org/codehaus/spice/alchemist/logger<br /></span>
<div class="fileheader"><big><b>LoggerAlchemist.java</b></big> <small id="info">1.2 -&gt; 1.3</small></div>
<pre class="diff"><small id="info">diff -u -r1.2 -r1.3
--- LoggerAlchemist.java	17 Jun 2004 22:27:22 -0000	1.2
+++ LoggerAlchemist.java	20 Jun 2004 12:48:45 -0000	1.3
@@ -7,13 +7,14 @@
</small></pre><pre class="diff" id="context">  */
 package org.codehaus.spice.alchemist.logger;
 
</pre><pre class="diff" id="added">+import org.codehaus.dna.LogEnabled;
</pre><pre class="diff" id="context"> import org.codehaus.dna.Logger;
 
 /**
  * Utility class containing methods to transform Logger objects.
  *
  * @author Mauro Talevi
</pre><pre class="diff" id="removed">- * @version $Revision: 1.2 $ $Date: 2004/06/17 22:27:22 $
</pre><pre class="diff" id="added">+ * @version $Revision: 1.3 $ $Date: 2004/06/20 12:48:45 $
</pre><pre class="diff" id="context">  */
 public class LoggerAlchemist
 {
</pre><pre class="diff"><small id="info">@@ -55,6 +56,21 @@
</small></pre><pre class="diff" id="context">     }
     
     /**
</pre><pre class="diff" id="added">+     * Determines if an object is DNA LogEnabled
+     * 
+     * @param object the Object to check
+     * @return A boolean &lt;code&gt;true&lt;/code&gt; if the object is an instance of
+     * 		   {@link LogEnabled}
+     */
+    public static boolean isDNALogEnabled( final Object object ){
+        if ( object instanceof LogEnabled )
+        {
+            return true;
+        }
+        return false;
+    }
+
+    /**
</pre><pre class="diff" id="context">      * Casts an object to Avalon LogEnabled if possible.
      * 
      * @param object the Object to cast
</pre><pre class="diff"><small id="info">@@ -71,4 +87,20 @@
</small></pre><pre class="diff" id="context">         throw new IllegalArgumentException( message );
     }
 
</pre><pre class="diff" id="added">+    /**
+     * Casts an object to DNA LogEnabled if possible.
+     * 
+     * @param object the Object to cast
+     * @return A {@link LogEnabled}
+     * @throws IllegalArgumentException if not DNA LogEnabled.
+     */
+    public static LogEnabled toDNALogEnabled( final Object object ){
+        if ( isDNALogEnabled( object ) )
+        {
+            return (LogEnabled)object; 
+        }
+        final String message = ( object != null ? object.getClass().getName() : "Object" )
+        					 	+ " is not DNA LogEnabled";
+        throw new IllegalArgumentException( message );
+    }
</pre><pre class="diff" id="context"> }
</pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname">spice/components/alchemist/src/java/org/codehaus/spice/alchemist/instrument<br /></span>
<div class="fileheader"><big><b>DNAInstrumentManager.java</b></big> <small id="info">1.3 -&gt; 1.4</small></div>
<pre class="diff"><small id="info">diff -u -r1.3 -r1.4
--- DNAInstrumentManager.java	19 Jun 2004 17:51:35 -0000	1.3
+++ DNAInstrumentManager.java	20 Jun 2004 12:48:45 -0000	1.4
@@ -25,7 +25,7 @@
</small></pre><pre class="diff" id="context">  * 
  * @author Johan Sjoberg
  * @author Mauro Talevi
</pre><pre class="diff" id="removed">- * @version $Revision: 1.3 $ $Date: 2004/06/19 17:51:35 $
</pre><pre class="diff" id="added">+ * @version $Revision: 1.4 $ $Date: 2004/06/20 12:48:45 $
</pre><pre class="diff" id="context">  */
 public class DNAInstrumentManager implements InstrumentManager, LogEnabled,
         Configurable, Active {
</pre><pre class="diff"><small id="info">@@ -50,9 +50,11 @@
</small></pre><pre class="diff" id="context">      * @see LogEnabled#enableLogging(Logger)
      */
     public void enableLogging( Logger logger ) {
</pre><pre class="diff" id="removed">-        if ( LoggerAlchemist.isAvalonLogEnabled( _manager ) ) {
</pre><pre class="diff" id="added">+        try {
</pre><pre class="diff" id="context">             LoggerAlchemist.toAvalonLogEnabled( _manager ).enableLogging(
                     LoggerAlchemist.toAvalonLogger( logger ) );
</pre><pre class="diff" id="added">+        } catch ( IllegalArgumentException e ) {
+            // The manager is not Avalon LogEnabled            
</pre><pre class="diff" id="context">         }
     }
 
</pre><pre class="diff"><small id="info">@@ -77,7 +79,7 @@
</small></pre><pre class="diff" id="context">         try {
             ActivityAlchemist.toAvalonInitializable( _manager ).initialize();
         } catch ( IllegalArgumentException e ){
</pre><pre class="diff" id="removed">-            // <span id="removedchars">_</span>manager is not Avalon Initialisable
</pre><pre class="diff" id="added">+            // <span id="addedchars">The&nbsp;</span>manager is not Avalon Initialisable
</pre><pre class="diff" id="context">         }
     }
 
</pre><pre class="diff"><small id="info">@@ -88,7 +90,7 @@
</small></pre><pre class="diff" id="context">         try {
             ActivityAlchemist.toAvalonDisposable( _manager ).dispose();
         } catch ( IllegalArgumentException e ){
</pre><pre class="diff" id="removed">-            // <span id="removedchars">_</span>manager is not Avalon Disposable
</pre><pre class="diff" id="added">+            // <span id="addedchars">The&nbsp;</span>manager is not Avalon Disposable
</pre><pre class="diff" id="context">         }
     }
 
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.8</small></center>
</body></html>