Java Doc for NbCollections.java in  » IDE-Netbeans » openide » org » openide » 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 » IDE Netbeans » openide » org.openide.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.openide.util.NbCollections

NbCollections
public class NbCollections (Code)
Utilities for working with generics.

Note that there is no checkedListByFilter method currently. If constant-time operation is important (e.g. your raw list is large and RandomAccess ) you can use NbCollections.checkedListByCopy , assuming you do not need to modify the underlying list. If you are only interested in an iterator anyway, try NbCollections.checkedIteratorByFilter .
author:
   Jesse Glick
since:
   org.openide.util 7.1





Method Summary
public static  Enumeration<E>checkedEnumerationByFilter(Enumeration rawEnum, Class<E> type, boolean strict)
     Create a typesafe filter of an unchecked enumeration.
public static  Iterator<E>checkedIteratorByFilter(Iterator rawIterator, Class<E> type, boolean strict)
     Create a typesafe filter of an unchecked iterator.
public static  List<E>checkedListByCopy(List rawList, Class<E> type, boolean strict)
     Create a typesafe copy of a raw list.
public static  Map<K, V>checkedMapByCopy(Map rawMap, Class<K> keyType, Class<V> valueType, boolean strict)
     Create a typesafe copy of a raw map.
public static  Map<K, V>checkedMapByFilter(Map rawMap, Class<K> keyType, Class<V> valueType, boolean strict)
     Create a typesafe view over an underlying raw map.
public static  Set<E>checkedSetByCopy(Set rawSet, Class<E> type, boolean strict)
     Create a typesafe copy of a raw set.
public static  Set<E>checkedSetByFilter(Set rawSet, Class<E> type, boolean strict)
     Create a typesafe view over an underlying raw set.
public static  Iterable<E>iterable(Iterator<E> iterator)
     Treat an Iterator as an Iterable so it can be used in an enhanced for-loop.
public static  Iterable<E>iterable(Enumeration<E> enumeration)
     Treat an Enumeration as an Iterable so it can be used in an enhanced for-loop.



Method Detail
checkedEnumerationByFilter
public static Enumeration<E> checkedEnumerationByFilter(Enumeration rawEnum, Class<E> type, boolean strict)(Code)
Create a typesafe filter of an unchecked enumeration.
Parameters:
  rawEnum - an unchecked enumeration
Parameters:
  type - the desired enumeration type
Parameters:
  strict - if false, elements which are not null but not assignable to the requested type are omitted;if true, ClassCastException may be thrown from an enumeration operation an enumeration guaranteed to contain only objects of the requested type (or null)



checkedIteratorByFilter
public static Iterator<E> checkedIteratorByFilter(Iterator rawIterator, Class<E> type, boolean strict)(Code)
Create a typesafe filter of an unchecked iterator. Iterator.remove will work if it does in the unchecked iterator.
Parameters:
  rawIterator - an unchecked iterator
Parameters:
  type - the desired enumeration type
Parameters:
  strict - if false, elements which are not null but not assignable to the requested type are omitted;if true, ClassCastException may be thrown from an iterator operation an iterator guaranteed to contain only objects of the requested type (or null)



checkedListByCopy
public static List<E> checkedListByCopy(List rawList, Class<E> type, boolean strict) throws ClassCastException(Code)
Create a typesafe copy of a raw list.
Parameters:
  rawList - an unchecked list
Parameters:
  type - the desired supertype of the entries
Parameters:
  strict - true to throw a ClassCastException if the raw list has an invalid entry,false to skip over such entries (warnings may be logged) a typed list guaranteed to contain only entries assignableto the named type (or they may be null)
throws:
  ClassCastException - if some entry in the raw list was not well-typed, and only if strict was true



checkedMapByCopy
public static Map<K, V> checkedMapByCopy(Map rawMap, Class<K> keyType, Class<V> valueType, boolean strict) throws ClassCastException(Code)
Create a typesafe copy of a raw map.
Parameters:
  rawMap - an unchecked map
Parameters:
  keyType - the desired supertype of the keys
Parameters:
  valueType - the desired supertype of the values
Parameters:
  strict - true to throw a ClassCastException if the raw map has an invalid key or value,false to skip over such map entries (warnings may be logged) a typed map guaranteed to contain only keys and values assignableto the named types (or they may be null)
throws:
  ClassCastException - if some key or value in the raw map was not well-typed, and only if strict was true



checkedMapByFilter
public static Map<K, V> checkedMapByFilter(Map rawMap, Class<K> keyType, Class<V> valueType, boolean strict)(Code)
Create a typesafe view over an underlying raw map. Mutations affect the underlying map (this is not a copy). Map.clear will make the view empty but may not clear the underlying map. You may add entries only of the requested type pair. Map.get , Map.containsKey , and Map.containsValue also perform a type check and will throw ClassCastException for an illegal argument. The view is serializable if the underlying map is.
Parameters:
  rawMap - an unchecked map
Parameters:
  keyType - the desired entry key type
Parameters:
  valueType - the desired entry value type
Parameters:
  strict - if false, entries in the underlying map for which the key is not null but not assignableto the requested key type, and/or the value is not null but not assignable tothe requested value type, are omitted from the view;if true, a ClassCastException may arise during some map operation a view over the raw map guaranteed to match the specified type



checkedSetByCopy
public static Set<E> checkedSetByCopy(Set rawSet, Class<E> type, boolean strict) throws ClassCastException(Code)
Create a typesafe copy of a raw set.
Parameters:
  rawSet - an unchecked set
Parameters:
  type - the desired supertype of the entries
Parameters:
  strict - true to throw a ClassCastException if the raw set has an invalid entry,false to skip over such entries (warnings may be logged) a typed set guaranteed to contain only entries assignableto the named type (or they may be null)
throws:
  ClassCastException - if some entry in the raw set was not well-typed, and only if strict was true



checkedSetByFilter
public static Set<E> checkedSetByFilter(Set rawSet, Class<E> type, boolean strict)(Code)
Create a typesafe view over an underlying raw set. Mutations affect the underlying set (this is not a copy). Set.clear will make the view empty but may not clear the underlying set. You may add elements only of the requested type. Set.contains also performs a type check and will throw ClassCastException for an illegal argument. The view is serializable if the underlying set is.
Parameters:
  rawSet - an unchecked set
Parameters:
  type - the desired element type
Parameters:
  strict - if false, elements in the underlying set which are not null and which are not assignableto the requested type are omitted from the view;if true, a ClassCastException may arise during some set operation a view over the raw set guaranteed to match the specified type



iterable
public static Iterable<E> iterable(Iterator<E> iterator)(Code)
Treat an Iterator as an Iterable so it can be used in an enhanced for-loop. Bear in mind that the iterator is "consumed" by the loop and so should be used only once. Generally it is best to put the code which obtains the iterator inside the loop header.

Example of correct usage:

 String text = ...;
 for (String token : NbCollections.iterable(new 
java.util.Scanner (text))) {
 // ...
 }
 

Parameters:
  iterator - an iterator an iterable wrapper which will traverse the iterator once
throws:
  NullPointerException - if the iterator is null
See Also:    Java bug #6312085
See Also:    Java bug #6360734
See Also:    Java bug #4988624
since:
   org.openide.util 7.5



iterable
public static Iterable<E> iterable(Enumeration<E> enumeration)(Code)
Treat an Enumeration as an Iterable so it can be used in an enhanced for-loop. Bear in mind that the enumeration is "consumed" by the loop and so should be used only once. Generally it is best to put the code which obtains the enumeration inside the loop header.

Example of correct usage:

 ClassLoader loader = ...;
 String name = ...;
 for (URL resource : NbCollections.iterable(loader.
ClassLoader.getResources getResources (name))) {
 // ...
 }
 

Parameters:
  enumeration - an enumeration an iterable wrapper which will traverse the enumeration once(Iterator.remove is not supported)
throws:
  NullPointerException - if the enumeration is null
See Also:    Java bug #6349852
since:
   org.openide.util 7.5



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.