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

pag at mulgara.org pag at mulgara.org
Wed Nov 14 19:50:33 UTC 2007


Author: pag
Date: 2007-11-14 13:50:31 -0600 (Wed, 14 Nov 2007)
New Revision: 544

Added:
   branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/AddAlias.java
Modified:
   branches/nw-interface/src/jar/itql/java/org/mulgara/itql/TqlInterpreter.java
Log:
Added an AddAlias AST node for indicating that the interpreter got a new alias, though no processing happens on this object beyond reporting what happened.

Modified: branches/nw-interface/src/jar/itql/java/org/mulgara/itql/TqlInterpreter.java
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/itql/TqlInterpreter.java	2007-11-14 19:41:24 UTC (rev 543)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/itql/TqlInterpreter.java	2007-11-14 19:50:31 UTC (rev 544)
@@ -29,6 +29,7 @@
 import org.mulgara.itql.lexer.*;
 import org.mulgara.itql.node.*;
 import org.mulgara.itql.parser.*;
+import org.mulgara.query.operation.AddAlias;
 import org.mulgara.query.operation.ApplyRules;
 import org.mulgara.query.operation.Backup;
 import org.mulgara.query.operation.Command;
@@ -471,6 +472,9 @@
       // log that we've added the pair to the map
       if (logger.isDebugEnabled()) logger.debug("Aliased " + aliasTarget + " as " + aliasPrefix);
 
+      // Return an AST element, for reporting on what happened.
+      lastCommand = new AddAlias(aliasPrefix, aliasTarget);
+
     } catch (URISyntaxException use) {
       // log the failed URI creation
       logger.warn("Unable to create URI from alias target " + aliasTarget);

Added: branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/AddAlias.java
===================================================================
--- branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/AddAlias.java	2007-11-14 19:41:24 UTC (rev 543)
+++ branches/nw-interface/src/jar/query/java/org/mulgara/query/operation/AddAlias.java	2007-11-14 19:50:31 UTC (rev 544)
@@ -0,0 +1,75 @@
+/*
+ * The contents of this file are subject to the Open Software License
+ * Version 3.0 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.opensource.org/licenses/osl-3.0.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ * the License for the specific language governing rights and limitations
+ * under the License.
+ */
+
+package org.mulgara.query.operation;
+
+import org.mulgara.connection.Connection;
+
+
+/**
+ * An AST element for the ALIAS command.
+ *
+ * @created 2007-11-14
+ * @author Paul Gearon
+ * @copyright &copy; 2007 <a href="mailto:pgearon at users.sourceforge.net">Paul Gearon</a>
+ * @licence <a href="{@docRoot}/../../LICENCE.txt">Open Software License v3.0</a>
+ */
+public class AddAlias extends LocalCommand {
+  
+  private static final String SUCCESS_MSG_PREFIX = "Successfully aliased ";
+
+  private static final String SUCCESS_MSG_AS = " as ";
+
+  /** The new alias to set. */
+  private final String aliasPrefix;
+  
+  /** The string for the URI of the alias. */
+  private final String aliasTarget;
+
+  /**
+   * Creates a new alias command.
+   * @param aliasPrefix The alias to set.
+   * @param aliasTarget The URI that the alias applies to.
+   */
+  public AddAlias(String aliasPrefix, String aliasTarget) {
+    this.aliasPrefix = aliasPrefix;
+    this.aliasTarget = aliasTarget;
+  }
+  
+  /**
+   * Indicates that this operation is for a UI.
+   * @return <code>true</code> as operation is for UI output only.
+   */
+  public boolean isUICommand() {
+    return true;
+  }
+
+  /** @return the aliasPrefix */
+  public String getAliasPrefix() {
+    return aliasPrefix;
+  }
+
+  /** @return the aliasTarget */
+  public String getAliasTarget() {
+    return aliasTarget;
+  }
+
+  /**
+   * Asks for the help text associated with the creation of this object.
+   * @param conn ignored.
+   * @return The text of the help request.
+   */
+  public Object execute(Connection conn) throws Exception {
+    return setResultMessage(SUCCESS_MSG_PREFIX + aliasPrefix + SUCCESS_MSG_AS + aliasTarget);
+  }
+
+}




More information about the Mulgara-svn mailing list