Source Code Cross Referenced for Index.java in  » Database-ORM » Torque » org » apache » torque » engine » database » model » 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 ORM » Torque » org.apache.torque.engine.database.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.torque.engine.database.model;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with 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,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import java.util.ArrayList;
023:        import java.util.Collections;
024:        import java.util.Iterator;
025:        import java.util.List;
026:        import java.util.Map;
027:
028:        import org.apache.commons.collections.map.ListOrderedMap;
029:        import org.apache.commons.logging.Log;
030:        import org.apache.commons.logging.LogFactory;
031:
032:        import org.apache.torque.engine.EngineException;
033:
034:        import org.xml.sax.Attributes;
035:
036:        /**
037:         * Information about indices of a table.
038:         *
039:         * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
040:         * @author <a href="mailto:dlr@finemaltcoding.com>Daniel Rall</a>
041:         * @author <a href="mailto:monroe@dukece.com>Greg Monroe</a>
042:         * @version $Id: Index.java 473814 2006-11-11 22:30:30Z tv $
043:         */
044:        public class Index {
045:            /** Logging class from commons.logging */
046:            private static Log log = LogFactory.getLog(Index.class);
047:            /** name of the index */
048:            private String indexName;
049:            /** table */
050:            private Table parentTable;
051:            /** columns */
052:            private List indexColumns;
053:            /** The XML Options specified for this index */
054:            private Map options;
055:
056:            /**
057:             * Creates a new instance with default characteristics (no name or
058:             * parent table, small column list size allocation, non-unique).
059:             */
060:            public Index() {
061:                indexColumns = new ArrayList(3);
062:                options = Collections.synchronizedMap(new ListOrderedMap());
063:            }
064:
065:            /**
066:             * Creates a new instance for the list of columns composing an
067:             * index.  Otherwise performs as {@link #Index()}.
068:             *
069:             * @param table The table this index is associated with.
070:             * @param indexColumns The list of {@link
071:             * org.apache.torque.engine.database.model.Column} objects which
072:             * make up this index.  Cannot be empty.
073:             * @exception EngineException Error generating name.
074:             * @see #Index()
075:             */
076:            protected Index(Table table, List indexColumns)
077:                    throws EngineException {
078:                this ();
079:                setTable(table);
080:                if (!indexColumns.isEmpty()) {
081:                    this .indexColumns = indexColumns;
082:
083:                    if (log.isDebugEnabled()) {
084:                        log.debug("Created Index named " + getName() + " with "
085:                                + indexColumns.size() + " columns");
086:                    }
087:                } else {
088:                    throw new EngineException(
089:                            "Cannot create a new Index using an "
090:                                    + "empty list Column object");
091:                }
092:            }
093:
094:            /**
095:             * Imports index from an XML specification
096:             *
097:             * @param attrib the xml attributes
098:             */
099:            public void loadFromXML(Attributes attrib) {
100:                indexName = attrib.getValue("name");
101:            }
102:
103:            /**
104:             * Returns the uniqueness of this index.
105:             *
106:             * @return the uniqueness of this index
107:             */
108:            public boolean isUnique() {
109:                return false;
110:            }
111:
112:            /**
113:             * Gets the name of this index.
114:             *
115:             * @return the name of this index
116:             */
117:            public String getName() {
118:                return indexName;
119:            }
120:
121:            /**
122:             * Set the name of this index.
123:             *
124:             * @param name the name of this index
125:             */
126:            public void setName(String name) {
127:                this .indexName = name;
128:            }
129:
130:            /**
131:             * Set the parent Table of the index
132:             *
133:             * @param parent the table
134:             */
135:            public void setTable(Table parent) {
136:                parentTable = parent;
137:            }
138:
139:            /**
140:             * Get the parent Table of the index
141:             *
142:             * @return the table
143:             */
144:            public Table getTable() {
145:                return parentTable;
146:            }
147:
148:            /**
149:             * Returns the Name of the table the index is in
150:             *
151:             * @return the name of the table
152:             */
153:            public String getTableName() {
154:                return parentTable.getName();
155:            }
156:
157:            /**
158:             * Adds a new column to an index.
159:             *
160:             * @param attrib xml attributes for the column
161:             */
162:            public void addColumn(Attributes attrib) {
163:                indexColumns.add(attrib.getValue("name"));
164:            }
165:
166:            /**
167:             * Return a comma delimited string of the columns which compose this index.
168:             *
169:             * @return a list of column names
170:             */
171:            public String getColumnList() {
172:                return Column.makeList(getColumns());
173:            }
174:
175:            /**
176:             * Return the list of local columns. You should not edit this list.
177:             *
178:             * @return a list of columns
179:             */
180:            public List getColumns() {
181:                return indexColumns;
182:            }
183:
184:            /**
185:             * Returns the list of names of the columns referenced by this
186:             * index.  Slightly over-allocates the list's buffer (just in case
187:             * more elements are going to be added, such as when a name is
188:             * being generated).  Feel free to modify this list.
189:             *
190:             * @return a list of column names
191:             */
192:            protected List getColumnNames() {
193:                List names = new ArrayList(indexColumns.size() + 2);
194:                Iterator i = getColumns().iterator();
195:                while (i.hasNext()) {
196:                    Column c = (Column) i.next();
197:                    names.add(c.getName());
198:                }
199:                return names;
200:            }
201:
202:            /**
203:             * String representation of the index. This is an xml representation.
204:             *
205:             * @return a xml representation
206:             */
207:            public String toString() {
208:                StringBuffer result = new StringBuffer();
209:                result.append(" <index name=\"").append(getName()).append("\"");
210:
211:                result.append(">\n");
212:
213:                for (int i = 0; i < indexColumns.size(); i++) {
214:                    result.append("  <index-column name=\"").append(
215:                            indexColumns.get(i)).append("\"/>\n");
216:                }
217:                result.append(" </index>\n");
218:                return result.toString();
219:            }
220:
221:            /**
222:             * Add an XML Specified option key/value pair to this element's option set.
223:             *
224:             * @param key the key of the option.
225:             * @param value the value of the option.
226:             */
227:            public void addOption(String key, String value) {
228:                options.put(key, value);
229:            }
230:
231:            /**
232:             * Get the value that was associated with this key in an XML option
233:             * element.
234:             *
235:             * @param key the key of the option.
236:             * @return The value for the key or a null.
237:             */
238:            public String getOption(String key) {
239:                return (String) options.get(key);
240:            }
241:
242:            /**
243:             * Gets the full ordered hashtable array of items specified by XML option
244:             * statements under this element.<p>
245:             *
246:             * Note, this is not thread save but since it's only used for
247:             * generation which is single threaded, there should be minimum
248:             * danger using this in Velocity.
249:             *
250:             * @return An Map of all options. Will not be null but may be empty.
251:             */
252:            public Map getOptions() {
253:                return options;
254:            }
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.