Source Code Cross Referenced for SYSSCHEMASRowFactory.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » sql » catalog » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database DBMS » db derby 10.2 » org.apache.derby.impl.sql.catalog 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.sql.catalog.SYSSCHEMASRowFactory
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.sql.catalog;
023:
024:        import org.apache.derby.iapi.types.DataTypeDescriptor;
025:        import org.apache.derby.iapi.types.TypeId;
026:        import org.apache.derby.iapi.types.DataValueDescriptor;
027:
028:        import org.apache.derby.iapi.types.TypeId;
029:        import org.apache.derby.iapi.sql.dictionary.SystemColumn;
030:        import org.apache.derby.catalog.TypeDescriptor;
031:
032:        import org.apache.derby.iapi.types.DataValueFactory;
033:        import org.apache.derby.iapi.types.RowLocation;
034:
035:        import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory;
036:        import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator;
037:        import org.apache.derby.iapi.sql.dictionary.DataDictionary;
038:        import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
039:        import org.apache.derby.iapi.sql.dictionary.TupleDescriptor;
040:
041:        import org.apache.derby.iapi.sql.execute.ExecutionFactory;
042:        import org.apache.derby.iapi.sql.execute.ExecIndexRow;
043:        import org.apache.derby.iapi.sql.execute.ExecRow;
044:
045:        import org.apache.derby.iapi.error.StandardException;
046:
047:        import org.apache.derby.iapi.services.monitor.Monitor;
048:        import org.apache.derby.catalog.UUID;
049:        import org.apache.derby.iapi.services.uuid.UUIDFactory;
050:
051:        import org.apache.derby.iapi.services.sanity.SanityManager;
052:
053:        /**
054:         * Factory for creating a SYSSCHEMAS row.
055:         *
056:         *
057:         * @version 0.1
058:         * @author Jamie
059:         */
060:
061:        public class SYSSCHEMASRowFactory extends CatalogRowFactory {
062:            private static final String TABLENAME_STRING = "SYSSCHEMAS";
063:
064:            public static final int SYSSCHEMAS_COLUMN_COUNT = 3;
065:            /* Column #s for sysinfo (1 based) */
066:            public static final int SYSSCHEMAS_SCHEMAID = 1;
067:            public static final int SYSSCHEMAS_SCHEMANAME = 2;
068:            public static final int SYSSCHEMAS_SCHEMAAID = 3;
069:
070:            protected static final int SYSSCHEMAS_INDEX1_ID = 0;
071:            protected static final int SYSSCHEMAS_INDEX2_ID = 1;
072:
073:            private static final int[][] indexColumnPositions = {
074:                    { SYSSCHEMAS_SCHEMANAME }, { SYSSCHEMAS_SCHEMAID } };
075:
076:            private static final boolean[] uniqueness = null;
077:
078:            private static final String[] uuids = {
079:                    "80000022-00d0-fd77-3ed8-000a0a0b1900" // catalog UUID
080:                    , "8000002a-00d0-fd77-3ed8-000a0a0b1900" // heap UUID
081:                    , "80000024-00d0-fd77-3ed8-000a0a0b1900" // SYSSCHEMAS_INDEX1
082:                    , "80000026-00d0-fd77-3ed8-000a0a0b1900" // SYSSCHEMAS_INDEX2
083:            };
084:
085:            /////////////////////////////////////////////////////////////////////////////
086:            //
087:            //	CONSTRUCTORS
088:            //
089:            /////////////////////////////////////////////////////////////////////////////
090:
091:            public SYSSCHEMASRowFactory(UUIDFactory uuidf, ExecutionFactory ef,
092:                    DataValueFactory dvf, boolean convertIdToLower) {
093:                super (uuidf, ef, dvf, convertIdToLower);
094:                initInfo(SYSSCHEMAS_COLUMN_COUNT, TABLENAME_STRING,
095:                        indexColumnPositions, uniqueness, uuids);
096:            }
097:
098:            /////////////////////////////////////////////////////////////////////////////
099:            //
100:            //	METHODS
101:            //
102:            /////////////////////////////////////////////////////////////////////////////
103:
104:            /**
105:             * Make a SYSSCHEMAS row
106:             *
107:             * @return	Row suitable for inserting into SYSSCHEMAS.
108:             *
109:             * @exception   StandardException thrown on failure
110:             */
111:
112:            public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent)
113:                    throws StandardException {
114:                DataTypeDescriptor dtd;
115:                ExecRow row;
116:                DataValueDescriptor col;
117:                String name = null;
118:                UUID oid = null;
119:                String uuid = null;
120:                String aid = null;
121:
122:                if (td != null) {
123:                    SchemaDescriptor schemaDescriptor = (SchemaDescriptor) td;
124:
125:                    name = schemaDescriptor.getSchemaName();
126:                    oid = schemaDescriptor.getUUID();
127:                    if (oid == null) {
128:                        oid = getUUIDFactory().createUUID();
129:                        schemaDescriptor.setUUID(oid);
130:                    }
131:                    uuid = oid.toString();
132:
133:                    aid = schemaDescriptor.getAuthorizationId();
134:                }
135:
136:                /* Build the row to insert */
137:                row = getExecutionFactory()
138:                        .getValueRow(SYSSCHEMAS_COLUMN_COUNT);
139:
140:                /* 1st column is SCHEMAID */
141:                row.setColumn(1, dvf.getCharDataValue(uuid));
142:
143:                /* 2nd column is SCHEMANAME */
144:                row.setColumn(2, dvf.getVarcharDataValue(name));
145:
146:                /* 3rd column is SCHEMAAID */
147:                row.setColumn(3, dvf.getVarcharDataValue(aid));
148:
149:                return row;
150:            }
151:
152:            ///////////////////////////////////////////////////////////////////////////
153:            //
154:            //	ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory
155:            //
156:            ///////////////////////////////////////////////////////////////////////////
157:
158:            /**
159:             * Make an  Tuple Descriptor out of a SYSSCHEMAS row
160:             *
161:             * @param row 					a SYSSCHEMAS row
162:             * @param parentTupleDescriptor	unused
163:             * @param dd 					dataDictionary
164:             *
165:             * @return	a  descriptor equivalent to a SYSSCHEMAS row
166:             *
167:             * @exception   StandardException thrown on failure
168:             */
169:            public TupleDescriptor buildDescriptor(ExecRow row,
170:                    TupleDescriptor parentTupleDescriptor, DataDictionary dd)
171:                    throws StandardException {
172:                DataValueDescriptor col;
173:                SchemaDescriptor descriptor;
174:                String name;
175:                UUID id;
176:                String aid;
177:                String uuid;
178:                DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
179:
180:                if (SanityManager.DEBUG) {
181:                    SanityManager.ASSERT(
182:                            row.nColumns() == SYSSCHEMAS_COLUMN_COUNT,
183:                            "Wrong number of columns for a SYSSCHEMAS row");
184:                }
185:
186:                // first column is schemaid (UUID - char(36))
187:                col = row.getColumn(1);
188:                uuid = col.getString();
189:                id = getUUIDFactory().recreateUUID(uuid);
190:
191:                // second column is schemaname (varchar(128))
192:                col = row.getColumn(2);
193:                name = col.getString();
194:
195:                // third column is auid (varchar(128))
196:                col = row.getColumn(3);
197:                aid = col.getString();
198:
199:                descriptor = ddg.newSchemaDescriptor(name, aid, id);
200:
201:                return descriptor;
202:            }
203:
204:            /**
205:             * Builds a list of columns suitable for creating this Catalog.
206:             *
207:             *
208:             * @return array of SystemColumn suitable for making this catalog.
209:             */
210:            public SystemColumn[] buildColumnList() {
211:                int index = 0;
212:                SystemColumn[] columnList = new SystemColumn[SYSSCHEMAS_COLUMN_COUNT];
213:
214:                // describe columns
215:
216:                columnList[index++] = new SystemColumnImpl(
217:                        convertIdCase("SCHEMAID"), // name 
218:                        SYSSCHEMAS_SCHEMAID, // column number
219:                        0, // precision
220:                        0, // scale
221:                        false, // nullability
222:                        "CHAR", // dataType
223:                        true, // built-in type
224:                        36 // maxLength
225:                );
226:                columnList[index++] = new SystemColumnImpl( // SQL IDENTIFIER
227:                        convertIdCase("SCHEMANAME"), // column name
228:                        SYSSCHEMAS_SCHEMANAME, // column number
229:                        false // nullability
230:                );
231:
232:                columnList[index++] = new SystemColumnImpl( // SQL IDENTIFIER
233:                        convertIdCase("AUTHORIZATIONID"), // column name
234:                        SYSSCHEMAS_SCHEMAAID, // column number
235:                        false // nullability
236:                );
237:
238:                return columnList;
239:            }
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.