Source Code Cross Referenced for QueryStatEntry.java in  » Database-Client » SQL-Profiler » org » jahia » sqlprofiler » 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 Profiler » org.jahia.sqlprofiler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) Jahia Ltd. All rights reserved.
003:         *
004:         * This software is published under the terms of the Jahia Open Software
005:         * License version 1.1, a copy of which has been included with this
006:         * distribution in the LICENSE.txt file.
007:         */
008:        package org.jahia.sqlprofiler;
009:
010:        import java.util.*;
011:
012:        /**
013:         * <p>Title: Stores the result of a parsed SQL Select statement, storing the
014:         * table and columns names associated with the query.</p>
015:         * <p>Description: </p>
016:         * <p>Copyright: Copyright (c) 2003</p>
017:         * <p>Company: Jahia Ltd</p>
018:         * @author Serge Huber
019:         * @version 1.0
020:         */
021:
022:        public class QueryStatEntry implements  Comparable {
023:            private ArrayList tableNames = new ArrayList();
024:            private ArrayList columnNames = new ArrayList();
025:            private Set queries = new TreeSet();
026:            private int occurences = 0;
027:            private long totalElapsedTime = 0;
028:
029:            public QueryStatEntry() {
030:            }
031:
032:            public QueryStatEntry(ArrayList tableNames, ArrayList columnNames) {
033:                // we copy here to make sure we have only one value for each table and
034:                // column name, which is not guaranteed since we are using ArrayList
035:                // to preserve order of the detected identifiers.
036:                Iterator tableNameIter = tableNames.iterator();
037:                while (tableNameIter.hasNext()) {
038:                    String curTableName = (String) tableNameIter.next();
039:                    if (!this .tableNames.contains(curTableName)) {
040:                        this .tableNames.add(curTableName);
041:                    }
042:                }
043:                Iterator columnNameIter = columnNames.iterator();
044:                while (columnNameIter.hasNext()) {
045:                    String curColumnName = (String) columnNameIter.next();
046:                    if (!this .columnNames.contains(curColumnName)) {
047:                        this .columnNames.add(curColumnName);
048:                    }
049:                }
050:            }
051:
052:            public java.util.ArrayList getTableNames() {
053:                return tableNames;
054:            }
055:
056:            public java.util.ArrayList getColumnNames() {
057:                return columnNames;
058:            }
059:
060:            public int getOccurences() {
061:                return occurences;
062:            }
063:
064:            public long getTotalElapsedTime() {
065:                return totalElapsedTime;
066:            }
067:
068:            public void incOccurences() {
069:                occurences++;
070:            }
071:
072:            public void incTotalElapseTime(long elapsedTime) {
073:                totalElapsedTime += elapsedTime;
074:            }
075:
076:            public void addQuery(QueryEntry query) {
077:                queries.add(query);
078:            }
079:
080:            public Set getQueries() {
081:                return queries;
082:            }
083:
084:            public String getKey() {
085:                String hashCodeStr = tableNames.toString() + "_"
086:                        + columnNames.toString();
087:                return hashCodeStr;
088:            }
089:
090:            public int hashCode() {
091:                return getKey().hashCode();
092:            }
093:
094:            public boolean equals(Object o) {
095:                if (o instanceof  QueryStatEntry) {
096:                    QueryStatEntry right = (QueryStatEntry) o;
097:                    return getKey().equals(right.getKey());
098:                } else {
099:                    return false;
100:                }
101:            }
102:
103:            public int compareTo(Object o) throws ClassCastException {
104:                QueryStatEntry right = (QueryStatEntry) o;
105:
106:                // first let's compare total time.
107:                Long leftElapsedTime = new Long(getTotalElapsedTime());
108:                Long rightElapsedTime = new Long(right.getTotalElapsedTime());
109:                int compareElapsed = -leftElapsedTime
110:                        .compareTo(rightElapsedTime);
111:                if (compareElapsed != 0) {
112:                    return compareElapsed;
113:                }
114:
115:                Integer left = new Integer(occurences);
116:                return -left.compareTo(new Integer(right.getOccurences()));
117:            }
118:
119:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.