~ubuntu-branches/ubuntu/raring/apgdiff/raring

« back to all changes in this revision

Viewing changes to src/main/java/cz/startnet/utils/pgdiff/schema/PgIndex.java

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2010-10-11 09:08:18 UTC
  • mfrom: (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20101011090818-sdw8yfemrnxo328k
Tags: 2.2.2-1
* New upstream version.
* Using changelog included in zipfile, thanks Miroslav for providing this.
* Update manpage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Copyright 2006 StartNet s.r.o.
 
3
 *
 
4
 * Distributed under MIT license
 
5
 */
1
6
package cz.startnet.utils.pgdiff.schema;
2
7
 
3
8
import cz.startnet.utils.pgdiff.PgDiffUtils;
32
37
     * @param name {@link #name}
33
38
     */
34
39
    public PgIndex(final String name) {
35
 
        super();
36
40
        this.name = name;
37
41
    }
38
42
 
39
43
    /**
40
44
     * Creates and returns SQL for creation of the index.
41
45
     *
42
 
     * @param quoteNames whether names should be quoted
43
 
     *
44
46
     * @return created SQL
45
47
     */
46
 
    public String getCreationSQL(final boolean quoteNames) {
47
 
        final StringBuilder sbSQL = new StringBuilder();
 
48
    public String getCreationSQL() {
 
49
        final StringBuilder sbSQL = new StringBuilder(100);
48
50
        sbSQL.append("CREATE ");
49
51
 
50
52
        if (isUnique()) {
52
54
        }
53
55
 
54
56
        sbSQL.append("INDEX ");
55
 
        sbSQL.append(PgDiffUtils.getQuotedName(getName(), quoteNames));
 
57
        sbSQL.append(PgDiffUtils.getQuotedName(getName()));
56
58
        sbSQL.append(" ON ");
57
 
        sbSQL.append(PgDiffUtils.getQuotedName(getTableName(), quoteNames));
 
59
        sbSQL.append(PgDiffUtils.getQuotedName(getTableName()));
58
60
        sbSQL.append(' ');
59
61
        sbSQL.append(getDefinition());
60
62
        sbSQL.append(';');
81
83
    }
82
84
 
83
85
    /**
84
 
     * Creates and returns SQL command for dropping the index.
85
 
     *
86
 
     * @param quoteNames whether names should be quoted
87
 
     *
88
 
     * @return created SQL command
 
86
     * Creates and returns SQL statement for dropping the index.
 
87
     *
 
88
     * @return created SQL statement
89
89
     */
90
 
    public String getDropSQL(final boolean quoteNames) {
91
 
        return "DROP INDEX " + PgDiffUtils.getQuotedName(getName(), quoteNames)
92
 
                + ";";
 
90
    public String getDropSQL() {
 
91
        return "DROP INDEX " + PgDiffUtils.getQuotedName(getName()) + ";";
93
92
    }
94
93
 
95
94
    /**
143
142
            equals = true;
144
143
        } else if (object instanceof PgIndex) {
145
144
            final PgIndex index = (PgIndex) object;
146
 
            equals = definition.equals(index.definition)
147
 
                    && name.equals(index.name)
148
 
                    && tableName.equals(index.tableName)
149
 
                    && unique == index.unique;
 
145
            equals = definition.equals(index.getDefinition())
 
146
                    && name.equals(index.getName())
 
147
                    && tableName.equals(index.getTableName())
 
148
                    && unique == index.isUnique();
150
149
        }
151
150
 
152
151
        return equals;