001 package com.sptci.rwt;
002
003 import java.util.ArrayList;
004 import java.util.Collection;
005 import java.util.Collections;
006
007 /**
008 * A value object that represents metadata for the database.
009 *
010 * <p>© Copyright 2007 <a href='http://sptci.com/' target='_new'>Sans Pareil Technologies, Inc.</a></p>
011 * @author Rakesh Vidyadharan 2007-09-25
012 * @version $Id: DBMSMetaData.java 4123 2008-05-25 21:49:01Z rakesh $
013 * @see java.sql.DatabaseMetaData
014 */
015 public class DBMSMetaData extends MetaData
016 {
017 /**
018 * An enumeration for the various types of transaction isolation levels
019 * supported by the database.
020 */
021 public enum Transaction { None, ReadCommitted, ReadUncommitted,
022 RepeatableRead, Serialisable };
023
024 /** The product version as reported by the vendor. */
025 private String version;
026
027 /** The default transaction isolation level used by the database. */
028 private Transaction defaultTransaction;
029
030 /** Metadata about the JDBC driver used to access the database */
031 private JDBCMetaData jdbcMetaData;
032
033 /**
034 * Metadata about maximum limitsMetaData enforced by the database.
035 */
036 private LimitsMetaData limitsMetaData;
037
038 /** Collection of catalogues available in the database. */
039 private Collection<CatalogueMetaData> catalogues =
040 new ArrayList<CatalogueMetaData>();
041
042 /** Collection of schemas available in the database. */
043 private Collection<SchemaMetaData> schemas = new ArrayList<SchemaMetaData>();
044
045 /**
046 * Returns {@link #version}.
047 *
048 * @return The value/reference of/to version.
049 */
050 public String getVersion()
051 {
052 return version;
053 }
054
055 /**
056 * Set {@link #version}.
057 *
058 * @param version The value to set.
059 */
060 protected void setVersion( final String version )
061 {
062 this.version = version;
063 }
064
065 /**
066 * Returns {@link #jdbcMetaData}.
067 *
068 * @return The value/reference of/to jdbcMetaData.
069 */
070 public JDBCMetaData getJdbcMetaData()
071 {
072 return jdbcMetaData;
073 }
074
075 /**
076 * Set {@link #jdbcMetaData}.
077 *
078 * @param jdbcMetaData The value to set.
079 */
080 protected void setJdbcMetaData( final JDBCMetaData jdbcMetaData )
081 {
082 this.jdbcMetaData = jdbcMetaData;
083 }
084
085 /**
086 * Returns {@link #defaultTransaction}.
087 *
088 * @return The value/reference of/to defaultTransaction.
089 */
090 public String getDefaultTransaction()
091 {
092 return defaultTransaction.toString();
093 }
094
095 /**
096 * Set {@link #defaultTransaction}.
097 *
098 * @param transaction The value to set.
099 */
100 protected void setDefaultTransaction( final Transaction transaction )
101 {
102 this.defaultTransaction = transaction;
103 }
104
105 /**
106 * Returns {@link #limitsMetaData}.
107 *
108 * @return The value/reference of/to limitsMetaData.
109 */
110 public LimitsMetaData getLimitsMetaData()
111 {
112 return limitsMetaData;
113 }
114
115 /**
116 * Set {@link #limitsMetaData}.
117 *
118 * @param limitsMetaData The value to set.
119 */
120 protected void setLimitsMetaData( final LimitsMetaData limitsMetaData )
121 {
122 this.limitsMetaData = limitsMetaData;
123 }
124
125 /**
126 * Return the catalogue identified by the name specified.
127 *
128 * @param name The name of the catalogue.
129 * @return The meta data object associated with the catalogue.
130 */
131 public CatalogueMetaData getCatalogue( final String name )
132 {
133 CatalogueMetaData cmd = null;
134 if ( name == null ) return cmd;
135
136 for ( CatalogueMetaData md : catalogues )
137 {
138 if ( name.equals( md.getName() ) )
139 {
140 cmd = md;
141 }
142 }
143
144 return cmd;
145 }
146
147 /**
148 * Returns {@link #catalogues}.
149 *
150 * @return The value/reference of/to catalogues.
151 */
152 public Collection<CatalogueMetaData> getCatalogues()
153 {
154 return Collections.unmodifiableCollection( catalogues );
155 }
156
157 /**
158 * Set {@link #catalogues}.
159 *
160 * @param catalogues The value to set.
161 */
162 protected void setCatalogues(
163 final Collection<CatalogueMetaData> catalogues )
164 {
165 this.catalogues.clear();
166 this.catalogues.addAll( catalogues );
167 }
168
169 /**
170 * Returns {@link #schemas}.
171 *
172 * @return The value/reference of/to schemas.
173 */
174 public Collection<SchemaMetaData> getSchemas()
175 {
176 return Collections.unmodifiableCollection( schemas );
177 }
178
179 /**
180 * Set {@link #schemas}.
181 *
182 * @param schemas The value to set.
183 */
184 protected void setSchemas( final Collection<SchemaMetaData> schemas )
185 {
186 this.schemas.clear();
187 this.schemas.addAll( schemas );
188 }
189 }