Source Code Cross Referenced for Hunk3.java in  » Source-Control » sourcejammer » JLibDiff » 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 » Source Control » sourcejammer » JLibDiff 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright (C) 2001, 2002 Robert MacGrogan
003:         *
004:         *  This library is free software; you can redistribute it and/or
005:         *  modify it under the terms of the GNU Lesser General Public
006:         *  License as published by the Free Software Foundation; either
007:         *  version 2.1 of the License, or (at your option) any later version.
008:         *
009:         *  This library is distributed in the hope that it will be useful,
010:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012:         *  Lesser General Public License for more details.
013:         *
014:         *  You should have received a copy of the GNU Lesser General Public
015:         *  License along with this library; if not, write to the Free Software
016:         *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017:         *
018:         *
019:         * $Archive: SourceJammer$
020:         * $FileName: Hunk3.java$
021:         * $FileID: 4295$
022:         *
023:         * Last change:
024:         * $AuthorName: Rob MacGrogan$
025:         * $Date: 4/23/03 5:23 PM$
026:         * $Comment: Replaced GPL header with LGPL header.$
027:         */
028:
029:        package JLibDiff;
030:
031:        import java.io.*;
032:        import java.util.*;
033:
034:        /**
035:         * @author $AuthorName: Rob MacGrogan$
036:         * @version $VerNum: 2$
037:         * $KeyWordsOff: $<br><br>
038:         * 
039:         * 
040:         * The <code>Hunk3</code> class represents a bloc of difference of three
041:         * files or  three Buffers.
042:         */
043:        public class Hunk3 {
044:
045:            DiffType diff;
046:            int range[][] = new int[3][2];
047:            private Hunk3Type type = null;
048:            private ArrayList file0Lines = null;
049:            private ArrayList file1Lines = null;
050:            private ArrayList file2Lines = null;
051:
052:            Vector a = new Vector();
053:            Vector b = new Vector();
054:            Vector c = new Vector();
055:
056:            /**
057:             * Allocates a new Hunk3.
058:             */
059:            public Hunk3() {
060:            }
061:
062:            /**
063:             * Set range of difference which consern this bloc in etch file by values
064:             * passed in argument.
065:             *
066:             * @param low0  start position of bloc of difference in the first file.
067:             * @param high0 end position of bloc ob difference in thefirst file.   
068:             * @param low1  start position of bloc of difference in the second file.
069:             * @param high1 end position of bloc ob difference in the second file. 
070:             * @param lowc  start position of bloc of difference in the therd file.
071:             * @param highc end position of bloc ob difference in the therd file.
072:             */
073:            public void setRange(int low0, int high0, int low1, int high1,
074:                    int lowc, int highc) {
075:                range[0][0] = low0;
076:                range[0][1] = high0;
077:                range[1][0] = low1;
078:                range[1][1] = high1;
079:                range[2][0] = lowc;
080:                range[2][1] = highc;
081:            }
082:
083:            /**
084:             * Returns a string representation of the current Hunk with normal format.
085:             */
086:            public String convert() {
087:                int i;
088:                int dontprint = 0;
089:                int oddoneout;
090:                System.out.print("----------" + diff.code() + "\n");
091:                String s = new String("====");
092:                switch (diff.code()) {
093:                case 5:
094:                    dontprint = 3;
095:                    oddoneout = 3;
096:                    s = s.concat("\n");
097:                    break;
098:                case 6:
099:                case 7:
100:                case 8:
101:                    oddoneout = (int) diff.code() - 6;
102:                    if (oddoneout == 0)
103:                        dontprint = 1;
104:                    else
105:                        dontprint = 0;
106:                    s = s.concat((+oddoneout + 1) + "\n");
107:                    break;
108:                default:
109:                    break;
110:                }
111:                for (i = 0; i < 3; i++) {
112:                    int lowt = this .lowLine(i), hight = this .highLine(i);
113:                    s = s.concat(+(i + 1) + ":");
114:                    switch (lowt - hight) {
115:                    case 1:
116:                        s = s.concat(+(lowt - 1) + "a\n");
117:                        break;
118:                    case 0:
119:                        s = s.concat(+lowt + "c\n");
120:                        break;
121:                    default:
122:                        s = s.concat(+lowt + "," + hight + "c\n");
123:                        break;
124:                    }
125:                    if (i == dontprint)
126:                        continue;
127:                    if (lowt <= hight) {
128:
129:                    }
130:                }
131:                return s;
132:            }
133:
134:            /**
135:             * Returns the value of position of bloc start line reliding the
136:             * file passed in argument.
137:             *
138:             * @param filenum   file number which can be:
139:             *                    0 to indicate first file.
140:             *                    1 to indicate second file.
141:             *                    2 to indicate therd file.
142:             */
143:            public int lowLine(int filenum) {
144:                return range[filenum][0];
145:            }
146:
147:            /**
148:             * Returns the value of position of bloc end line reliding the
149:             * file passed in argument.
150:             *
151:             * @param filenum   file number which can be:
152:             *                    0 to indicate first file.
153:             *                    1 to indicate second file.
154:             *                    2 to indicate therd file.
155:             */
156:            public int highLine(int filenum) {
157:                return range[filenum][1];
158:            }
159:
160:            /**
161:             * Returns the number of lines reliding this bloc of difference and the
162:             * file passed in argument.
163:             *
164:             * @param filenum   file number which can be:
165:             *                    0 to indicate first file.
166:             *                    1 to indicate second file.
167:             *                    2 to indicate therd file.
168:             */
169:            public int numLines(int filenum) {
170:                return (range[filenum][1] - range[filenum][0] + 1);
171:            }
172:
173:            public void accpet(Hunk3Visitor visitor) {
174:                visitor.visitHunk3(this );
175:            }
176:
177:            /**
178:             * Returns the maximum range for this hunk3. That is, the greatest
179:             * difference between high line and low line in a single file.
180:             */
181:            public int getMaxRange() {
182:                int max = -1;
183:
184:                int range0 = numLines(0);
185:                int range1 = numLines(1);
186:                int range2 = numLines(2);
187:
188:                if (range0 > range1) {
189:                    max = range0;
190:                } else {
191:                    max = range1;
192:                }
193:                if (range2 > max) {
194:                    max = range2;
195:                }
196:                return max;
197:            }
198:
199:            /**
200:             * Returns the file0Lines.
201:             * @return ArrayList
202:             */
203:            public ArrayList getFile0Lines() {
204:                return file0Lines;
205:            }
206:
207:            /**
208:             * Returns the file1Lines.
209:             * @return ArrayList
210:             */
211:            public ArrayList getFile1Lines() {
212:                return file1Lines;
213:            }
214:
215:            /**
216:             * Returns the file2Lines.
217:             * @return ArrayList
218:             */
219:            public ArrayList getFile2Lines() {
220:                return file2Lines;
221:            }
222:
223:            /**
224:             * Sets the file0Lines.
225:             * @param file0Lines The file0Lines to set
226:             */
227:            public void setFile0Lines(ArrayList file0Lines) {
228:                this .file0Lines = file0Lines;
229:            }
230:
231:            /**
232:             * Sets the file1Lines.
233:             * @param file1Lines The file1Lines to set
234:             */
235:            public void setFile1Lines(ArrayList file1Lines) {
236:                this .file1Lines = file1Lines;
237:            }
238:
239:            /**
240:             * Sets the file2Lines.
241:             * @param file2Lines The file2Lines to set
242:             */
243:            public void setFile2Lines(ArrayList file2Lines) {
244:                this .file2Lines = file2Lines;
245:            }
246:
247:            /**
248:             * Returns the type.
249:             * @return Hunk3Type
250:             */
251:            public Hunk3Type getType() {
252:                return type;
253:            }
254:
255:            /**
256:             * Sets the type.
257:             * @param type The type to set
258:             */
259:            public void setType(Hunk3Type type) {
260:                this.type = type;
261:            }
262:
263:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.