|
| 1 | +/*- |
| 2 | + * #%L |
| 3 | + * JSQLParser library |
| 4 | + * %% |
| 5 | + * Copyright (C) 2004 - 2026 JSQLParser |
| 6 | + * %% |
| 7 | + * Dual licensed under GNU LGPL 2.1 or Apache License 2.0 |
| 8 | + * #L% |
| 9 | + */ |
| 10 | +package net.sf.jsqlparser.statement.create.view; |
| 11 | + |
| 12 | +import java.io.Serializable; |
| 13 | +import net.sf.jsqlparser.statement.MySqlDefiner; |
| 14 | + |
| 15 | +/** Prefix options shared by MySQL CREATE VIEW and ALTER VIEW. */ |
| 16 | +public class MySqlViewOptions implements Serializable { |
| 17 | + public enum Algorithm { |
| 18 | + UNDEFINED, MERGE, TEMPTABLE |
| 19 | + } |
| 20 | + |
| 21 | + public enum Security { |
| 22 | + DEFINER, INVOKER |
| 23 | + } |
| 24 | + |
| 25 | + private Algorithm algorithm; |
| 26 | + private MySqlDefiner definer; |
| 27 | + private Security security; |
| 28 | + |
| 29 | + public Algorithm getAlgorithm() { |
| 30 | + return algorithm; |
| 31 | + } |
| 32 | + |
| 33 | + public void setAlgorithm(Algorithm algorithm) { |
| 34 | + this.algorithm = algorithm; |
| 35 | + } |
| 36 | + |
| 37 | + public MySqlDefiner getDefiner() { |
| 38 | + return definer; |
| 39 | + } |
| 40 | + |
| 41 | + public void setDefiner(MySqlDefiner definer) { |
| 42 | + this.definer = definer; |
| 43 | + } |
| 44 | + |
| 45 | + public Security getSecurity() { |
| 46 | + return security; |
| 47 | + } |
| 48 | + |
| 49 | + public void setSecurity(Security security) { |
| 50 | + this.security = security; |
| 51 | + } |
| 52 | + |
| 53 | + public void appendTo(StringBuilder builder) { |
| 54 | + if (algorithm != null) { |
| 55 | + builder.append("ALGORITHM = ").append(algorithm).append(' '); |
| 56 | + } |
| 57 | + if (definer != null) { |
| 58 | + builder.append("DEFINER = ").append(definer).append(' '); |
| 59 | + } |
| 60 | + if (security != null) { |
| 61 | + builder.append("SQL SECURITY ").append(security).append(' '); |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public String toString() { |
| 67 | + StringBuilder sql = new StringBuilder(); |
| 68 | + appendTo(sql); |
| 69 | + return sql.toString().trim(); |
| 70 | + } |
| 71 | +} |
0 commit comments