001package com.randomnoun.common.jexl.sql; 002 003/* (c) 2013 randomnoun. All Rights Reserved. This work is licensed under a 004 * BSD Simplified License. (http://www.randomnoun.com/bsd-simplified.html) 005 */ 006 007 008/** Class to mark a String as generated 'SQL' (as opposed to 009 * a String literal). 010 * 011 * <p>As the SqlGenerator traverses nodes in the AST graph, the visit() methods 012 * return values which are either POJOs (Integers, Strings, Longs, etc...) which 013 * are <i>evaluated</i> from the AST, or SQL text, which is basically an 014 * opaque string which is generated from what we've seen so far in the AST; 015 * (e.g. "abc > 123 AND def LIKE 'GHI'"). As soon as a POJO is converted into 016 * it's SQL form, it is wrappered in this object, so that other visit() nodes 017 * don't accidentally try to evaluate it. 018 * 019 * @author knoxg 020 * 021 */ 022public class SqlText 023{ 024 025 /** An SQL text 'snippet' */ 026 private String sql; 027 028 /** Create an SQL snippet */ 029 public SqlText(String sql) 030 { 031 this.sql = sql; 032 } 033 034 /** Retrieve the SQL snippet stored in this object. */ 035 public String getSqlText() 036 { 037 return sql; 038 } 039 040 /** We supply a .toString() method to make debugging easier */ 041 public String toString() 042 { 043 return sql; 044 } 045}