~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: 2009-12-02 11:11:33 UTC
  • mfrom: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20091202111133-k5wrh3zb2pzmbv8c
Tags: 1.4-1
* New upstream version. (Without changelog, I am afraid.)
* Test suite still not enabled as it needs network access. (The junit
  version in Debian needs upgrading.)
* Optimize rules files a bit so debhelper doesn't clean twice, and quilt's
  patch target doesn't prevent build-stamp from working.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * $Id: PgColumn.java 80 2007-09-01 20:25:45Z fordfrog $
3
 
 */
4
1
package cz.startnet.utils.pgdiff.schema;
5
2
 
6
3
import cz.startnet.utils.pgdiff.PgDiffUtils;
8
5
import java.util.regex.Matcher;
9
6
import java.util.regex.Pattern;
10
7
 
11
 
 
12
8
/**
13
9
 * Stores column information.
14
10
 *
15
11
 * @author fordfrog
16
 
 * @version $Id: PgColumn.java 80 2007-09-01 20:25:45Z fordfrog $
17
12
 */
18
13
public class PgColumn {
 
14
 
19
15
    /**
20
16
     * Pattern for parsing NULL arguments.
21
17
     */
22
18
    private static final Pattern PATTERN_NULL =
23
 
        Pattern.compile("^(.+)[\\s]+NULL$", Pattern.CASE_INSENSITIVE);
24
 
 
 
19
            Pattern.compile("^(.+)[\\s]+NULL$", Pattern.CASE_INSENSITIVE);
25
20
    /**
26
21
     * Pattern for parsing NOT NULL arguments.
27
22
     */
28
 
    private static final Pattern PATTERN_NOT_NULL =
29
 
        Pattern.compile("^(.+)[\\s]+NOT[\\s]+NULL$", Pattern.CASE_INSENSITIVE);
30
 
 
 
23
    private static final Pattern PATTERN_NOT_NULL = Pattern.compile(
 
24
            "^(.+)[\\s]+NOT[\\s]+NULL$", Pattern.CASE_INSENSITIVE);
31
25
    /**
32
26
     * Pattern for parsing DEFAULT value.
33
27
     */
34
 
    private static final Pattern PATTERN_DEFAULT =
35
 
        Pattern.compile(
36
 
                "^(.+)[\\s]+DEFAULT[\\s]+(.+)$",
37
 
                Pattern.CASE_INSENSITIVE);
38
 
 
 
28
    private static final Pattern PATTERN_DEFAULT = Pattern.compile(
 
29
            "^(.+)[\\s]+DEFAULT[\\s]+(.+)$", Pattern.CASE_INSENSITIVE);
39
30
    /**
40
31
     * Specific statistics value.
41
32
     */
42
33
    private Integer statistics;
43
 
 
44
34
    /**
45
35
     * Default value of the column.
46
36
     */
47
37
    private String defaultValue;
48
 
 
49
38
    /**
50
39
     * Name of the column.
51
40
     */
52
41
    private String name;
53
 
 
54
42
    /**
55
43
     * Type of the column.
56
44
     */
57
45
    private String type;
58
 
 
59
46
    /**
60
47
     * Determines whether null value is allowed in the column.
61
48
     */
97
84
     *
98
85
     * @return full definition of the column
99
86
     */
100
 
    public String getFullDefinition(
101
 
        final boolean quoteName,
102
 
        final boolean addDefaults) {
 
87
    public String getFullDefinition(final boolean quoteName,
 
88
            final boolean addDefaults) {
103
89
        final StringBuilder sbDefinition = new StringBuilder();
104
90
        sbDefinition.append(PgDiffUtils.getQuotedName(name, quoteName));
105
91
        sbDefinition.append(' ');