Java Doc for SimpleDiff.java in  » ERP-CRM-Financial » sakai » org » apache » commons » jrcs » 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 » ERP CRM Financial » sakai » org.apache.commons.jrcs.diff 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.jrcs.diff.SimpleDiff

SimpleDiff
public class SimpleDiff implements DiffAlgorithm(Code)
Implements a simple differencing algortithm.


version:
   $Revision: 7756 $
author:
   Juanco Anez
author:
  


author:
   Overview of Algorithm
author:
  


author:
  


author:
   by bwm
author:
  


author:
  


author:
   The algorithm is optimised for situations where the input sequences
author:
   have few repeated objects. If it is given input with many repeated
author:
   objects it will report sub-optimal changes. However, given
author:
   appropriate input, it is fast, and linear in memory usage.
author:
  


author:
  


author:
   The algorithm consists of the following steps:
author:
  


author:
  

    author:
      
  • compute an equivalence set for the input data

  • author:
      
  • translate each element of the orginal and revised input
    author:
       sequences to a member of the equivalence set

  • author:
      
  • match the the input sequences to determine the deltas, i.e. the
    author:
       differences between the original and revised sequences.

  • author:
      

author:
  


author:
   The first step is to compute a an equivalence set for the input data.
author:
   The equivalence set is computed from objects that are in the original
author:
   input sequence
author:
  


author:
  

author:
   eq(x) = the index of the first occurence of x in the original sequence.
author:
  

author:
  


author:
   With this equivalence function, the algorithm can compare integers
author:
   rather than strings, which is considerably more efficient.
author:
  


author:
  


author:
   The second step is to compute the datastructure on which the
author:
   algorithm will operate. Having computed the equivalence function in
author:
   the previous step, we can compute two arrays where indx[i] =
author:
   eqs(orig[i]) and jndx[i] = eqs(rev[i]). The algorithm can now operate
author:
   on indx and jndx instead of orig and rev. Thus, comparisons are then
author:
   on O(int == int) instead of O(Object.equals(Object)).
author:
  


author:
  


author:
   The algorithm now matches indx and jndx. Whilst indx[i] == jndx[i] it
author:
   skips matching objects in the sequence. In seeking to match objects
author:
   in the input sequence it assumes that each object is likely to be
author:
   unique. It uses the known characteristics of the unique equivalence
author:
   function. It can tell from the eq value if this object appeared in
author:
   the other sequence at all. If it did not, there is no point in
author:
   searching for a match.
author:
  


author:
  


author:
   Recall that the eq function value is the index earliest occurrence in
author:
   the orig sequence. This information is used to search efficiently for
author:
   the next match. The algorithm is perfect when all input objects are
author:
   unique, but degrades when input objects are not unique. When input
author:
   objects are not unique an optimal match may not be found, but a
author:
   correct match will be.
author:
  


author:
  


author:
   Having identified common matching objects in the orig and revised
author:
   sequences, the differences between them are easily computed.
author:
  


See Also:   Delta
See Also:   Revision
See Also:    Modifications: 27/Apr/2003 bwm Added some comments whilst
See Also:   trying to figure out the algorithm 03 May 2003 bwm Created this
See Also:   implementation class by refactoring it out of the Diff class to enable
See Also:   plug in difference algorithms


Field Summary
final static  intEOS
    
final static  intNOT_FOUND_i
    
final static  intNOT_FOUND_j
    

Constructor Summary
public  SimpleDiff()
    

Method Summary
protected  MapbuildEqSet(Object[] orig, Object[] rev)
    
protected  int[]buildIndex(Map eqs, Object[] seq, int NF)
    
public  Revisiondiff(Object[] orig, Object[] rev)
     Compute the difference between original and revised sequences.
Parameters:
  orig - The original sequence.
Parameters:
  rev - The revised sequence to be compared with the original.
protected  intscan(int[] ndx, int i, int target)
    

Field Detail
EOS
final static int EOS(Code)



NOT_FOUND_i
final static int NOT_FOUND_i(Code)



NOT_FOUND_j
final static int NOT_FOUND_j(Code)




Constructor Detail
SimpleDiff
public SimpleDiff()(Code)




Method Detail
buildEqSet
protected Map buildEqSet(Object[] orig, Object[] rev)(Code)
create a Map from each common item in orig and rev to the index of its first occurrence in orig
Parameters:
  orig - the original sequence of items
Parameters:
  rev - the revised sequence of items



buildIndex
protected int[] buildIndex(Map eqs, Object[] seq, int NF)(Code)
build a an array such each a[i] = eqs([i]) or NF if eqs([i]) undefined
Parameters:
  eqs - a mapping from Object to Integer
Parameters:
  seq - a sequence of objects
Parameters:
  NF - the not found marker



diff
public Revision diff(Object[] orig, Object[] rev) throws DifferentiationFailedException(Code)
Compute the difference between original and revised sequences.
Parameters:
  orig - The original sequence.
Parameters:
  rev - The revised sequence to be compared with the original. A Revision object describing the differences.
throws:
  DifferenciationFailedException - if the diff could not be computed.



scan
protected int scan(int[] ndx, int i, int target)(Code)



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.