EMMA Coverage Report (generated Sun Mar 01 22:06:14 CET 2015)
[all classes][org.h2.command.ddl]

COVERAGE SUMMARY FOR SOURCE FILE [CreateFunctionAlias.java]

nameclass, %method, %block, %line, %
CreateFunctionAlias.java100% (1/1)100% (10/10)95%  (106/111)97%  (30/31)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CreateFunctionAlias100% (1/1)100% (10/10)95%  (106/111)97%  (30/31)
update (): int 100% (1/1)93%  (65/70)92%  (12/13)
CreateFunctionAlias (Session, Schema): void 100% (1/1)100% (8/8)100% (3/3)
getType (): int 100% (1/1)100% (2/2)100% (1/1)
setAliasName (String): void 100% (1/1)100% (4/4)100% (2/2)
setBufferResultSetToLocalTemp (boolean): void 100% (1/1)100% (4/4)100% (2/2)
setDeterministic (boolean): void 100% (1/1)100% (4/4)100% (2/2)
setForce (boolean): void 100% (1/1)100% (4/4)100% (2/2)
setIfNotExists (boolean): void 100% (1/1)100% (4/4)100% (2/2)
setJavaClassMethod (String): void 100% (1/1)100% (7/7)100% (2/2)
setSource (String): void 100% (1/1)100% (4/4)100% (2/2)

1/*
2 * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (http://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6package org.h2.command.ddl;
7 
8import org.h2.api.ErrorCode;
9import org.h2.command.CommandInterface;
10import org.h2.engine.Database;
11import org.h2.engine.FunctionAlias;
12import org.h2.engine.Session;
13import org.h2.message.DbException;
14import org.h2.schema.Schema;
15import org.h2.util.StringUtils;
16 
17/**
18 * This class represents the statement
19 * CREATE ALIAS
20 */
21public class CreateFunctionAlias extends SchemaCommand {
22 
23    private String aliasName;
24    private String javaClassMethod;
25    private boolean deterministic;
26    private boolean ifNotExists;
27    private boolean force;
28    private String source;
29    private boolean bufferResultSetToLocalTemp = true;
30 
31    public CreateFunctionAlias(Session session, Schema schema) {
32        super(session, schema);
33    }
34 
35    @Override
36    public int update() {
37        session.commit(true);
38        session.getUser().checkAdmin();
39        Database db = session.getDatabase();
40        if (getSchema().findFunction(aliasName) != null) {
41            if (!ifNotExists) {
42                throw DbException.get(
43                        ErrorCode.FUNCTION_ALIAS_ALREADY_EXISTS_1, aliasName);
44            }
45        } else {
46            int id = getObjectId();
47            FunctionAlias functionAlias;
48            if (javaClassMethod != null) {
49                functionAlias = FunctionAlias.newInstance(getSchema(), id,
50                        aliasName, javaClassMethod, force,
51                        bufferResultSetToLocalTemp);
52            } else {
53                functionAlias = FunctionAlias.newInstanceFromSource(
54                        getSchema(), id, aliasName, source, force,
55                        bufferResultSetToLocalTemp);
56            }
57            functionAlias.setDeterministic(deterministic);
58            db.addSchemaObject(session, functionAlias);
59        }
60        return 0;
61    }
62 
63    public void setAliasName(String name) {
64        this.aliasName = name;
65    }
66 
67    /**
68     * Set the qualified method name after removing whitespace.
69     *
70     * @param method the qualified method name
71     */
72    public void setJavaClassMethod(String method) {
73        this.javaClassMethod = StringUtils.replaceAll(method, " ", "");
74    }
75 
76    public void setIfNotExists(boolean ifNotExists) {
77        this.ifNotExists = ifNotExists;
78    }
79 
80    public void setForce(boolean force) {
81        this.force = force;
82    }
83 
84    public void setDeterministic(boolean deterministic) {
85        this.deterministic = deterministic;
86    }
87 
88    /**
89     * Should the return value ResultSet be buffered in a local temporary file?
90     *
91     * @param b the new value
92     */
93    public void setBufferResultSetToLocalTemp(boolean b) {
94        this.bufferResultSetToLocalTemp = b;
95    }
96 
97    public void setSource(String source) {
98        this.source = source;
99    }
100 
101    @Override
102    public int getType() {
103        return CommandInterface.CREATE_ALIAS;
104    }
105 
106}

[all classes][org.h2.command.ddl]
EMMA 2.0.5312 (C) Vladimir Roubtsov