All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.espertech.esper.client.soda.CreateTableClause Maven / Gradle / Ivy

There is a newer version: 7.1.0
Show newest version
/**************************************************************************************
 * Copyright (C) 2006-2015 EsperTech Inc. All rights reserved.                        *
 * http://www.espertech.com/esper                                                          *
 * http://www.espertech.com                                                           *
 * ---------------------------------------------------------------------------------- *
 * The software in this package is published under the terms of the GPL license       *
 * a copy of which has been included with this distribution in the license.txt file.  *
 **************************************************************************************/
package com.espertech.esper.client.soda;

import java.io.Serializable;
import java.io.StringWriter;
import java.util.List;

/**
 * Represents a create-variable syntax for creating a new variable.
 */
public class CreateTableClause implements Serializable
{
    private static final long serialVersionUID = 0L;

    private String tableName;
    private List columns;

    /**
     * Ctor.
     */
    public CreateTableClause() {
    }

    /**
     * Ctor.
     * @param tableName the table name
     */
    public CreateTableClause(String tableName) {
        this.tableName = tableName;
    }

    /**
     * Ctor.
     * @param tableName the table name
     * @param columns table columns
     */
    public CreateTableClause(String tableName, List columns) {
        this.tableName = tableName;
        this.columns = columns;
    }

    /**
     * Returns the table name
     * @return table name
     */
    public String getTableName() {
        return tableName;
    }

    /**
     * Sets the table name
     * @param tableName table name
     */
    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    /**
     * Returns the table columns
     * @return table columns
     */
    public List getColumns() {
        return columns;
    }

    /**
     * Sets the table columns
     * @param columns table columns
     */
    public void setColumns(List columns) {
        this.columns = columns;
    }

    /**
     * Render create-table clause
     * @param writer to render to
     */
    public void toEPL(StringWriter writer)
    {
        writer.append("create table ");
        writer.append(tableName);
        writer.append(" (");
        String delimiter = "";
        for (CreateTableColumn col : columns) {
            writer.append(delimiter);
            col.toEPL(writer);
            delimiter = ", ";
        }
        writer.append(")");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy