Java Doc for ComparatorChain.java in  » Database-DBMS » axion » org » axiondb » util » 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 DBMS » axion » org.axiondb.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.axiondb.util.ComparatorChain

ComparatorChain
public class ComparatorChain implements Comparator,Serializable(Code)

A ComparatorChain is a Comparator that wraps one or more Comparators in sequence. The ComparatorChain calls each Comparator in sequence until either 1) any single Comparator returns a non-zero result (and that result is then returned), or 2) the ComparatorChain is exhausted (and zero is returned). This type of sorting is very similar to multi-column sorting in SQL, and this class allows Java classes to emulate that kind of behaviour when sorting a List.

To further facilitate SQL-like sorting, the order of any single Comparator in the list can be reversed.

Calling a method that adds new Comparators or changes the ascend/descend sort after compare(Object, Object) has been called will result in an UnsupportedOperationException. However, take care to not alter the underlying List of Comparators or the BitSet that defines the sort order.

Instances of ComparatorChain are not synchronized. The class is not thread-safe at construction time, but it is thread-safe to perform multiple comparisons after all the setup operations are complete.


author:
   Morgan Delagrange
version:
   $Revision: 1.1 $ $Date: 2005/10/13 02:25:32 $


Field Summary
protected  ListcomparatorChain
    
protected  booleanisLocked
    
protected  BitSetorderingBits
    

Constructor Summary
public  ComparatorChain()
     Construct a ComparatorChain with no Comparators.
public  ComparatorChain(Comparator comparator)
    
public  ComparatorChain(Comparator comparator, boolean reverse)
    
public  ComparatorChain(List list)
     Construct a ComparatorChain from the Comparators in the List.
public  ComparatorChain(List list, BitSet bits)
     Construct a ComparatorChain from the Comparators in the given List.

Method Summary
public  voidaddComparator(Comparator comparator)
    
public  voidaddComparator(Comparator comparator, boolean reverse)
    
public  intcompare(Object o1, Object o2)
     Perform comparisons on the Objects as per Comparator.compare(o1,o2).
public  booleanequals(Object that)
     Returns true iff that Object is is a Comparator whose ordering is known to be equivalent to mine.

This implementation returns true iff that. Object.getClass getClass() equals this.getClass(), and the underlying comparators and order bits are equal.

public  inthashCode()
     Implement a hash code for this comparator that is consistent with ComparatorChain.equals .
public  booleanisLocked()
     Determine if modifications can still be made to the ComparatorChain.
public  voidsetComparator(int index, Comparator comparator)
     Replace the Comparator at the given index, maintaining the existing sort order.
public  voidsetComparator(int index, Comparator comparator, boolean reverse)
    
public  voidsetForwardSort(int index)
     Change the sort order at the given index in the ComparatorChain to a forward sort.
public  voidsetReverseSort(int index)
     Change the sort order at the given index in the ComparatorChain to a reverse sort.
public  intsize()
     Number of Comparators in the current ComparatorChain.

Field Detail
comparatorChain
protected List comparatorChain(Code)



isLocked
protected boolean isLocked(Code)



orderingBits
protected BitSet orderingBits(Code)




Constructor Detail
ComparatorChain
public ComparatorChain()(Code)
Construct a ComparatorChain with no Comparators. You must add at least one Comparator before calling the compare(Object,Object) method, or an UnsupportedOperationException is thrown



ComparatorChain
public ComparatorChain(Comparator comparator)(Code)
Construct a ComparatorChain with a single Comparator, sorting in the forward order
Parameters:
  comparator - First comparator in the Comparator chain



ComparatorChain
public ComparatorChain(Comparator comparator, boolean reverse)(Code)
Construct a Comparator chain with a single Comparator, sorting in the given order
Parameters:
  comparator - First Comparator in the ComparatorChain
Parameters:
  reverse - false = forward sort; true = reverse sort



ComparatorChain
public ComparatorChain(List list)(Code)
Construct a ComparatorChain from the Comparators in the List. All Comparators will default to the forward sort order.
Parameters:
  list - List of Comparators
See Also:   ComparatorChain.ComparatorChain(List,BitSet)



ComparatorChain
public ComparatorChain(List list, BitSet bits)(Code)
Construct a ComparatorChain from the Comparators in the given List. The sort order of each column will be drawn from the given BitSet. When determining the sort order for Comparator at index i in the List, the ComparatorChain will call BitSet.get(i). If that method returns false, the forward sort order is used; a return value of true indicates reverse sort order.
Parameters:
  list - List of Comparators. NOTE: This constructor does not perform adefensive copy of the list
Parameters:
  bits - Sort order for each Comparator. Extra bits are ignored, unless extraComparators are added by another method.




Method Detail
addComparator
public void addComparator(Comparator comparator)(Code)
Add a Comparator to the end of the chain using the forward sort order
Parameters:
  comparator - Comparator with the forward sort order



addComparator
public void addComparator(Comparator comparator, boolean reverse)(Code)
Add a Comparator to the end of the chain using the given sort order
Parameters:
  comparator - Comparator to add to the end of the chain
Parameters:
  reverse - false = forward sort order; true = reverse sort order



compare
public int compare(Object o1, Object o2) throws UnsupportedOperationException(Code)
Perform comparisons on the Objects as per Comparator.compare(o1,o2).
Parameters:
  o1 - object 1
Parameters:
  o2 - object 2 -1, 0, or 1
exception:
  UnsupportedOperationException - if the ComparatorChain does not contain atleast one Comparator



equals
public boolean equals(Object that)(Code)
Returns true iff that Object is is a Comparator whose ordering is known to be equivalent to mine.

This implementation returns true iff that. Object.getClass getClass() equals this.getClass(), and the underlying comparators and order bits are equal. Subclasses may want to override this behavior to remain consistent with the Comparator.equals contract.
since:
   Commons Collections 3.0




hashCode
public int hashCode()(Code)
Implement a hash code for this comparator that is consistent with ComparatorChain.equals .
since:
   Commons Collections 3.0



isLocked
public boolean isLocked()(Code)
Determine if modifications can still be made to the ComparatorChain. ComparatorChains cannot be modified once they have performed a comparison. true = ComparatorChain cannot be modified; false = ComparatorChain canstill be modified.



setComparator
public void setComparator(int index, Comparator comparator) throws IndexOutOfBoundsException(Code)
Replace the Comparator at the given index, maintaining the existing sort order.
Parameters:
  index - index of the Comparator to replace
Parameters:
  comparator - Comparator to place at the given index
exception:
  IndexOutOfBoundsException - if index < 0 or index >= size()



setComparator
public void setComparator(int index, Comparator comparator, boolean reverse)(Code)
Replace the Comparator at the given index in the ComparatorChain, using the given sort order
Parameters:
  index - index of the Comparator to replace
Parameters:
  comparator - Comparator to set
Parameters:
  reverse - false = forward sort order; true = reverse sort order



setForwardSort
public void setForwardSort(int index)(Code)
Change the sort order at the given index in the ComparatorChain to a forward sort.
Parameters:
  index - Index of the ComparatorChain



setReverseSort
public void setReverseSort(int index)(Code)
Change the sort order at the given index in the ComparatorChain to a reverse sort.
Parameters:
  index - Index of the ComparatorChain



size
public int size()(Code)
Number of Comparators in the current ComparatorChain. Comparator count



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.