Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/rxm.git

Started working on FROM clause.

AuthorDave Jarvis <email>
Date2015-03-13 12:28:43 GMT-0700
Commitcac18d4559033d78fa4f0f44b8be2c557b65bc6d
Parenta7910c4
source/java/com/whitemagicsoftware/rxm/Parser.java
@Override
public synchronized void exitQuery( QueryParser.QueryContext ctx ) {
- System.out.println( getContextTree().getRoot().toString() );
+ String select = getSelectClause();
+ String from = getFromClause();
+ String where = getWhereClause();
+ System.out.printf( "SELECT%n%s%nFROM%n%s%nWHERE%n%s%n",
+ select, from, where );
+ }
+
+ /**
+ * This should only be called after the SELECT clause has been
+ * constructed using the AST.
+ *
+ * @return The SELECT portion of a SQL statement.
+ */
+ private String getSelectClause() {
+ return getContextTree().getRoot().toString();
+ }
+
+ /**
+ * Returns the tables JOINed together that are used in the SELECT clause
+ * of the SQL statement.
+ *
+ * @return The FROM portion of a SQL statement.
+ */
+ private String getFromClause() {
+ return "";
+ }
+
+ private String getWhereClause() {
+ return "";
}
}
}
-
source/java/com/whitemagicsoftware/rxm/tree/TransformationTree.java
*/
public String toString() {
- return toString( this, 0 );
+ return toString( this, getIndent() );
}
/**
- * Answers whether the transformed query should be
- * indented with newlines.
+ * Answers whether the transformed query should be indented with newlines.
+ *
+ * @return true Format the output (by default).
*/
protected boolean beautify() {
}
}
-
source/java/com/whitemagicsoftware/rxm/tree/xml/RootContext.java
String e = element.getText();
- String s = String.format( "SELECT%nXMLROOT( %s", startElement( e ) );
+ String s = String.format( "XMLROOT( %s", startElement( e ) );
return new Token( s );
}
/**
* Closes the XMLELEMENT and XMLROOT.
*/
@Override
public Token getStop() {
- return new Token( String.format( ")%s )", getDeclaration() ) );
+ return new Token( String.format( ")%s)", getDeclaration() ) );
}
/**
* Returns the value for the XML declaration.
*
* @return The XML declaration string in SQL/XML.
*/
protected String getDeclaration() {
- return String.format( ", VERSION '%.1f', STANDALONE %s",
+ return String.format( ",VERSION '%.1f',STANDALONE %s",
getVersion(), isStandalone() ? "YES" : "NO" );
}
Delta36 lines added, 9 lines removed, 27-line increase