%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.torque.engine.database.model.Unique |
|
|
1 | package org.apache.torque.engine.database.model; |
|
2 | ||
3 | /* |
|
4 | * Licensed to the Apache Software Foundation (ASF) under one |
|
5 | * or more contributor license agreements. See the NOTICE file |
|
6 | * distributed with this work for additional information |
|
7 | * regarding copyright ownership. The ASF licenses this file |
|
8 | * to you under the Apache License, Version 2.0 (the |
|
9 | * "License"); you may not use this file except in compliance |
|
10 | * with the License. You may obtain a copy of the License at |
|
11 | * |
|
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
13 | * |
|
14 | * Unless required by applicable law or agreed to in writing, |
|
15 | * software distributed under the License is distributed on an |
|
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
17 | * KIND, either express or implied. See the License for the |
|
18 | * specific language governing permissions and limitations |
|
19 | * under the License. |
|
20 | */ |
|
21 | ||
22 | import java.util.List; |
|
23 | ||
24 | /** |
|
25 | * Information about unique columns of a table. This class assumes |
|
26 | * that in the underlying RDBMS, unique constraints and unique indices |
|
27 | * are roughly equivalent. For example, adding a unique constraint to |
|
28 | * a column also creates an index on that column (this is known to be |
|
29 | * true for MySQL and Oracle). |
|
30 | * |
|
31 | * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a> |
|
32 | * @author <a href="mailto:dlr@collab.net">Daniel Rall</a> |
|
33 | * @version $Id: Unique.java 473814 2006-11-11 22:30:30Z tv $ |
|
34 | */ |
|
35 | 63 | public class Unique extends Index |
36 | { |
|
37 | /** |
|
38 | * Returns <code>true</code>. |
|
39 | * |
|
40 | * @return true |
|
41 | */ |
|
42 | public final boolean isUnique() |
|
43 | { |
|
44 | 0 | return true; |
45 | } |
|
46 | ||
47 | /** |
|
48 | * String representation of the index. This is an xml representation. |
|
49 | * |
|
50 | * @return string representation in xml |
|
51 | */ |
|
52 | public String toString() |
|
53 | { |
|
54 | 0 | StringBuffer result = new StringBuffer(); |
55 | 0 | result.append(" <unique name=\"") |
56 | .append(getName()) |
|
57 | .append("\">\n"); |
|
58 | ||
59 | 0 | List columns = getColumns(); |
60 | 0 | for (int i = 0; i < columns.size(); i++) |
61 | { |
|
62 | 0 | result.append(" <unique-column name=\"") |
63 | .append(columns.get(i)) |
|
64 | .append("\"/>\n"); |
|
65 | } |
|
66 | 0 | result.append(" </unique>\n"); |
67 | 0 | return result.toString(); |
68 | } |
|
69 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |