Project Report: fawkez

Packagesummary org.jcoderz.phoenix.sqlparser

org.jcoderz.phoenix.sqlparser.CreateTableStatement

LineHitsNoteSource
1  /*
2   * $Id: CreateTableStatement.java 1011 2008-06-16 17:57:36Z amandel $
3   *
4   * Copyright 2006, The jCoderZ.org Project. All rights reserved.
5   *
6   * Redistribution and use in source and binary forms, with or without
7   * modification, are permitted provided that the following conditions are
8   * met:
9   *
10   *    * Redistributions of source code must retain the above copyright
11   *      notice, this list of conditions and the following disclaimer.
12   *    * Redistributions in binary form must reproduce the above
13   *      copyright notice, this list of conditions and the following
14   *      disclaimer in the documentation and/or other materials
15   *      provided with the distribution.
16   *    * Neither the name of the jCoderZ.org Project nor the names of
17   *      its contributors may be used to endorse or promote products
18   *      derived from this software without specific prior written
19   *      permission.
20   *
21   * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
22   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24   * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS
25   * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31   * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 Albrecht Messner
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     
50100    private final List mColumns = new ArrayList();
51  
52100    private final List mIndexes = new ArrayList();
53     
54100    private final List mFkConstraints = new ArrayList();
55     
56 (1)   public CreateTableStatement (String tableName)
57100    {
58100       mTableName = tableName;
59100    }
60     
61     /**
62      * Returns all columns of this table.
63      * @return a list of ColumnSpec objects describing the columns of this table
64      */
65     public final List getColumns ()
66     {
67100       return mColumns;
68     }
69  
70     /**
71      * Returns the name of this table.
72      * @return the name of this table
73      */
74     public final String getTableName ()
75     {
76100       return mTableName;
77     }
78  
79     /**
80      * Adds a column definition to this table.
81      * @param column a column definition
82      */
83     public final void addColumn (ColumnSpec column)
84     {
85100       mColumns.add(column);
86100    }
87     
88     /**
89      * Retrieves a column by its name.
90      * @param colName the name of the column
91      * @return the column specification, or null
92      *         if no column by that name is found
93      */
94     public final ColumnSpec getColumnByName (String colName)
95     {
96100       ColumnSpec result = null;
97100       for (final Iterator it = mColumns.iterator(); it.hasNext(); )
98        {
99100          final ColumnSpec col = (ColumnSpec) it.next();
100100          if (col.getColumnName().equalsIgnoreCase(colName))
101           {
102100             result = col;
103100             break;
104           }
105100       }
106100       return result;
107     }
108  
109     /**
110      * Returns a readable string representation.
111      * @return a readable string representation
112      */
113     public final String toString ()
114     {
115100(2)      final StringBuffer sbuf = new StringBuffer();
116100       sbuf.append("[CREATE TABLE Statement: name=").append(mTableName);
117100       sbuf.append(", bean name=").append(mBeanName);
118100       sbuf.append(", annotation=").append(getAnnotation());
119100       for (final Iterator it = mColumns.iterator(); it.hasNext();)
120        {
121100          final ColumnSpec col = (ColumnSpec) it.next();
122100          sbuf.append(",\n col=").append(col);
123100       }
124100       sbuf.append(']');
125100       return sbuf.toString();
126     }
127     /**
128      * @return Returns the beanName.
129      */
130     public String getBeanName ()
131     {
1320       return mBeanName;
133     }
134     /**
135      * @param beanName The beanName to set.
136      */
137     public void setBeanName (String beanName)
138     {
1390       mBeanName = beanName;
1400    }
141     
142 (3)   public List getIndexes ()
143     {
144100       return mIndexes;
145     }
146     
147 (4)   public void addIndex (CreateIndexStatement stmt)
148     {
149100       mIndexes.add(stmt);
150100    }
151     
152 (5)   public void addFkConstraint (FkConstraint constraint)
153     {
1540       mFkConstraints.add(constraint);
1550    }
156     
157 (6)   public List getFkConstraints ()
158     {
159100       return mFkConstraints;
160     }
161     
162     /**
163      * @return Returns the additionalJavadoc.
164      */
165     public String getAdditionalJavadoc ()
166     {
1670       return mAdditionalJavadoc;
168     }
169  
170     /**
171      * @param additionalJavadoc The additionalJavadoc to set.
172      */
173     public void setAdditionalJavadoc (String additionalJavadoc)
174     {
1750       mAdditionalJavadoc = additionalJavadoc;
1760    }
177  
178 (7)   public void setOptimisticVersionCount (boolean b)
179     {
1800       mOptimisticVersionCount = b;
1810    }
182     
183 (8)   public boolean isOptimisticVersionCount ()
184     {
1850       return mOptimisticVersionCount;
186     }
187  
188     /**
189      * @param b
190    */
191 (9)   public void setSkipAppserverSupport (boolean b)
192     {
1930       mSkipAppserverSupport = b;
1940    }
195     
196     /**
197      * @return Returns the skipAppserverSupport.
198      */
199     public boolean isSkipAppserverSupport ()
200     {
2010       return mSkipAppserverSupport;
202     }
203  }

Findings in this File

c (1) 56 : 4 Missing a Javadoc comment.
i (2) 115 : 26 StringBuffer constructor is initialized with size 16, but has at least 66 characters appended.
c (3) 142 : 4 Missing a Javadoc comment.
c (4) 147 : 4 Missing a Javadoc comment.
c (5) 152 : 4 Missing a Javadoc comment.
c (6) 157 : 4 Missing a Javadoc comment.
c (7) 178 : 4 Missing a Javadoc comment.
c (8) 183 : 4 Missing a Javadoc comment.
c (9) 191 : 49 Expected @param tag for 'b'.