[Mulgara-svn] r1130 - in trunk/src/jar/query/java/org/mulgara/query: . operation

pag at mulgara.org pag at mulgara.org
Sun Aug 10 02:07:40 UTC 2008


Author: pag
Date: 2008-08-09 19:07:39 -0700 (Sat, 09 Aug 2008)
New Revision: 1130

Modified:
   trunk/src/jar/query/java/org/mulgara/query/Query.java
   trunk/src/jar/query/java/org/mulgara/query/operation/Command.java
   trunk/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java
   trunk/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
Log:
Added a method to Commands to save and retrieve the text that generated the command.

Modified: trunk/src/jar/query/java/org/mulgara/query/Query.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/Query.java	2008-08-10 02:06:35 UTC (rev 1129)
+++ trunk/src/jar/query/java/org/mulgara/query/Query.java	2008-08-10 02:07:39 UTC (rev 1130)
@@ -112,6 +112,9 @@
   /** A UI message describing the result of this message. */
   private String resultMessage = "";
 
+  /** A lexical form for the query, set manually rather than constructed in {@link #toString()}. */
+  private String textualForm = "";
+
   //
   // Constructors
   //
@@ -415,7 +418,23 @@
   }
 
 
+  /** @see org.mulgara.query.operation.Command#setText(java.lang.String) */
+  public void setText(String text) {
+    textualForm = text;
+  }
+
+
   /**
+   * Returns the textual representation of this Command.
+   * @return The text of the command. This comes from the lexer, rather than reconstruction
+   *         from the structure of the query.
+   */
+  public String getText() {
+    return textualForm;
+  }
+
+
+  /**
    * Generate a legible representation of the query.
    *
    * @return A string representing all the elements of a query.

Modified: trunk/src/jar/query/java/org/mulgara/query/operation/Command.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/operation/Command.java	2008-08-10 02:06:35 UTC (rev 1129)
+++ trunk/src/jar/query/java/org/mulgara/query/operation/Command.java	2008-08-10 02:07:39 UTC (rev 1130)
@@ -74,4 +74,19 @@
    * @return <code>true</code> if the result of execute is an Answer.
    */
   boolean isAnswerable();
+
+  /**
+   * Sets the textual representation of this command. This may not be the original command
+   * but will be equivalent.
+   * @param text A textual representation of the command.
+   */
+  void setText(String text);
+
+
+  /**
+   * Returns the textual representation of this Command.
+   * @return The text of the command.
+   */
+  public String getText();
+
 }

Modified: trunk/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java	2008-08-10 02:06:35 UTC (rev 1129)
+++ trunk/src/jar/query/java/org/mulgara/query/operation/LocalCommand.java	2008-08-10 02:07:39 UTC (rev 1130)
@@ -24,6 +24,9 @@
  */
 public abstract class LocalCommand implements Command {
 
+  /** The text used to create this command. */
+  private String textualForm;
+
   /** The message set by the result of this command. */
   private String resultMessage = "";
 
@@ -68,8 +71,33 @@
   public URI getServerURI() {
     return null;
   }
-  
+
+
+  /** @see org.mulgara.query.operation.Command#setText(java.lang.String) */
+  public void setText(String text) {
+    textualForm = text;
+  }
+
+
   /**
+   * Returns the textual representation of this Command. Same as {@link #toString()}.
+   * @return The text of the command.
+   */
+  public String getText() {
+    return textualForm;
+  }
+
+
+  /**
+   * Returns the textual representation of this Command.
+   * @return The text of the command.
+   */
+  public String toString() {
+    return textualForm;
+  }
+
+
+  /**
    * Executes the operation. This is highly specific to each operation.
    * @return Data specific to the operation.
    * @throws Exception specific to the operation.
@@ -77,7 +105,8 @@
   public Object execute() throws Exception {
     return execute(null);
   }
-  
+
+
   /**
    * Gets a message text relevant to the operation.  Useful for the UI.
    * @return A text message associated with the result of this
@@ -87,6 +116,7 @@
     return resultMessage;
   }
 
+
   /**
    * Sets message text relevant to the operation.  Useful for the UI.
    * @return The set text.

Modified: trunk/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java
===================================================================
--- trunk/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java	2008-08-10 02:06:35 UTC (rev 1129)
+++ trunk/src/jar/query/java/org/mulgara/query/operation/ServerCommand.java	2008-08-10 02:07:39 UTC (rev 1130)
@@ -27,6 +27,9 @@
  */
 public abstract class ServerCommand implements Command {
 
+  /** The text used to create this command. */
+  private String textualForm;
+
   /** The graph being referred to on the server. */
   private final ModelResource serverGraph;
   
@@ -111,7 +114,22 @@
   }
 
 
+  /** @see org.mulgara.query.operation.Command#setText(java.lang.String) */
+  public void setText(String text) {
+    textualForm = text;
+  }
+
+
   /**
+   * Returns the textual representation of this Command. Same as {@link #toString()}.
+   * @return The text of the command.
+   */
+  public String getText() {
+    return textualForm;
+  }
+
+
+  /**
    * Sets message text relevant to the operation.  Useful for the UI.
    * @return The set text.
    */




More information about the Mulgara-svn mailing list