001    /*
002     * JBoss DNA (http://www.jboss.org/dna)
003     * See the COPYRIGHT.txt file distributed with this work for information
004     * regarding copyright ownership.  Some portions may be licensed
005     * to Red Hat, Inc. under one or more contributor license agreements.
006     * See the AUTHORS.txt file in the distribution for a full listing of 
007     * individual contributors. 
008     *
009     * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
010     * is licensed to you under the terms of the GNU Lesser General Public License as
011     * published by the Free Software Foundation; either version 2.1 of
012     * the License, or (at your option) any later version.
013     *
014     * JBoss DNA is distributed in the hope that it will be useful,
015     * but WITHOUT ANY WARRANTY; without even the implied warranty of
016     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017     * Lesser General Public License for more details.
018     *
019     * You should have received a copy of the GNU Lesser General Public
020     * License along with this software; if not, write to the Free
021     * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
022     * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
023     */
024    package org.jboss.dna.common.jdbc.model.api;
025    
026    import java.util.Set;
027    
028    /**
029     * Provides all column specific metadata.
030     * 
031     * @author <a href="mailto:litsenko_sergey@yahoo.com">Sergiy Litsenko</a>
032     */
033    public interface Column extends DatabaseNamedObject {
034    
035        /**
036         * Returns owner of ColumnMetaData such as Table, or Stored Procedure, UDT, PK, FK, Index, etc. May return NULL
037         * 
038         * @return owner of ColumnMetaData such as Table, or Stored Procedure, or UDT, PK, FK, Index, etc. May return NULL
039         */
040        SchemaObject getOwner();
041    
042        /**
043         * Sets the owner of ColumnMetaData
044         * 
045         * @param owner the owner of ColumnMetaData
046         */
047        void setOwner( SchemaObject owner );
048    
049        /**
050         * Gets column nullability
051         * 
052         * @return column nullability
053         */
054        NullabilityType getNullabilityType();
055    
056        /**
057         * Sets column nullability
058         * 
059         * @param nullabilityType the column nullability
060         */
061        void setNullabilityType( NullabilityType nullabilityType );
062    
063        /**
064         * Gets SQL type from java.sql.Types
065         * 
066         * @return SQL type from java.sql.Types
067         */
068        SqlType getSqlType();
069    
070        /**
071         * Sets SQL type from java.sql.Types
072         * 
073         * @param sqlType the SQL type from java.sql.Types
074         */
075        void setSqlType( SqlType sqlType );
076    
077        /**
078         * Data source dependent type name. For a UDT, the type name is fully qualified. For a REF, the type name is fully qualified
079         * and represents the target type of the reference type.
080         * 
081         * @return data source dependent type name
082         */
083        String getTypeName();
084    
085        /**
086         * Data source dependent type name. For a UDT, the type name is fully qualified. For a REF, the type name is fully qualified
087         * and represents the target type of the reference type.
088         * 
089         * @param typeName data source dependent type name
090         */
091        void setTypeName( String typeName );
092    
093        /**
094         * Gets column size. For char or date types this is the maximum number of characters, for numeric or decimal types this is
095         * precision. For Stored procedure columns it is length in bytes of data
096         * 
097         * @return column size
098         */
099        Integer getSize();
100    
101        /**
102         * Sets column size. For char or date types this is the maximum number of characters, for numeric or decimal types this is
103         * precision. For Stored procedure columns it is length in bytes of data
104         * 
105         * @param size the column size
106         */
107        void setSize( Integer size );
108    
109        /**
110         * Gets precision if applicable otherwise 0. For table columns return the number of fractional digits; for stored procedure
111         * column - scale.
112         * 
113         * @return precision if applicable otherwise 0
114         */
115        Integer getPrecision();
116    
117        /**
118         * Sets precision if applicable otherwise 0. For table columns return the number of fractional digits; for stored procedure
119         * column - scale.
120         * 
121         * @param precision the precision if applicable otherwise 0
122         */
123        void setPrecision( Integer precision );
124    
125        /**
126         * Gets radix if applicable
127         * 
128         * @return radix if applicable
129         */
130        Integer getRadix();
131    
132        /**
133         * Sets radix if applicable
134         * 
135         * @param radix if applicable
136         */
137        void setRadix( Integer radix );
138    
139        /**
140         * Gets default value (may be <code>null</code>)
141         * 
142         * @return default value (may be <code>null</code>)
143         */
144        String getDefaultValue();
145    
146        /**
147         * Sets default value (may be <code>null</code>)
148         * 
149         * @param defaultValue the default value (may be <code>null</code>)
150         */
151        void setDefaultValue( String defaultValue );
152    
153        /**
154         * Returns index of column starting at 1 - if applicable. Otherwise returns -1.
155         * 
156         * @return index of column starting at 1 - if applicable. Otherwise returns -1.
157         */
158        Integer getOrdinalPosition();
159    
160        /**
161         * Sets index of column starting at 1 - if applicable. Otherwise returns -1.
162         * 
163         * @param ordinalPosition the index of column starting at 1 - if applicable. Otherwise returns -1.
164         */
165        void setOrdinalPosition( Integer ordinalPosition );
166    
167        /**
168         * For char types returns the maximum number of bytes in the column. Otherwise returns -1. May return null.
169         * 
170         * @return For char types returns the maximum number of bytes in the column. Otherwise returns -1. May return null.
171         */
172        Integer getCharOctetLength();
173    
174        /**
175         * For char types sets the maximum number of bytes in the column. Otherwise -1.
176         * 
177         * @param charOctetLength For char types sets the maximum number of bytes in the column. Otherwise -1.
178         */
179        void setCharOctetLength( Integer charOctetLength );
180    
181        /**
182         * Gets table column privileges.
183         * 
184         * @return set of table column privileges
185         */
186        Set<Privilege> getPrivileges();
187    
188        /**
189         * Adds table column priviledge
190         * 
191         * @param privilege the table column priviledge
192         */
193        void addPrivilege( Privilege privilege );
194    
195        /**
196         * Deletes table column priviledge
197         * 
198         * @param privilege the table column priviledge
199         */
200        void deletePrivilege( Privilege privilege );
201    
202        /**
203         * Searches priviledge by name
204         * 
205         * @param priviledgeName the priviledge name to search
206         * @return priviledge if found, otherwise return null
207         */
208        Privilege findPriviledgeByName( String priviledgeName );
209    }