Java Doc for SetUtils.java in  » Library » Apache-common-Collections » org » apache » commons » collections » 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 » Library » Apache common Collections » org.apache.commons.collections 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.apache.commons.collections.SetUtils

SetUtils
public class SetUtils (Code)
Provides utility methods and decorators for Set and SortedSet instances.
since:
   Commons Collections 2.1
version:
   $Revision: 155406 $ $Date: 2005-02-26 12:55:26 +0000 (Sat, 26 Feb 2005) $
author:
   Paul Jack
author:
   Stephen Colebourne
author:
   Neil O'Toole
author:
   Matthew Hawthorne


Field Summary
final public static  SetEMPTY_SET
     An empty unmodifiable set.
final public static  SortedSetEMPTY_SORTED_SET
     An empty unmodifiable sorted set.

Constructor Summary
public  SetUtils()
     SetUtils should not normally be instantiated.

Method Summary
public static  inthashCodeForSet(Collection set)
     Generates a hash code using the algorithm specified in java.util.Set.hashCode .

This method is useful for implementing Set when you cannot extend AbstractSet.

public static  booleanisEqualSet(Collection set1, Collection set2)
     Tests two sets for equality as per the equals() contract in java.util.Set.equals(java.lang.Object) .

This method is useful for implementing Set when you cannot extend AbstractSet.

public static  SetorderedSet(Set set)
     Returns a set that maintains the order of elements that are added backed by the given set.
public static  SetpredicatedSet(Set set, Predicate predicate)
     Returns a predicated (validating) set backed by the given set.
public static  SortedSetpredicatedSortedSet(SortedSet set, Predicate predicate)
     Returns a predicated (validating) sorted set backed by the given sorted set.
public static  SetsynchronizedSet(Set set)
     Returns a synchronized set backed by the given set.
public static  SortedSetsynchronizedSortedSet(SortedSet set)
     Returns a synchronized sorted set backed by the given sorted set.
public static  SettransformedSet(Set set, Transformer transformer)
     Returns a transformed set backed by the given set.

Each object is passed through the transformer as it is added to the Set.

public static  SortedSettransformedSortedSet(SortedSet set, Transformer transformer)
     Returns a transformed sorted set backed by the given set.

Each object is passed through the transformer as it is added to the Set.

public static  SettypedSet(Set set, Class type)
     Returns a typed set backed by the given set.
public static  SortedSettypedSortedSet(SortedSet set, Class type)
     Returns a typed sorted set backed by the given set.
public static  SetunmodifiableSet(Set set)
     Returns an unmodifiable set backed by the given set.
public static  SortedSetunmodifiableSortedSet(SortedSet set)
     Returns an unmodifiable sorted set backed by the given sorted set.

Field Detail
EMPTY_SET
final public static Set EMPTY_SET(Code)
An empty unmodifiable set. This uses the Collections implementation and is provided for completeness.



EMPTY_SORTED_SET
final public static SortedSet EMPTY_SORTED_SET(Code)
An empty unmodifiable sorted set. This is not provided in the JDK.




Constructor Detail
SetUtils
public SetUtils()(Code)
SetUtils should not normally be instantiated.




Method Detail
hashCodeForSet
public static int hashCodeForSet(Collection set)(Code)
Generates a hash code using the algorithm specified in java.util.Set.hashCode .

This method is useful for implementing Set when you cannot extend AbstractSet. The method takes Collection instances to enable other collection types to use the Set implementation algorithm.
See Also:   java.util.Set.hashCode
Parameters:
  set - the set to calculate the hash code for, may be null the hash code




isEqualSet
public static boolean isEqualSet(Collection set1, Collection set2)(Code)
Tests two sets for equality as per the equals() contract in java.util.Set.equals(java.lang.Object) .

This method is useful for implementing Set when you cannot extend AbstractSet. The method takes Collection instances to enable other collection types to use the Set implementation algorithm.

The relevant text (slightly paraphrased as this is a static method) is:

Two sets are considered equal if they have the same size, and every member of the first set is contained in the second. This ensures that the equals method works properly across different implementations of the Set interface.

This implementation first checks if the two sets are the same object: if so it returns true. Then, it checks if the two sets are identical in size; if not, it returns false. If so, it returns a.containsAll((Collection) b).


See Also:   java.util.Set
Parameters:
  set1 - the first set, may be null
Parameters:
  set2 - the second set, may be null whether the sets are equal by value comparison



orderedSet
public static Set orderedSet(Set set)(Code)
Returns a set that maintains the order of elements that are added backed by the given set.

If an element is added twice, the order is determined by the first add. The order is observed through the iterator or toArray.
Parameters:
  set - the set to order, must not be null an ordered set backed by the given set
throws:
  IllegalArgumentException - if the Set is null




predicatedSet
public static Set predicatedSet(Set set, Predicate predicate)(Code)
Returns a predicated (validating) set backed by the given set.

Only objects that pass the test in the given predicate can be added to the set. Trying to add an invalid object results in an IllegalArgumentException. It is important not to use the original set after invoking this method, as it is a backdoor for adding invalid objects.
Parameters:
  set - the set to predicate, must not be null
Parameters:
  predicate - the predicate for the set, must not be null a predicated set backed by the given set
throws:
  IllegalArgumentException - if the Set or Predicate is null




predicatedSortedSet
public static SortedSet predicatedSortedSet(SortedSet set, Predicate predicate)(Code)
Returns a predicated (validating) sorted set backed by the given sorted set.

Only objects that pass the test in the given predicate can be added to the set. Trying to add an invalid object results in an IllegalArgumentException. It is important not to use the original set after invoking this method, as it is a backdoor for adding invalid objects.
Parameters:
  set - the sorted set to predicate, must not be null
Parameters:
  predicate - the predicate for the sorted set, must not be null a predicated sorted set backed by the given sorted set
throws:
  IllegalArgumentException - if the Set or Predicate is null




synchronizedSet
public static Set synchronizedSet(Set set)(Code)
Returns a synchronized set backed by the given set.

You must manually synchronize on the returned buffer's iterator to avoid non-deterministic behavior:

 Set s = SetUtils.synchronizedSet(mySet);
 synchronized (s) {
 Iterator i = s.iterator();
 while (i.hasNext()) {
 process (i.next());
 }
 }
 
This method uses the implementation in the decorators subpackage.
Parameters:
  set - the set to synchronize, must not be null a synchronized set backed by the given set
throws:
  IllegalArgumentException - if the set is null



synchronizedSortedSet
public static SortedSet synchronizedSortedSet(SortedSet set)(Code)
Returns a synchronized sorted set backed by the given sorted set.

You must manually synchronize on the returned buffer's iterator to avoid non-deterministic behavior:

 Set s = SetUtils.synchronizedSet(mySet);
 synchronized (s) {
 Iterator i = s.iterator();
 while (i.hasNext()) {
 process (i.next());
 }
 }
 
This method uses the implementation in the decorators subpackage.
Parameters:
  set - the sorted set to synchronize, must not be null a synchronized set backed by the given set
throws:
  IllegalArgumentException - if the set is null



transformedSet
public static Set transformedSet(Set set, Transformer transformer)(Code)
Returns a transformed set backed by the given set.

Each object is passed through the transformer as it is added to the Set. It is important not to use the original set after invoking this method, as it is a backdoor for adding untransformed objects.
Parameters:
  set - the set to transform, must not be null
Parameters:
  transformer - the transformer for the set, must not be null a transformed set backed by the given set
throws:
  IllegalArgumentException - if the Set or Transformer is null




transformedSortedSet
public static SortedSet transformedSortedSet(SortedSet set, Transformer transformer)(Code)
Returns a transformed sorted set backed by the given set.

Each object is passed through the transformer as it is added to the Set. It is important not to use the original set after invoking this method, as it is a backdoor for adding untransformed objects.
Parameters:
  set - the set to transform, must not be null
Parameters:
  transformer - the transformer for the set, must not be null a transformed set backed by the given set
throws:
  IllegalArgumentException - if the Set or Transformer is null




typedSet
public static Set typedSet(Set set, Class type)(Code)
Returns a typed set backed by the given set.

Only objects of the specified type can be added to the set.
Parameters:
  set - the set to limit to a specific type, must not be null
Parameters:
  type - the type of objects which may be added to the set a typed set backed by the specified set




typedSortedSet
public static SortedSet typedSortedSet(SortedSet set, Class type)(Code)
Returns a typed sorted set backed by the given set.

Only objects of the specified type can be added to the set.
Parameters:
  set - the set to limit to a specific type, must not be null
Parameters:
  type - the type of objects which may be added to the set a typed set backed by the specified set




unmodifiableSet
public static Set unmodifiableSet(Set set)(Code)
Returns an unmodifiable set backed by the given set.

This method uses the implementation in the decorators subpackage.
Parameters:
  set - the set to make unmodifiable, must not be null an unmodifiable set backed by the given set
throws:
  IllegalArgumentException - if the set is null




unmodifiableSortedSet
public static SortedSet unmodifiableSortedSet(SortedSet set)(Code)
Returns an unmodifiable sorted set backed by the given sorted set.

This method uses the implementation in the decorators subpackage.
Parameters:
  set - the sorted set to make unmodifiable, must not be null an unmodifiable set backed by the given set
throws:
  IllegalArgumentException - if the set is null




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.