Source Code Cross Referenced for InformationHelper.java in  » Database-Client » dbmjui » fr » aliacom » dbmjui » components » information » 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 » dbmjui » fr.aliacom.dbmjui.components.information 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Mar 2, 2003
003:         *
004:         * Dbmjui is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU General Public License version 2 as
006:         * published by the Free Software Foundation.
007:         *  
008:         * Dbmjui is distributed in the hope that it will be useful,
009:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
010:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
011:         * Library General Public License for more details.
012:         *  
013:         * You should have received a copy of the GNU General Public
014:         * License along with dbmjui; see the file COPYING.  If not,
015:         * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
016:         * Boston, MA 02111-1307, USA.
017:         *
018:         */
019:        package fr.aliacom.dbmjui.components.information;
020:
021:        import java.util.ArrayList;
022:
023:        import com.sap.dbtech.powertoys.DBM;
024:
025:        import fr.aliacom.dbmjui.*;
026:        import fr.aliacom.dbmjui.beans.CacheInfoEntry;
027:        import fr.aliacom.dbmjui.beans.DataInfoEntry;
028:        import fr.aliacom.dbmjui.beans.IOInfoEntry;
029:        import fr.aliacom.dbmjui.beans.LockInfoEntry;
030:        import fr.aliacom.dbmjui.beans.LogInfoEntry;
031:        import fr.aliacom.dbmjui.beans.SessionInfoEntry;
032:        import fr.aliacom.dbmjui.beans.VersionInfoEntry;
033:        import fr.aliacom.dbmjui.driver.*;
034:        import fr.aliacom.util.StringFunctions;
035:
036:        /**
037:         * Some utility functions to parse the output
038:         * from the dbm info commands.
039:         * 
040:         * Those functions turns the string output into ArrayList of
041:         * JavaBeans.
042:         * 
043:         * 
044:         * @author tom
045:         *
046:         * (c) 2001, 2003 Thomas Cataldo
047:         */
048:        public class InformationHelper implements  IInformationHelper {
049:
050:            public InformationHelper() {
051:            }
052:
053:            /* (non-Javadoc)
054:             * @see fr.aliacom.dbmjui.IInformationHelper#getIOInfo(fr.aliacom.dbmjui.DbInstance)
055:             */
056:            public ArrayList getIOInfo(DbInstance dbi) {
057:                return parseIOInfo(executeInfoCommand(dbi, "io", false));
058:            }
059:
060:            public ArrayList getCachesInfo(DbInstance dbi) {
061:                return parseCachesInfo(executeInfoCommand(dbi, "caches", false));
062:            }
063:
064:            public ArrayList getDataInfo(DbInstance dbi) {
065:                return parseDataInfo(executeInfoCommand(dbi, "data", false));
066:            }
067:
068:            public ArrayList getLocksInfo(DbInstance dbi) {
069:                return parseLocksInfo(executeInfoCommand(dbi, "locks", false));
070:            }
071:
072:            public ArrayList getLogsInfo(DbInstance dbi) {
073:                return parseLogsInfo(executeInfoCommand(dbi, "log", false));
074:            }
075:
076:            public ArrayList getSessionsInfo(DbInstance dbi) {
077:                return parseSessionsInfo(executeInfoCommand(dbi, "users", false));
078:            }
079:
080:            public ArrayList getVersionsInfo(DbInstance dbi) {
081:                return parseVersionsInfo(executeInfoCommand(dbi, "versions",
082:                        false));
083:            }
084:
085:            private String executeInfoCommand(DbInstance dbi, String info,
086:                    boolean needSql) {
087:                String ret = "";
088:                try {
089:                    DBM dbm = dbi.getDbmConnection();
090:                    if (needSql) {
091:                        dbm.cmd("sql_connect");
092:                    }
093:                    ret = dbm.cmd("info " + info);
094:                    dbm.release();
095:                } catch (Exception e) {
096:                    e.printStackTrace();
097:                }
098:                return ret;
099:            }
100:
101:            /**
102:             * Parses the "info caches" output and turns it CacheInfoEntry beans.
103:             * 
104:             * @param info the output of "info caches" command 
105:             * @return an ArrayList of <code>CacheInfoEntry</code> beans.
106:             */
107:            protected ArrayList parseCachesInfo(String info) {
108:                ArrayList untyped = getInfoAsStrings(info, "\\|");
109:                ArrayList ret = new ArrayList(untyped.size());
110:                for (int i = 0, n = untyped.size(); i < n; i++) {
111:                    String[] line = (String[]) untyped.get(i);
112:                    ret.add(new CacheInfoEntry(line[0], line[1], line[2],
113:                            line[3], line[4]));
114:                }
115:
116:                return ret;
117:            }
118:
119:            /**
120:             * Parses the "info data" output and turns it DataInfoEntry beans.
121:             * 
122:             * @param info the output of "info data" command 
123:             * @return an ArrayList of <code>DataInfoEntry</code> beans.
124:             */
125:            protected ArrayList parseDataInfo(String info) {
126:                ArrayList untyped = getInfoAsStrings(info, "=");
127:                ArrayList ret = new ArrayList(untyped.size());
128:                for (int i = 0, n = untyped.size(); i < n; i++) {
129:                    String[] line = (String[]) untyped.get(i);
130:                    ret.add(new DataInfoEntry(line[0], line[1]));
131:                }
132:
133:                return ret;
134:            }
135:
136:            /**
137:             * Parses the "info io" output and turns it IOInfoEntry beans.
138:             * 
139:             * @param info the output of "info io" command 
140:             * @return an ArrayList of <code>IOInfoEntry</code> beans.
141:             */
142:            protected ArrayList parseIOInfo(String info) {
143:                ArrayList untyped = getInfoAsStrings(info, "\\|");
144:                ArrayList ret = new ArrayList(untyped.size());
145:                for (int i = 0, n = untyped.size(); i < n; i++) {
146:                    String[] line = (String[]) untyped.get(i);
147:                    ret.add(new IOInfoEntry(line[0], line[1], line[2], line[3],
148:                            line[4]));
149:                }
150:
151:                return ret;
152:            }
153:
154:            /**
155:             * Parses the "info log" output and turns it LogInfoEntry beans.
156:             * 
157:             * @param info the output of "info log" command 
158:             * @return an ArrayList of <code>LogInfoEntry</code> beans.
159:             */
160:            protected ArrayList parseLogsInfo(String info) {
161:                ArrayList untyped = getInfoAsStrings(info, "=");
162:                ArrayList ret = new ArrayList(untyped.size());
163:                for (int i = 0, n = untyped.size(); i < n; i++) {
164:                    String[] line = (String[]) untyped.get(i);
165:                    ret.add(new LogInfoEntry(line[0], line[1]));
166:                }
167:
168:                return ret;
169:            }
170:
171:            /**
172:             * Parses the "info locks" output and turns it LockInfoEntry beans.
173:             * 
174:             * @param info the output of "info locks" command 
175:             * @return an ArrayList of <code>LockInfoEntry</code> beans.
176:             */
177:            protected ArrayList parseLocksInfo(String info) {
178:                ArrayList untyped = getInfoAsStrings(info, "=");
179:                ArrayList ret = new ArrayList(untyped.size());
180:                for (int i = 0, n = untyped.size(); i < n; i++) {
181:                    String[] line = (String[]) untyped.get(i);
182:                    ret.add(new LockInfoEntry(line[0], line[1]));
183:                }
184:
185:                return ret;
186:            }
187:
188:            /**
189:             * Parses the "info version" output and turns it VersionInfoEntry beans.
190:             * 
191:             * @param info the output of "info caches" command 
192:             * @return an ArrayList of <code>VersionInfoEntry</code> beans.
193:             */
194:            protected ArrayList parseVersionsInfo(String info) {
195:                ArrayList untyped = getInfoAsStrings(info, "=");
196:                ArrayList ret = new ArrayList(untyped.size());
197:                for (int i = 0, n = untyped.size(); i < n; i++) {
198:                    String[] line = (String[]) untyped.get(i);
199:                    ret.add(new VersionInfoEntry(line[0], line[1]));
200:                }
201:
202:                return ret;
203:            }
204:
205:            /**
206:             * Parses the "info caches" output and turns it CacheInfoEntry beans.
207:             * 
208:             * @param info the output of "info caches" command 
209:             * @return an ArrayList of <code>CacheInfoEntry</code> beans.
210:             */
211:            protected ArrayList parseSessionsInfo(String info) {
212:                ArrayList untyped = getInfoAsStrings(info, "\\|");
213:                ArrayList ret = new ArrayList(untyped.size());
214:                for (int i = 0, n = untyped.size(); i < n; i++) {
215:                    String[] line = (String[]) untyped.get(i);
216:                    ret.add(new SessionInfoEntry(line[0], line[1], line[2],
217:                            line[3], line[4], line[5]));
218:                }
219:
220:                return ret;
221:            }
222:
223:            /**
224:             * Parses the output of any of the info command,
225:             * and turns it into an ArrayList of String arrays.
226:             * Each the string array element is a field for the info
227:             * command. Whitespaces at the end are trimmed.
228:             * 
229:             * @param info
230:             * @param separatorChar the separator used between the info fields
231:             * @return an ArrayList&lt;String[]&gt;
232:             */
233:            protected ArrayList getInfoAsStrings(String info,
234:                    String separatorChar) {
235:                String[] lines = info.split("\n");
236:                ArrayList data = new ArrayList(lines.length);
237:                for (int i = 3; i < lines.length; i++) {
238:                    String[] line = lines[i].split(separatorChar);
239:                    for (int j = 0; j < line.length; j++) {
240:                        line[j] = StringFunctions.rtrim(line[j]);
241:                    }
242:                    data.add(line);
243:                }
244:                return data;
245:
246:            }
247:
248:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.