~ubuntu-branches/ubuntu/vivid/apgdiff/vivid

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2010-10-02 19:35:17 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20101002193517-9wesve8sksxcktkc
Tags: 2.2-1
* New upstream version.
* Update homepage location.
* Finally enable test suite, yay!

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;
37
42
     * True if CYCLE, false if NO CYCLE.
38
43
     */
39
44
    private boolean cycle;
 
45
    /**
 
46
     * Column the sequence is owned by.
 
47
     */
 
48
    private String ownedBy;
40
49
 
41
50
    /**
42
51
     * Creates a new PgSequence object.
66
75
    }
67
76
 
68
77
    /**
69
 
     * Creates and returns SQL command for creation of the sequence.
70
 
     *
71
 
     * @param quoteNames whether names should be quoted
72
 
     *
73
 
     * @return created SQL command
 
78
     * Creates and returns SQL statement for creation of the sequence.
 
79
     *
 
80
     * @return created SQL statement
74
81
     */
75
 
    public String getCreationSQL(final boolean quoteNames) {
76
 
        final StringBuilder sbSQL = new StringBuilder();
 
82
    public String getCreationSQL() {
 
83
        final StringBuilder sbSQL = new StringBuilder(100);
77
84
        sbSQL.append("CREATE SEQUENCE ");
78
 
        sbSQL.append(PgDiffUtils.getQuotedName(name, quoteNames));
 
85
        sbSQL.append(PgDiffUtils.getQuotedName(name));
79
86
 
80
87
        if (startWith != null) {
81
88
            sbSQL.append("\n\tSTART WITH ");
114
121
            sbSQL.append("\n\tCYCLE");
115
122
        }
116
123
 
 
124
        if (ownedBy != null && !ownedBy.isEmpty()) {
 
125
            sbSQL.append("\n\tOWNED BY ");
 
126
            sbSQL.append(PgDiffUtils.getQuotedName(ownedBy));
 
127
        }
 
128
 
117
129
        sbSQL.append(';');
118
130
 
119
131
        return sbSQL.toString();
138
150
    }
139
151
 
140
152
    /**
141
 
     * Creates and returns SQL command for dropping the sequence.
142
 
     *
143
 
     * @param quoteNames whether names should be quoted
 
153
     * Creates and returns SQL statement for dropping the sequence.
144
154
     *
145
155
     * @return created SQL
146
156
     */
147
 
    public String getDropSQL(final boolean quoteNames) {
148
 
        return "DROP SEQUENCE "
149
 
                + PgDiffUtils.getQuotedName(getName(), quoteNames) + ";";
 
157
    public String getDropSQL() {
 
158
        return "DROP SEQUENCE " + PgDiffUtils.getQuotedName(getName()) + ";";
150
159
    }
151
160
 
152
161
    /**
238
247
    public String getStartWith() {
239
248
        return startWith;
240
249
    }
 
250
 
 
251
    /**
 
252
     * Getter for {@link #ownedBy}.
 
253
     *
 
254
     * @return {@link #ownedBy}
 
255
     */
 
256
    public String getOwnedBy() {
 
257
        return ownedBy;
 
258
    }
 
259
 
 
260
    /**
 
261
     * Setter for {@link #ownedBy}.
 
262
     *
 
263
     * @param ownedBy {@link #ownedBy}
 
264
     */
 
265
    public void setOwnedBy(final String ownedBy) {
 
266
        this.ownedBy = ownedBy;
 
267
    }
241
268
}