001    package railo.runtime.db;
002    
003    import java.util.TimeZone;
004    
005    import railo.runtime.type.Struct;
006    
007    /**
008     * interface for a datasource
009     */
010    public interface DataSource extends Cloneable {
011    
012        /**
013         * Field <code>ALLOW_SELECT</code>
014         */
015        public static final int ALLOW_SELECT = 1;
016    
017        /**
018         * Field <code>ALLOW_DELETE</code>
019         */
020        public static final int ALLOW_DELETE = 2;
021    
022        /**
023         * Field <code>ALLOW_UPDATE</code>
024         */
025        public static final int ALLOW_UPDATE = 4;
026    
027        /**
028         * Field <code>ALLOW_INSERT</code>
029         */
030        public static final int ALLOW_INSERT = 8;
031    
032        /**
033         * Field <code>ALLOW_CREATE</code>
034         */
035        public static final int ALLOW_CREATE = 16;
036    
037        /**
038         * Field <code>ALLOW_GRANT</code>
039         */
040        public static final int ALLOW_GRANT = 32;
041    
042        /**
043         * Field <code>ALLOW_REVOKE</code>
044         */
045        public static final int ALLOW_REVOKE = 64;
046    
047        /**
048         * Field <code>ALLOW_DROP</code>
049         */
050        public static final int ALLOW_DROP = 128;
051    
052        /**
053         * Field <code>ALLOW_ALTER</code>
054         */
055        public static final int ALLOW_ALTER = 256;
056    
057        /**
058         * Field <code>ALLOW_ALL</code>
059         */
060        public static final int ALLOW_ALL = ALLOW_SELECT + ALLOW_DELETE
061                + ALLOW_UPDATE + ALLOW_INSERT + ALLOW_CREATE + ALLOW_GRANT
062                + ALLOW_REVOKE + ALLOW_DROP + ALLOW_ALTER;
063    
064        /**
065         * @return Returns the dsn.
066         */
067        public abstract String getDsnOriginal(); // FUTURE deprecated
068        // FUTURE public abstract String getConnectionStringOriginal();
069    
070        /**
071         * @return Returns the dsn.
072         */
073        public abstract String getDsnTranslated(); // FUTURE deprecated
074        // FUTURE public abstract String getConnectionStringTranslated();
075        
076        
077    
078        /**
079         * @return Returns the password.
080         */
081        public abstract String getPassword();
082    
083        /**
084         * @return Returns the username.
085         */
086        public abstract String getUsername();
087    
088        /**
089         * @return Returns the readOnly.
090         */
091        public abstract boolean isReadOnly();
092    
093        /**
094         * @param allow 
095         * @return returns if given allow exists
096         */
097        public abstract boolean hasAllow(int allow);
098    
099        /**
100         * @return Returns the clazz.
101         */
102        public abstract Class getClazz();
103    
104        /**
105         * @return Returns the database.
106         */
107        public abstract String getDatabase();
108    
109        /**
110         * @return Returns the port.
111         */
112        public abstract int getPort();
113    
114        /**
115         * @return Returns the host.
116         */
117        public abstract String getHost();
118    
119        /**
120         * @return cloned Object
121         */
122        public abstract Object clone();
123    
124        /**
125         * @return clone the DataSource as ReadOnly
126         */
127        public abstract DataSource cloneReadOnly();
128    
129        /**
130         * @return Returns the blob.
131         */
132        public abstract boolean isBlob();
133    
134        /**
135         * @return Returns the clob.
136         */
137        public abstract boolean isClob();
138    
139        /**
140         * @return Returns the connectionLimit.
141         */
142        public abstract int getConnectionLimit();
143    
144        /**
145         * @return Returns the connectionTimeout.
146         */
147        public abstract int getConnectionTimeout();
148        
149        public long getMetaCacheTimeout();
150        
151        public TimeZone getTimeZone();
152    
153        /**
154         * @param key 
155         * @return Returns matching custom value or null if not exist.
156         */
157        public abstract String getCustomValue(String key);
158    
159        /**
160         * @return returns all custom names
161         */
162        public abstract String[] getCustomNames();
163    
164        /**
165         * @return returns custom
166         */
167        public abstract Struct getCustoms();
168    
169        /**
170         * @return returns if database has a SQL restriction
171         */
172        public abstract boolean hasSQLRestriction();
173    
174        /**
175         * @return Returns the name.
176         */
177        public abstract String getName();
178    
179        /**
180         * @param clazz The clazz to set.
181         */
182        public abstract void setClazz(Class clazz);
183    
184        public abstract boolean isStorage();
185    
186            public abstract boolean validate();
187    
188            //  public abstract int getMaxConnection();
189    
190    }