~ubuntu-branches/ubuntu/wily/apgdiff/wily

« back to all changes in this revision

Viewing changes to src/main/java/cz/startnet/utils/pgdiff/parsers/CreateViewParser.java

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Berg
  • Date: 2009-12-02 11:11:33 UTC
  • mfrom: (1.1.2 upstream)
  • 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: CreateViewParser.java 94 2008-09-30 11:07:28Z fordfrog $
3
 
 */
4
1
package cz.startnet.utils.pgdiff.parsers;
5
2
 
6
3
import cz.startnet.utils.pgdiff.schema.PgDatabase;
10
7
import java.util.regex.Matcher;
11
8
import java.util.regex.Pattern;
12
9
 
13
 
 
14
10
/**
15
11
 * Parses CREATE VIEW commands.
16
12
 *
17
13
 * @author fordfrog
18
 
 * @version $Id: CreateViewParser.java 94 2008-09-30 11:07:28Z fordfrog $
19
14
 */
20
15
public class CreateViewParser {
 
16
 
21
17
    /**
22
18
     * Pattern for parsing CREATE VIEW definition.
23
19
     */
24
 
    private static final Pattern PATTERN =
25
 
        Pattern.compile(
26
 
                "CREATE[\\s]+(?:OR[\\s]+REPLACE[\\s]+)?VIEW[\\s]+"
27
 
                + "\"?([^\\s\"]+)\"?[\\s]+(?:\\(([^)]+)\\)[\\s]+)?"
28
 
                + "AS[\\s]+(.+)?(?:;)",
29
 
                Pattern.CASE_INSENSITIVE);
 
20
    private static final Pattern PATTERN = Pattern.compile(
 
21
            "CREATE[\\s]+(?:OR[\\s]+REPLACE[\\s]+)?VIEW[\\s]+"
 
22
            + "\"?([^\\s\"]+)\"?[\\s]+(?:\\(([^)]+)\\)[\\s]+)?"
 
23
            + "AS[\\s]+(.+)?(?:;)", Pattern.CASE_INSENSITIVE);
30
24
 
31
25
    /**
32
26
     * Creates a new instance of CreateViewParser.
62
56
            view.setQuery(query);
63
57
 
64
58
            final PgSchema schema =
65
 
                database.getSchema(
66
 
                        ParserUtils.getSchemaName(viewName, database));
 
59
                    database.getSchema(
 
60
                    ParserUtils.getSchemaName(viewName, database));
67
61
            schema.addView(view);
68
62
        } else {
69
63
            throw new ParserException(