Source Code Cross Referenced for IndexReporter.java in  » Database-Client » SQL-Workbench » workbench » db » report » 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 Client » SQL Workbench » workbench.db.report 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * IndexReporter.java
003:         *
004:         * This file is part of SQL Workbench/J, http://www.sql-workbench.net
005:         *
006:         * Copyright 2002-2008, Thomas Kellerer
007:         * No part of this code maybe reused without the permission of the author
008:         *
009:         * To contact the author please send an email to: support@sql-workbench.net
010:         *
011:         */
012:        package workbench.db.report;
013:
014:        import java.util.ArrayList;
015:        import java.util.Collection;
016:        import java.util.LinkedList;
017:        import java.util.List;
018:        import workbench.db.IndexColumn;
019:        import workbench.db.IndexDefinition;
020:        import workbench.db.TableIdentifier;
021:        import workbench.db.WbConnection;
022:        import workbench.util.StrBuffer;
023:
024:        /**
025:         * Class to retrieve all index definitions for a table and
026:         * generate an XML string from that.
027:         *
028:         * @author  support@sql-workbench.net
029:         */
030:        public class IndexReporter {
031:            public static final String TAG_INDEX = "index-def";
032:
033:            public static final String TAG_INDEX_NAME = "name";
034:            public static final String TAG_INDEX_UNIQUE = "unique";
035:            public static final String TAG_INDEX_PK = "primary-key";
036:            public static final String TAG_INDEX_TYPE = "type";
037:            public static final String TAG_INDEX_EXPR = "index-expression";
038:            public static final String TAG_INDEX_COLUMN_LIST = "column-list";
039:            public static final String TAG_INDEX_COLUMN_NAME = "column";
040:
041:            private Collection<IndexDefinition> indexList;
042:            private TagWriter tagWriter = new TagWriter();
043:
044:            public IndexReporter(TableIdentifier tbl, WbConnection conn) {
045:                indexList = conn.getMetadata().getTableIndexList(tbl);
046:            }
047:
048:            public IndexReporter(IndexDefinition index) {
049:                indexList = new LinkedList<IndexDefinition>();
050:                indexList.add(index);
051:            }
052:
053:            public void appendXml(StrBuffer result, StrBuffer indent) {
054:                int numIndex = this .indexList.size();
055:                if (numIndex == 0)
056:                    return;
057:                StrBuffer defIndent = new StrBuffer(indent);
058:                defIndent.append("  ");
059:
060:                for (IndexDefinition index : indexList) {
061:                    if (index == null)
062:                        continue;
063:                    tagWriter.appendOpenTag(result, indent, TAG_INDEX);
064:                    result.append('\n');
065:                    tagWriter.appendTag(result, defIndent, TAG_INDEX_NAME,
066:                            index.getName());
067:                    tagWriter.appendTag(result, defIndent, TAG_INDEX_EXPR,
068:                            index.getExpression());
069:                    tagWriter.appendTag(result, defIndent, TAG_INDEX_UNIQUE,
070:                            index.isUnique());
071:                    tagWriter.appendTag(result, defIndent, TAG_INDEX_PK, index
072:                            .isPrimaryKeyIndex());
073:                    tagWriter.appendTag(result, defIndent, TAG_INDEX_TYPE,
074:                            index.getIndexType());
075:                    List<IndexColumn> columns = index.getColumns();
076:                    if (columns.size() > 0) {
077:                        StrBuffer colIndent = new StrBuffer(defIndent);
078:                        colIndent.append("  ");
079:                        tagWriter.appendOpenTag(result, defIndent,
080:                                TAG_INDEX_COLUMN_LIST);
081:                        result.append('\n');
082:                        for (IndexColumn col : columns) {
083:
084:                            List<TagAttribute> attrs = new ArrayList<TagAttribute>(
085:                                    2);
086:                            attrs
087:                                    .add(new TagAttribute("name", col
088:                                            .getColumn()));
089:
090:                            if (col.getDirection() != null) {
091:                                attrs.add(new TagAttribute("direction", col
092:                                        .getDirection()));
093:                            }
094:                            tagWriter.appendOpenTag(result, colIndent,
095:                                    TAG_INDEX_COLUMN_NAME, attrs, false);
096:                            result.append("/>\n");
097:                        }
098:                        tagWriter.appendCloseTag(result, defIndent,
099:                                TAG_INDEX_COLUMN_LIST);
100:                    }
101:                    tagWriter.appendCloseTag(result, indent, TAG_INDEX);
102:                }
103:                return;
104:            }
105:
106:            public void setNamespace(String name) {
107:                this .tagWriter.setNamespace(name);
108:            }
109:
110:            public Collection<IndexDefinition> getIndexList() {
111:                return this .indexList;
112:            }
113:
114:            public void done() {
115:            }
116:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.