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

« back to all changes in this revision

Viewing changes to src/main/java/cz/startnet/utils/pgdiff/schema/PgColumn.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;
47
52
     * Determines whether null value is allowed in the column.
48
53
     */
49
54
    private boolean nullValue = true;
 
55
    /**
 
56
     * Contains information about column storage type.
 
57
     */
 
58
    private String storage;
50
59
 
51
60
    /**
52
61
     * Creates a new PgColumn object.
78
87
    /**
79
88
     * Returns full definition of the column.
80
89
     *
81
 
     * @param quoteName whether name should be quoted
82
90
     * @param addDefaults whether default value should be added in case NOT
83
91
     *        NULL constraint is specified but no default value is set
84
92
     *
85
93
     * @return full definition of the column
86
94
     */
87
 
    public String getFullDefinition(final boolean quoteName,
88
 
            final boolean addDefaults) {
89
 
        final StringBuilder sbDefinition = new StringBuilder();
90
 
        sbDefinition.append(PgDiffUtils.getQuotedName(name, quoteName));
 
95
    public String getFullDefinition(final boolean addDefaults) {
 
96
        final StringBuilder sbDefinition = new StringBuilder(100);
 
97
        sbDefinition.append(PgDiffUtils.getQuotedName(name));
91
98
        sbDefinition.append(' ');
92
99
        sbDefinition.append(type);
93
100
 
94
 
        if ((defaultValue != null) && (defaultValue.length() > 0)) {
 
101
        if (defaultValue != null && !defaultValue.isEmpty()) {
95
102
            sbDefinition.append(" DEFAULT ");
96
103
            sbDefinition.append(defaultValue);
97
104
        } else if (!nullValue && addDefaults) {
165
172
    }
166
173
 
167
174
    /**
 
175
     * Getter for {@link #storage}.
 
176
     *
 
177
     * @return {@link #storage}
 
178
     */
 
179
    public String getStorage() {
 
180
        return storage;
 
181
    }
 
182
 
 
183
    /**
 
184
     * Setter for {@link #storage}.
 
185
     *
 
186
     * @param storage {@link #storage}
 
187
     */
 
188
    public void setStorage(final String storage) {
 
189
        this.storage = storage;
 
190
    }
 
191
 
 
192
    /**
168
193
     * Setter for {@link #type}.
169
194
     *
170
195
     * @param type {@link #type}