|
| 1 | +/* |
| 2 | + * #%L |
| 3 | + * JSQLParser library |
| 4 | + * %% |
| 5 | + * Copyright (C) 2004 - 2013 JSQLParser |
| 6 | + * %% |
| 7 | + * This program is free software: you can redistribute it and/or modify |
| 8 | + * it under the terms of the GNU Lesser General Public License as |
| 9 | + * published by the Free Software Foundation, either version 2.1 of the |
| 10 | + * License, or (at your option) any later version. |
| 11 | + * |
| 12 | + * This program is distributed in the hope that it will be useful, |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | + * GNU General Lesser Public License for more details. |
| 16 | + * |
| 17 | + * You should have received a copy of the GNU General Lesser Public |
| 18 | + * License along with this program. If not, see |
| 19 | + * <http://www.gnu.org/licenses/lgpl-2.1.html>. |
| 20 | + * #L% |
| 21 | + */ |
| 22 | +package net.sf.jsqlparser.util.deparser; |
| 23 | + |
| 24 | +import net.sf.jsqlparser.expression.ExpressionVisitor; |
| 25 | +import net.sf.jsqlparser.statement.execute.Execute; |
| 26 | +import net.sf.jsqlparser.statement.select.PlainSelect; |
| 27 | + |
| 28 | +public class ExecuteDeParser { |
| 29 | + |
| 30 | + private StringBuilder buffer; |
| 31 | + private ExpressionVisitor expressionVisitor; |
| 32 | + |
| 33 | + /** |
| 34 | + * @param expressionVisitor a {@link ExpressionVisitor} to de-parse |
| 35 | + * expressions. It has to share the same<br> |
| 36 | + * StringBuilder (buffer parameter) as this object in order to work |
| 37 | + * @param buffer the buffer that will be filled with the select |
| 38 | + */ |
| 39 | + public ExecuteDeParser(ExpressionVisitor expressionVisitor, StringBuilder buffer) { |
| 40 | + this.buffer = buffer; |
| 41 | + this.expressionVisitor = expressionVisitor; |
| 42 | + } |
| 43 | + |
| 44 | + public StringBuilder getBuffer() { |
| 45 | + return buffer; |
| 46 | + } |
| 47 | + |
| 48 | + public void setBuffer(StringBuilder buffer) { |
| 49 | + this.buffer = buffer; |
| 50 | + } |
| 51 | + |
| 52 | + public void deParse(Execute execute) { |
| 53 | + buffer.append("EXECUTE ").append(execute.getName()); |
| 54 | + buffer.append(" ").append(PlainSelect.getStringList(execute.getExprList().getExpressions(), true, false)); |
| 55 | + } |
| 56 | + |
| 57 | + public ExpressionVisitor getExpressionVisitor() { |
| 58 | + return expressionVisitor; |
| 59 | + } |
| 60 | + |
| 61 | + public void setExpressionVisitor(ExpressionVisitor visitor) { |
| 62 | + expressionVisitor = visitor; |
| 63 | + } |
| 64 | +} |
0 commit comments