[Mulgara-svn] r455 - in branches/nw-interface/src/jar/query/java/org/mulgara/query: . operation

pag at mulgara.org pag at mulgara.org
Wed Sep 26 04:49:59 UTC 2007


Author: pag
Date: 2007-09-25 23:49:58 -0500 (Tue, 25 Sep 2007)
New Revision: 455

Modified:
   branches/nw-interface/src/jar/query/java/org/mulgara/query/Query.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Command.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java
   branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java
Log:
Added features to commands for better identification without using instanceof

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/Query.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/Query.java	2007-09-26 04:49:03 UTC (rev 454)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/Query.java	2007-09-26 04:49:58 UTC (rev 455)
@@ -457,6 +457,16 @@
 
 
   /**
+   * Indicates that this command returns an Answer. Saves the overhead of checking
+   * the return type of execute.
+   * @return <code>true</code>.
+   */
+  public boolean isAnswerable() {
+    return true;
+  }
+
+
+  /**
    * Gets the associated server for a non-local operation.
    * @return the server URI, or <code>null</code> if the data should be found locally.
    */

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Command.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Command.java	2007-09-26 04:49:03 UTC (rev 454)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/Command.java	2007-09-26 04:49:58 UTC (rev 455)
@@ -59,4 +59,11 @@
    * operation.
    */
   String getResultMessage();
+  
+  /**
+   * Indicates that this command returns an Answer. Saves the overhead of checking
+   * the return type of execute.
+   * @return <code>true</code> if the result of execute is an Answer.
+   */
+  boolean isAnswerable();
 }

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java	2007-09-26 04:49:03 UTC (rev 454)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java	2007-09-26 04:49:58 UTC (rev 455)
@@ -43,12 +43,22 @@
     return false;
   }
 
+
   /**
+   * Indicates that this command cannot return an Answer.
+   * @return <code>false</code> by default.
+   */
+  public boolean isAnswerable() {
+    return false;
+  }
+
+
+  /**
    * Gets the associated server for a non-local operation.
    * @throws UnsupportedOperationException Always thrown for local commands.
    */
   public URI getServerURI() throws UnsupportedOperationException {
-    throw new UnsupportedOperationException("Server URI not available for local commands.");
+    return null;
   }
   
   /**

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java	2007-09-26 04:49:03 UTC (rev 454)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java	2007-09-26 04:49:58 UTC (rev 455)
@@ -83,6 +83,16 @@
 
 
   /**
+   * Indicates that this command returns an Answer. Saves the overhead of checking
+   * the return type of execute.
+   * @return <code>false</code> by default.
+   */
+  public boolean isAnswerable() {
+    return false;
+  }
+
+
+  /**
    * Sets message text relevant to the operation.  Useful for the UI.
    * @return The set text.
    */

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java	2007-09-26 04:49:03 UTC (rev 454)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/SetAutoCommit.java	2007-09-26 04:49:58 UTC (rev 455)
@@ -34,7 +34,7 @@
 
   public Object execute(Connection conn) throws Exception {
     boolean on = isOn();
-    conn.setAutoCommit(on);
+    if (conn != null) conn.setAutoCommit(on);
     return setResultMessage(MESSAGE + (on ? ON : OFF));
   }
 

Modified: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java	2007-09-26 04:49:03 UTC (rev 454)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/TransactionCommand.java	2007-09-26 04:49:58 UTC (rev 455)
@@ -44,6 +44,14 @@
   }
 
   /**
+   * Indicates that this command cannot return an Answer
+   * @return <code>false</code>.
+   */
+  public boolean isAnswerable() {
+    return false;
+  }
+
+  /**
    * Requests a server URI for this operation.  None available, as it
    * operates on the local connection.
    * @return <code>null</code>




More information about the Mulgara-svn mailing list