1 package com.randomnoun.common.jexl.sql;
2
3 /* (c) 2013 randomnoun. All Rights Reserved. This work is licensed under a
4 * BSD Simplified License. (http://www.randomnoun.com/bsd-simplified.html)
5 */
6
7
8 /** Class to mark a String as generated 'SQL' (as opposed to
9 * a String literal).
10 *
11 * <p>As the SqlGenerator traverses nodes in the AST graph, the visit() methods
12 * return values which are either POJOs (Integers, Strings, Longs, etc...) which
13 * are <i>evaluated</i> from the AST, or SQL text, which is basically an
14 * opaque string which is generated from what we've seen so far in the AST;
15 * (e.g. "abc > 123 AND def LIKE 'GHI'"). As soon as a POJO is converted into
16 * it's SQL form, it is wrappered in this object, so that other visit() nodes
17 * don't accidentally try to evaluate it.
18 *
19 * @author knoxg
20 *
21 */
22 public class SqlText
23 {
24
25 /** An SQL text 'snippet' */
26 private String sql;
27
28 /** Create an SQL snippet */
29 public SqlText(String sql)
30 {
31 this.sql = sql;
32 }
33
34 /** Retrieve the SQL snippet stored in this object. */
35 public String getSqlText()
36 {
37 return sql;
38 }
39
40 /** We supply a .toString() method to make debugging easier */
41 public String toString()
42 {
43 return sql;
44 }
45 }