Java Doc for BagUtils.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.BagUtils

BagUtils
public class BagUtils (Code)
Provides utility methods and decorators for Bag and SortedBag 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:
   Andrew Freeman
author:
   Matthew Hawthorne


Field Summary
final public static  BagEMPTY_BAG
     An empty unmodifiable bag.
final public static  BagEMPTY_SORTED_BAG
     An empty unmodifiable sorted bag.

Constructor Summary
public  BagUtils()
     Instantiation of BagUtils is not intended or required.

Method Summary
public static  BagpredicatedBag(Bag bag, Predicate predicate)
     Returns a predicated (validating) bag backed by the given bag.
public static  SortedBagpredicatedSortedBag(SortedBag bag, Predicate predicate)
     Returns a predicated (validating) sorted bag backed by the given sorted bag.
public static  BagsynchronizedBag(Bag bag)
     Returns a synchronized (thread-safe) bag backed by the given bag.
public static  SortedBagsynchronizedSortedBag(SortedBag bag)
     Returns a synchronized (thread-safe) sorted bag backed by the given sorted bag.
public static  BagtransformedBag(Bag bag, Transformer transformer)
     Returns a transformed bag backed by the given bag.

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

public static  SortedBagtransformedSortedBag(SortedBag bag, Transformer transformer)
     Returns a transformed sorted bag backed by the given bag.

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

public static  BagtypedBag(Bag bag, Class type)
     Returns a typed bag backed by the given bag.
public static  SortedBagtypedSortedBag(SortedBag bag, Class type)
     Returns a typed sorted bag backed by the given bag.
public static  BagunmodifiableBag(Bag bag)
     Returns an unmodifiable view of the given bag.
public static  SortedBagunmodifiableSortedBag(SortedBag bag)
     Returns an unmodifiable view of the given sorted bag.

Field Detail
EMPTY_BAG
final public static Bag EMPTY_BAG(Code)
An empty unmodifiable bag.



EMPTY_SORTED_BAG
final public static Bag EMPTY_SORTED_BAG(Code)
An empty unmodifiable sorted bag.




Constructor Detail
BagUtils
public BagUtils()(Code)
Instantiation of BagUtils is not intended or required. However, some tools require an instance to operate.




Method Detail
predicatedBag
public static Bag predicatedBag(Bag bag, Predicate predicate)(Code)
Returns a predicated (validating) bag backed by the given bag.

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




predicatedSortedBag
public static SortedBag predicatedSortedBag(SortedBag bag, Predicate predicate)(Code)
Returns a predicated (validating) sorted bag backed by the given sorted bag.

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




synchronizedBag
public static Bag synchronizedBag(Bag bag)(Code)
Returns a synchronized (thread-safe) bag backed by the given bag. In order to guarantee serial access, it is critical that all access to the backing bag is accomplished through the returned bag.

It is imperative that the user manually synchronize on the returned bag when iterating over it:

 Bag bag = BagUtils.synchronizedBag(new HashBag());
 ...
 synchronized(bag) {
 Iterator i = bag.iterator(); // Must be in synchronized block
 while (i.hasNext())
 foo(i.next());
 }
 }
 
Failure to follow this advice may result in non-deterministic behavior.
Parameters:
  bag - the bag to synchronize, must not be null a synchronized bag backed by that bag
throws:
  IllegalArgumentException - if the Bag is null



synchronizedSortedBag
public static SortedBag synchronizedSortedBag(SortedBag bag)(Code)
Returns a synchronized (thread-safe) sorted bag backed by the given sorted bag. In order to guarantee serial access, it is critical that all access to the backing bag is accomplished through the returned bag.

It is imperative that the user manually synchronize on the returned bag when iterating over it:

 SortedBag bag = BagUtils.synchronizedSortedBag(new TreeBag());
 ...
 synchronized(bag) {
 Iterator i = bag.iterator(); // Must be in synchronized block
 while (i.hasNext())
 foo(i.next());
 }
 }
 
Failure to follow this advice may result in non-deterministic behavior.
Parameters:
  bag - the bag to synchronize, must not be null a synchronized bag backed by that bag
throws:
  IllegalArgumentException - if the SortedBag is null



transformedBag
public static Bag transformedBag(Bag bag, Transformer transformer)(Code)
Returns a transformed bag backed by the given bag.

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




transformedSortedBag
public static SortedBag transformedSortedBag(SortedBag bag, Transformer transformer)(Code)
Returns a transformed sorted bag backed by the given bag.

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




typedBag
public static Bag typedBag(Bag bag, Class type)(Code)
Returns a typed bag backed by the given bag.

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




typedSortedBag
public static SortedBag typedSortedBag(SortedBag bag, Class type)(Code)
Returns a typed sorted bag backed by the given bag.

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




unmodifiableBag
public static Bag unmodifiableBag(Bag bag)(Code)
Returns an unmodifiable view of the given bag. Any modification attempts to the returned bag will raise an UnsupportedOperationException .
Parameters:
  bag - the bag whose unmodifiable view is to be returned, must not be null an unmodifiable view of that bag
throws:
  IllegalArgumentException - if the Bag is null



unmodifiableSortedBag
public static SortedBag unmodifiableSortedBag(SortedBag bag)(Code)
Returns an unmodifiable view of the given sorted bag. Any modification attempts to the returned bag will raise an UnsupportedOperationException .
Parameters:
  bag - the bag whose unmodifiable view is to be returned, must not be null an unmodifiable view of that bag
throws:
  IllegalArgumentException - if the SortedBag 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.