Source Code Cross Referenced for CVSReportMaker.java in  » Groupware » LibreSource » org » libresource » so6 » core » 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 » Groupware » LibreSource » org.libresource.so6.core.report 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * LibreSource
003:         * Copyright (C) 2004-2008 Artenum SARL / INRIA
004:         * http://www.libresource.org - contact@artenum.com
005:         *
006:         * This file is part of the LibreSource software, 
007:         * which can be used and distributed under license conditions.
008:         * The license conditions are provided in the LICENSE.TXT file 
009:         * at the root path of the packaging that enclose this file. 
010:         * More information can be found at 
011:         * - http://dev.libresource.org/home/license
012:         *
013:         * Initial authors :
014:         *
015:         * Guillaume Bort / INRIA
016:         * Francois Charoy / Universite Nancy 2
017:         * Julien Forest / Artenum
018:         * Claude Godart / Universite Henry Poincare
019:         * Florent Jouille / INRIA
020:         * Sebastien Jourdain / INRIA / Artenum
021:         * Yves Lerumeur / Artenum
022:         * Pascal Molli / Universite Henry Poincare
023:         * Gerald Oster / INRIA
024:         * Mariarosa Penzi / Artenum
025:         * Gerard Sookahet / Artenum
026:         * Raphael Tani / INRIA
027:         *
028:         * Contributors :
029:         *
030:         * Stephane Bagnier / Artenum
031:         * Amadou Dia / Artenum-IUP Blois
032:         * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033:         */package org.libresource.so6.core.report;
034:
035:        import org.libresource.so6.core.command.Command;
036:        import org.libresource.so6.core.command.Macro;
037:        import org.libresource.so6.core.command.UpdateFile;
038:        import org.libresource.so6.core.command.fs.AddDir;
039:        import org.libresource.so6.core.command.fs.AddFile;
040:        import org.libresource.so6.core.command.fs.Remove;
041:        import org.libresource.so6.core.command.fs.Rename;
042:        import org.libresource.so6.core.command.fs.UpdateBinaryFile;
043:        import org.libresource.so6.core.engine.OpVectorFsImpl;
044:
045:        import java.io.IOException;
046:        import java.io.OutputStream;
047:        import java.io.OutputStreamWriter;
048:
049:        import java.util.ArrayList;
050:        import java.util.Enumeration;
051:        import java.util.Hashtable;
052:        import java.util.ListIterator;
053:
054:        /**
055:         * @author smack
056:         */
057:        public class CVSReportMaker {
058:            //
059:            private OpVectorFsImpl opVector;
060:            private Hashtable indexTable;
061:            private long from;
062:            private long to;
063:
064:            public CVSReportMaker(String opVerctorFsImplBasePath) {
065:                opVector = new OpVectorFsImpl(opVerctorFsImplBasePath);
066:                opVector.load();
067:                from = opVector.getFromTicket();
068:                to = opVector.getToTicket();
069:                indexTable = new Hashtable();
070:            }
071:
072:            public void buildIndexTable() throws Exception {
073:                Command cmd = null;
074:                ListIterator iterator = opVector.getCommands();
075:
076:                while ((cmd = (Command) iterator.next()) != null) {
077:                    String path = cmd.getPath();
078:                    FileMetaData metaData = (FileMetaData) indexTable.get(path);
079:
080:                    if (metaData == null) {
081:                        metaData = new FileMetaData(path);
082:                    }
083:
084:                    metaData.applyCmd(cmd);
085:                    indexTable.put(path, metaData);
086:                }
087:            }
088:
089:            public void writeReport(OutputStream out) throws IOException {
090:                if (from == 0) {
091:                    return;
092:                }
093:
094:                OutputStreamWriter ostw = new OutputStreamWriter(out);
095:                ostw.write("---\n");
096:
097:                for (Enumeration e = indexTable.keys(); e.hasMoreElements();) {
098:                    String path = (String) e.nextElement();
099:                    FileMetaData data = (FileMetaData) indexTable.get(path);
100:
101:                    // print
102:                    ostw.write(data.toString() + "\n");
103:                }
104:
105:                ostw.write("---\n");
106:                ostw.flush();
107:            }
108:
109:            public String getReport() throws IOException {
110:                if (from == 0) {
111:                    return "";
112:                }
113:
114:                StringBuffer buffer = new StringBuffer();
115:                buffer.append("---\n");
116:
117:                for (Enumeration e = indexTable.keys(); e.hasMoreElements();) {
118:                    String path = (String) e.nextElement();
119:                    FileMetaData data = (FileMetaData) indexTable.get(path);
120:
121:                    // print
122:                    buffer.append(data.toString() + "\n");
123:                }
124:
125:                buffer.append("---\n");
126:
127:                return buffer.toString();
128:            }
129:
130:            public long getFromTicket() {
131:                return from;
132:            }
133:
134:            public long getToTicket() {
135:                return to;
136:            }
137:
138:            public class FileMetaData {
139:                private final static String CREATE = "A";
140:                private final static String MOVE = "Moved";
141:                private final static String DELETE = "R";
142:                private final static String UPDATE = "U";
143:                private final static String CONFLICT = "C";
144:                private final static String CHANGE_TYPE = "Type changed";
145:
146:                //
147:                private boolean conflict = false;
148:                private String path;
149:                private ArrayList cmds;
150:
151:                FileMetaData(String path) {
152:                    this .path = path;
153:                    cmds = new ArrayList();
154:                }
155:
156:                public void applyCmd(Command cmd) {
157:                    if (cmd instanceof  Macro) {
158:                        this .applyCmd(((Macro) cmd).getCommand(1));
159:                        this .applyCmd(((Macro) cmd).getCommand(2));
160:                    } else {
161:                        if (cmd.isConflict()) {
162:                            conflict = true;
163:                        }
164:
165:                        if (cmd instanceof  UpdateFile
166:                                || cmd instanceof  UpdateBinaryFile) {
167:                            cmds.add(UPDATE);
168:                        }
169:
170:                        if (cmd instanceof  Remove) {
171:                            cmds.add(DELETE);
172:                        }
173:
174:                        if (cmd instanceof  AddFile) {
175:                            cmds.add(CREATE);
176:                        }
177:
178:                        if (cmd instanceof  AddDir) {
179:                            cmds.add(CREATE);
180:                        }
181:
182:                        if (cmd instanceof  Rename) {
183:                            cmds.add(MOVE);
184:                        }
185:                    }
186:                }
187:
188:                public ArrayList getCmdsList() {
189:                    return cmds;
190:                }
191:
192:                public String getType() {
193:                    if (cmds.contains(MOVE) && cmds.contains(CREATE)) {
194:                        return CREATE;
195:                    } else if (cmds.contains(DELETE) && cmds.contains(CREATE)) {
196:                        return CHANGE_TYPE;
197:                    } else if (cmds.contains(DELETE)) {
198:                        return DELETE;
199:                    } else if (cmds.contains(UPDATE)) {
200:                        return UPDATE;
201:                    } else if (cmds.contains(CREATE)) {
202:                        return CREATE;
203:                    } else if (cmds.contains(MOVE)) {
204:                        return MOVE;
205:                    }
206:
207:                    return "";
208:                }
209:
210:                public String toString() {
211:                    StringBuffer buffer = new StringBuffer();
212:
213:                    if (conflict) {
214:                        buffer.append(CONFLICT);
215:                    } else {
216:                        buffer.append(getType());
217:                    }
218:
219:                    buffer.append(" ");
220:                    buffer.append(path);
221:
222:                    return buffer.toString();
223:                }
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.