1 package org.apache.torque.engine.database.model;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import java.util.List;
20
21 /***
22 * Information about unique columns of a table. This class assumes
23 * that in the underlying RDBMS, unique constraints and unique indices
24 * are roughly equivalent. For example, adding a unique constraint to
25 * a column also creates an index on that column (this is known to be
26 * true for MySQL and Oracle).
27 *
28 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
29 * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
30 * @version $Id: Unique.java 239624 2005-08-24 12:18:03Z henning $
31 */
32 public class Unique extends Index
33 {
34 /***
35 * Returns <code>true</code>.
36 *
37 * @return true
38 */
39 public final boolean isUnique()
40 {
41 return true;
42 }
43
44 /***
45 * String representation of the index. This is an xml representation.
46 *
47 * @return string representation in xml
48 */
49 public String toString()
50 {
51 StringBuffer result = new StringBuffer();
52 result.append(" <unique name=\"")
53 .append(getName())
54 .append("\">\n");
55
56 List columns = getColumns();
57 for (int i = 0; i < columns.size(); i++)
58 {
59 result.append(" <unique-column name=\"")
60 .append(columns.get(i))
61 .append("\"/>\n");
62 }
63 result.append(" </unique>\n");
64 return result.toString();
65 }
66 }