001package gudusoft.gsqlparser.stmt.oracle;
002
003import gudusoft.gsqlparser.EDbObjectType;
004import gudusoft.gsqlparser.EDbVendor;
005import gudusoft.gsqlparser.ESqlStatementType;
006import gudusoft.gsqlparser.TCustomSqlStatement;
007import gudusoft.gsqlparser.TBaseType;
008import gudusoft.gsqlparser.nodes.TObjectName;
009import gudusoft.gsqlparser.nodes.TTypeAttributeList;
010import gudusoft.gsqlparser.nodes.TParseTreeVisitor;
011
012
013/**
014 * The CREATE TYPE statement creates or replaces
015 * <p>the specification of an object type,represented by {@link TPlsqlCreateType}.
016 * <p>a SQLJ object type (not supported),
017 * <p>a named varying array (varray), represented by {@link TPlsqlVarrayTypeDefStmt}.
018 * <p>a nested table type, represented by {@link TPlsqlTableTypeDefStmt}.
019 * <p>or an incomplete object type, represented by {@link TPlsqlCreateType}.
020 *
021 * <p>element specification was generated in parse tree, but not public available currently.
022*/
023public class TPlsqlCreateType extends TCustomSqlStatement {
024
025    private int kind = TBaseType.kind_create_type_placeholder;
026
027    public void setKind(int kind) {
028        this.kind = kind;
029    }
030
031    /**
032     *
033     * @return what's kind of SQL statement this class represents for.
034     * <p> {@link TBaseType#kind_define}: create the specification of an object type.
035     * <p> {@link TBaseType#kind_create_incomplete}: create an incomplete object type.
036     */
037    public int getKind() {
038        return kind;
039    }
040
041    /**
042     * List of attribute definition of this object type.
043     * @return {@link TTypeAttributeList}
044     */
045    public TTypeAttributeList getTypeAttributes() {
046        return typeAttributes;
047    }
048
049    public void setAttributes(TTypeAttributeList attributes) {
050
051        this.typeAttributes = attributes;
052    }
053
054    private TTypeAttributeList typeAttributes = null;
055
056    public TPlsqlCreateType(){
057        this(EDbVendor.dbvoracle);
058    }
059
060     public TPlsqlCreateType(EDbVendor dbvendor){
061        super(dbvendor);
062        sqlstatementtype = ESqlStatementType.sstplsql_createtype ;
063        }
064
065    /**
066     * Name of an object type.
067     * @return
068     */
069    public TObjectName getTypeName() {
070        return typeName;
071    }
072
073    private TObjectName typeName = null;
074    public void init(Object arg1)
075    {
076        typeName = (TObjectName)arg1;
077        //typeName.setObjectType(TObjectName.ttobjTypeName);
078        typeName.setDbObjectType(EDbObjectType.user_defined_type);
079    }
080
081
082    public int doParseStatement(TCustomSqlStatement psql) {
083
084        super.doParseStatement(psql);
085
086        return 0;
087    }
088
089    public void accept(TParseTreeVisitor v){
090        v.preVisit(this);
091        v.postVisit(this);
092    }
093
094    public void acceptChildren(TParseTreeVisitor v){
095        v.preVisit(this);
096        v.postVisit(this);
097    }
098
099    public void setTypeName(TObjectName typeName) {
100        this.typeName = typeName;
101    }
102}