View Javadoc

1   /*
2    * ModeShape (http://www.modeshape.org)
3    * See the COPYRIGHT.txt file distributed with this work for information
4    * regarding copyright ownership.  Some portions may be licensed
5    * to Red Hat, Inc. under one or more contributor license agreements.
6    * See the AUTHORS.txt file in the distribution for a full listing of 
7    * individual contributors. 
8    *
9    * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10   * is licensed to you under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation; either version 2.1 of
12   * the License, or (at your option) any later version.
13   *
14   * ModeShape is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this software; if not, write to the Free
21   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23   */
24  package org.modeshape.connector.meta.jdbc;
25  
26  import java.sql.DatabaseMetaData;
27  import net.jcip.annotations.Immutable;
28  
29  /**
30   * Container for table-level metadata. The fields in this class roughly parallel the information returned from the
31   * {@link DatabaseMetaData#getTables(String, String, String, String[])} method.
32   */
33  @Immutable
34  public class TableMetadata {
35  
36      private final String name;
37      private final String type;
38      private final String description;
39      private final String typeCatalogName;
40      private final String typeSchemaName;
41      private final String typeName;
42      private final String selfReferencingColumnName;
43      private final String referenceGenerationStrategyName;
44  
45      public TableMetadata( String name,
46                            String type,
47                            String description,
48                            String typeCatalogName,
49                            String typeSchemaName,
50                            String typeName,
51                            String selfReferencingColumnName,
52                            String referenceGenerationStrategyName ) {
53          super();
54          this.name = name;
55          this.type = type;
56          this.description = description;
57          this.typeCatalogName = typeCatalogName;
58          this.typeSchemaName = typeSchemaName;
59          this.typeName = typeName;
60          this.selfReferencingColumnName = selfReferencingColumnName;
61          this.referenceGenerationStrategyName = referenceGenerationStrategyName;
62      }
63  
64      /**
65       * @return the table name (TABLE_NAME in the {@link DatabaseMetaData#getTables(String, String, String, String[])} result set).
66       */
67      public String getName() {
68          return name;
69      }
70  
71      /**
72       * @return the table type (TABLE_TYPE in the {@link DatabaseMetaData#getTables(String, String, String, String[])} result set).
73       */
74      public String getType() {
75          return type;
76      }
77  
78      /**
79       * @return the table description (REMARKS in the {@link DatabaseMetaData#getTables(String, String, String, String[])} result
80       *         set).
81       */
82      public String getDescription() {
83          return description;
84      }
85  
86      /**
87       * @return the table types catalog name (TYPE_CAT in the {@link DatabaseMetaData#getTables(String, String, String, String[])}
88       *         result set).
89       */
90      public String getTypeCatalogName() {
91          return typeCatalogName;
92      }
93  
94      /**
95       * @return the table types schema name (TYPE_SCHEM in the {@link DatabaseMetaData#getTables(String, String, String, String[])}
96       *         result set).
97       */
98      public String getTypeSchemaName() {
99          return typeSchemaName;
100     }
101 
102     /**
103      * @return the table type name (TYPE_NAME in the {@link DatabaseMetaData#getTables(String, String, String, String[])} result
104      *         set).
105      */
106     public String getTypeName() {
107         return typeName;
108     }
109 
110     /**
111      * @return per the Javadoc for the DatabaseMetaData method, "the name of the designated 'identifier' column of a typed table"
112      *         (SELF_REFERENCING_COL_NAME in the {@link DatabaseMetaData#getTables(String, String, String, String[])} result set).
113      */
114     public String getSelfReferencingColumnName() {
115         return selfReferencingColumnName;
116     }
117 
118     /**
119      * @return the strategy for creating the values in the self-referencing column (REF_GENERATION in the
120      *         {@link DatabaseMetaData#getTables(String, String, String, String[])} result set).
121      */
122     public String getReferenceGenerationStrategyName() {
123         return referenceGenerationStrategyName;
124     }
125 
126 }