| 1 | | | |
| 2 | | | |
| 3 | | | |
| 4 | | | |
| 5 | | | |
| 6 | | | |
| 7 | | | |
| 8 | | | |
| 9 | | | |
| 10 | | | |
| 11 | | | |
| 12 | | | |
| 13 | | | |
| 14 | | | |
| 15 | | | |
| 16 | | | |
| 17 | | | |
| 18 | | | |
| 19 | | | |
| 20 | | | |
| 21 | | | |
| 22 | | | |
| 23 | | | |
| 24 | | | |
| 25 | | | |
| 26 | | | |
| 27 | | | |
| 28 | | | |
| 29 | | | |
| 30 | | | |
| 31 | | | |
| 32 | | | |
| 33 | | | package org.jcoderz.phoenix.sqlparser; |
| 34 | | | |
| 35 | | | import java.util.ArrayList; |
| 36 | | | import java.util.Iterator; |
| 37 | | | import java.util.List; |
| 38 | | | |
| 39 | | | |
| 40 | | | @author |
| 41 | | | |
| 42 | | | public class CreateTableStatement extends SqlStatement |
| 43 | | | { |
| 44 | | | private final String mTableName; |
| 45 | | | private String mBeanName; |
| 46 | | | private String mAdditionalJavadoc; |
| 47 | | | private boolean mOptimisticVersionCount; |
| 48 | | | private boolean mSkipAppserverSupport; |
| 49 | | | |
| 50 | 100 | | private final List mColumns = new ArrayList(); |
| 51 | | | |
| 52 | 100 | | private final List mIndexes = new ArrayList(); |
| 53 | | | |
| 54 | 100 | | private final List mFkConstraints = new ArrayList(); |
| 55 | | | |
| 56 | | (1) | public CreateTableStatement (String tableName) |
| 57 | 100 | | { |
| 58 | 100 | | mTableName = tableName; |
| 59 | 100 | | } |
| 60 | | | |
| 61 | | | |
| 62 | | | |
| 63 | | | @return |
| 64 | | | |
| 65 | | | public final List getColumns () |
| 66 | | | { |
| 67 | 100 | | return mColumns; |
| 68 | | | } |
| 69 | | | |
| 70 | | | |
| 71 | | | |
| 72 | | | @return |
| 73 | | | |
| 74 | | | public final String getTableName () |
| 75 | | | { |
| 76 | 100 | | return mTableName; |
| 77 | | | } |
| 78 | | | |
| 79 | | | |
| 80 | | | |
| 81 | | | @param |
| 82 | | | |
| 83 | | | public final void addColumn (ColumnSpec column) |
| 84 | | | { |
| 85 | 100 | | mColumns.add(column); |
| 86 | 100 | | } |
| 87 | | | |
| 88 | | | |
| 89 | | | |
| 90 | | | @param |
| 91 | | | @return |
| 92 | | | |
| 93 | | | |
| 94 | | | public final ColumnSpec getColumnByName (String colName) |
| 95 | | | { |
| 96 | 100 | | ColumnSpec result = null; |
| 97 | 100 | | for (final Iterator it = mColumns.iterator(); it.hasNext(); ) |
| 98 | | | { |
| 99 | 100 | | final ColumnSpec col = (ColumnSpec) it.next(); |
| 100 | 100 | | if (col.getColumnName().equalsIgnoreCase(colName)) |
| 101 | | | { |
| 102 | 100 | | result = col; |
| 103 | 100 | | break; |
| 104 | | | } |
| 105 | 100 | | } |
| 106 | 100 | | return result; |
| 107 | | | } |
| 108 | | | |
| 109 | | | |
| 110 | | | |
| 111 | | | @return |
| 112 | | | |
| 113 | | | public final String toString () |
| 114 | | | { |
| 115 | 100 | (2) | final StringBuffer sbuf = new StringBuffer(); |
| 116 | 100 | | sbuf.append("[CREATE TABLE Statement: name=").append(mTableName); |
| 117 | 100 | | sbuf.append(", bean name=").append(mBeanName); |
| 118 | 100 | | sbuf.append(", annotation=").append(getAnnotation()); |
| 119 | 100 | | for (final Iterator it = mColumns.iterator(); it.hasNext();) |
| 120 | | | { |
| 121 | 100 | | final ColumnSpec col = (ColumnSpec) it.next(); |
| 122 | 100 | | sbuf.append(",\n col=").append(col); |
| 123 | 100 | | } |
| 124 | 100 | | sbuf.append(']'); |
| 125 | 100 | | return sbuf.toString(); |
| 126 | | | } |
| 127 | | | |
| 128 | | | @return |
| 129 | | | |
| 130 | | | public String getBeanName () |
| 131 | | | { |
| 132 | 0 | | return mBeanName; |
| 133 | | | } |
| 134 | | | |
| 135 | | | @param |
| 136 | | | |
| 137 | | | public void setBeanName (String beanName) |
| 138 | | | { |
| 139 | 0 | | mBeanName = beanName; |
| 140 | 0 | | } |
| 141 | | | |
| 142 | | (3) | public List getIndexes () |
| 143 | | | { |
| 144 | 100 | | return mIndexes; |
| 145 | | | } |
| 146 | | | |
| 147 | | (4) | public void addIndex (CreateIndexStatement stmt) |
| 148 | | | { |
| 149 | 100 | | mIndexes.add(stmt); |
| 150 | 100 | | } |
| 151 | | | |
| 152 | | (5) | public void addFkConstraint (FkConstraint constraint) |
| 153 | | | { |
| 154 | 0 | | mFkConstraints.add(constraint); |
| 155 | 0 | | } |
| 156 | | | |
| 157 | | (6) | public List getFkConstraints () |
| 158 | | | { |
| 159 | 100 | | return mFkConstraints; |
| 160 | | | } |
| 161 | | | |
| 162 | | | |
| 163 | | | @return |
| 164 | | | |
| 165 | | | public String getAdditionalJavadoc () |
| 166 | | | { |
| 167 | 0 | | return mAdditionalJavadoc; |
| 168 | | | } |
| 169 | | | |
| 170 | | | |
| 171 | | | @param |
| 172 | | | |
| 173 | | | public void setAdditionalJavadoc (String additionalJavadoc) |
| 174 | | | { |
| 175 | 0 | | mAdditionalJavadoc = additionalJavadoc; |
| 176 | 0 | | } |
| 177 | | | |
| 178 | | (7) | public void setOptimisticVersionCount (boolean b) |
| 179 | | | { |
| 180 | 0 | | mOptimisticVersionCount = b; |
| 181 | 0 | | } |
| 182 | | | |
| 183 | | (8) | public boolean isOptimisticVersionCount () |
| 184 | | | { |
| 185 | 0 | | return mOptimisticVersionCount; |
| 186 | | | } |
| 187 | | | |
| 188 | | | |
| 189 | | | @param |
| 190 | | | |
| 191 | | (9) | public void setSkipAppserverSupport (boolean b) |
| 192 | | | { |
| 193 | 0 | | mSkipAppserverSupport = b; |
| 194 | 0 | | } |
| 195 | | | |
| 196 | | | |
| 197 | | | @return |
| 198 | | | |
| 199 | | | public boolean isSkipAppserverSupport () |
| 200 | | | { |
| 201 | 0 | | return mSkipAppserverSupport; |
| 202 | | | } |
| 203 | | | } |