Java Doc for Diff.java in  » Wiki-Engine » JAMWiki » org » incava » util » diff » 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 » Wiki Engine » JAMWiki » org.incava.util.diff 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.incava.util.diff.Diff

Diff
public class Diff (Code)
Compares two collections, returning a list of the additions, changes, and deletions between them. A Comparator may be passed as an argument to the constructor, and will thus be used. If not provided, the initial value in the a ("from") collection will be looked at to see if it supports the Comparable interface. If so, its equals and compareTo methods will be invoked on the instances in the "from" and "to" collections; otherwise, for speed, hash codes from the objects will be used instead for comparison.

The file FileDiff.java shows an example usage of this class, in an application similar to the Unix "diff" program.



Field Summary
protected  Object[]a
     The source array, AKA the "from" values.
protected  Object[]b
     The target array, AKA the "to" values.
protected  Listdiffs
     The list of differences, as Difference instances.

Constructor Summary
public  Diff(Object[] a, Object[] b, Comparator comp)
     Constructs the Diff object for the two arrays, using the given comparator.
public  Diff(Object[] a, Object[] b)
     Constructs the Diff object for the two arrays, using the default comparison mechanism between the objects, such as equals and compareTo.
public  Diff(Collection a, Collection b, Comparator comp)
     Constructs the Diff object for the two collections, using the given comparator.
public  Diff(Collection a, Collection b)
     Constructs the Diff object for the two collections, using the default comparison mechanism between the objects, such as equals and compareTo.

Method Summary
protected  voidappend(Integer value)
     Adds the given value to the "end" of the threshold map, that is, with the greatest index/key.
protected  booleancallFinishedA()
     Override and return true in order to have finishedA invoked at the last element in the a array.
protected  booleancallFinishedB()
     Override and return true in order to have finishedB invoked at the last element in the b array.
public  Listdiff()
     Runs diff and returns the results.
protected  booleanequals(Object x, Object y)
     Compares the two objects, using the comparator provided with the constructor, if any.
protected  voidfinishedA(int lastA)
     Invoked at the last element in a, if callFinishedA returns true.
protected  voidfinishedB(int lastB)
     Invoked at the last element in b, if callFinishedB returns true.
protected  IntegergetLastValue()
     Returns the value for the greatest key in the map.
public  Integer[]getLongestCommonSubsequences()
     Returns an array of the longest common subsequences.
protected  Integerinsert(Integer j, Integer k)
     Inserts the given values into the threshold map.
protected  booleanisGreaterThan(Integer index, Integer val)
     Returns whether the value in the map for the given index is greater than the given value.
protected  booleanisLessThan(Integer index, Integer val)
     Returns whether the value in the map for the given index is less than the given value.
protected static  booleanisNonzero(Integer i)
     Returns whether the integer is not zero (including if it is not null).
protected  voidonANotB(int ai, int bi)
     Invoked for elements in a and not in b.
protected  voidonBNotA(int ai, int bi)
     Invoked for elements in b and not in a.
protected  voidonMatch(int ai, int bi)
     Invoked for elements matching in a and b.
protected static  Integer[]toArray(TreeMap map)
     Converts the map (indexed by java.lang.Integers) into an array.
protected  voidtraverseSequences()
     Traverses the sequences, seeking the longest common subsequences, invoking the methods finishedA, finishedB, onANotB, and onBNotA.

Field Detail
a
protected Object[] a(Code)
The source array, AKA the "from" values.



b
protected Object[] b(Code)
The target array, AKA the "to" values.



diffs
protected List diffs(Code)
The list of differences, as Difference instances.




Constructor Detail
Diff
public Diff(Object[] a, Object[] b, Comparator comp)(Code)
Constructs the Diff object for the two arrays, using the given comparator.



Diff
public Diff(Object[] a, Object[] b)(Code)
Constructs the Diff object for the two arrays, using the default comparison mechanism between the objects, such as equals and compareTo.



Diff
public Diff(Collection a, Collection b, Comparator comp)(Code)
Constructs the Diff object for the two collections, using the given comparator.



Diff
public Diff(Collection a, Collection b)(Code)
Constructs the Diff object for the two collections, using the default comparison mechanism between the objects, such as equals and compareTo.




Method Detail
append
protected void append(Integer value)(Code)
Adds the given value to the "end" of the threshold map, that is, with the greatest index/key.



callFinishedA
protected boolean callFinishedA()(Code)
Override and return true in order to have finishedA invoked at the last element in the a array.



callFinishedB
protected boolean callFinishedB()(Code)
Override and return true in order to have finishedB invoked at the last element in the b array.



diff
public List diff()(Code)
Runs diff and returns the results.



equals
protected boolean equals(Object x, Object y)(Code)
Compares the two objects, using the comparator provided with the constructor, if any.



finishedA
protected void finishedA(int lastA)(Code)
Invoked at the last element in a, if callFinishedA returns true.



finishedB
protected void finishedB(int lastB)(Code)
Invoked at the last element in b, if callFinishedB returns true.



getLastValue
protected Integer getLastValue()(Code)
Returns the value for the greatest key in the map.



getLongestCommonSubsequences
public Integer[] getLongestCommonSubsequences()(Code)
Returns an array of the longest common subsequences.



insert
protected Integer insert(Integer j, Integer k)(Code)
Inserts the given values into the threshold map.



isGreaterThan
protected boolean isGreaterThan(Integer index, Integer val)(Code)
Returns whether the value in the map for the given index is greater than the given value.



isLessThan
protected boolean isLessThan(Integer index, Integer val)(Code)
Returns whether the value in the map for the given index is less than the given value.



isNonzero
protected static boolean isNonzero(Integer i)(Code)
Returns whether the integer is not zero (including if it is not null).



onANotB
protected void onANotB(int ai, int bi)(Code)
Invoked for elements in a and not in b.



onBNotA
protected void onBNotA(int ai, int bi)(Code)
Invoked for elements in b and not in a.



onMatch
protected void onMatch(int ai, int bi)(Code)
Invoked for elements matching in a and b.



toArray
protected static Integer[] toArray(TreeMap map)(Code)
Converts the map (indexed by java.lang.Integers) into an array.



traverseSequences
protected void traverseSequences()(Code)
Traverses the sequences, seeking the longest common subsequences, invoking the methods finishedA, finishedB, onANotB, and onBNotA.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.