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


001:        /*
002:         *  Copyright 2001-2004,2006 The Apache Software Foundation
003:         *
004:         *  Licensed under the Apache License, Version 2.0 (the "License");
005:         *  you may not use this file except in compliance with the License.
006:         *  You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         *  Unless required by applicable law or agreed to in writing, software
011:         *  distributed under the License is distributed on an "AS IS" BASIS,
012:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         *  See the License for the specific language governing permissions and
014:         *  limitations under the License.
015:         */
016:        package org.apache.commons.collections.functors;
017:
018:        import java.util.Collection;
019:        import java.util.Iterator;
020:
021:        import org.apache.commons.collections.Closure;
022:        import org.apache.commons.collections.Predicate;
023:        import org.apache.commons.collections.Transformer;
024:
025:        /**
026:         * Internal utilities for functors.
027:         * 
028:         * @since Commons Collections 3.0
029:         * @version $Revision: 377508 $ $Date: 2006-02-13 22:12:33 +0000 (Mon, 13 Feb 2006) $
030:         *
031:         * @author Stephen Colebourne
032:         * @author Matt Benson
033:         */
034:        class FunctorUtils {
035:
036:            /**
037:             * Restricted constructor.
038:             */
039:            private FunctorUtils() {
040:                super ();
041:            }
042:
043:            /**
044:             * Clone the predicates to ensure that the internal reference can't be messed with.
045:             * 
046:             * @param predicates  the predicates to copy
047:             * @return the cloned predicates
048:             */
049:            static Predicate[] copy(Predicate[] predicates) {
050:                if (predicates == null) {
051:                    return null;
052:                }
053:                return (Predicate[]) predicates.clone();
054:            }
055:
056:            /**
057:             * Validate the predicates to ensure that all is well.
058:             * 
059:             * @param predicates  the predicates to validate
060:             */
061:            static void validate(Predicate[] predicates) {
062:                if (predicates == null) {
063:                    throw new IllegalArgumentException(
064:                            "The predicate array must not be null");
065:                }
066:                for (int i = 0; i < predicates.length; i++) {
067:                    if (predicates[i] == null) {
068:                        throw new IllegalArgumentException(
069:                                "The predicate array must not contain a null predicate, index "
070:                                        + i + " was null");
071:                    }
072:                }
073:            }
074:
075:            /**
076:             * Validate the predicates to ensure that all is well.
077:             * 
078:             * @param predicates  the predicates to validate
079:             * @return predicate array
080:             */
081:            static Predicate[] validate(Collection predicates) {
082:                if (predicates == null) {
083:                    throw new IllegalArgumentException(
084:                            "The predicate collection must not be null");
085:                }
086:                // convert to array like this to guarantee iterator() ordering
087:                Predicate[] preds = new Predicate[predicates.size()];
088:                int i = 0;
089:                for (Iterator it = predicates.iterator(); it.hasNext();) {
090:                    preds[i] = (Predicate) it.next();
091:                    if (preds[i] == null) {
092:                        throw new IllegalArgumentException(
093:                                "The predicate collection must not contain a null predicate, index "
094:                                        + i + " was null");
095:                    }
096:                    i++;
097:                }
098:                return preds;
099:            }
100:
101:            /**
102:             * Clone the closures to ensure that the internal reference can't be messed with.
103:             * 
104:             * @param closures  the closures to copy
105:             * @return the cloned closures
106:             */
107:            static Closure[] copy(Closure[] closures) {
108:                if (closures == null) {
109:                    return null;
110:                }
111:                return (Closure[]) closures.clone();
112:            }
113:
114:            /**
115:             * Validate the closures to ensure that all is well.
116:             * 
117:             * @param closures  the closures to validate
118:             */
119:            static void validate(Closure[] closures) {
120:                if (closures == null) {
121:                    throw new IllegalArgumentException(
122:                            "The closure array must not be null");
123:                }
124:                for (int i = 0; i < closures.length; i++) {
125:                    if (closures[i] == null) {
126:                        throw new IllegalArgumentException(
127:                                "The closure array must not contain a null closure, index "
128:                                        + i + " was null");
129:                    }
130:                }
131:            }
132:
133:            /**
134:             * Copy method
135:             * 
136:             * @param transformers  the transformers to copy
137:             * @return a clone of the transformers
138:             */
139:            static Transformer[] copy(Transformer[] transformers) {
140:                if (transformers == null) {
141:                    return null;
142:                }
143:                return (Transformer[]) transformers.clone();
144:            }
145:
146:            /**
147:             * Validate method
148:             * 
149:             * @param transformers  the transformers to validate
150:             */
151:            static void validate(Transformer[] transformers) {
152:                if (transformers == null) {
153:                    throw new IllegalArgumentException(
154:                            "The transformer array must not be null");
155:                }
156:                for (int i = 0; i < transformers.length; i++) {
157:                    if (transformers[i] == null) {
158:                        throw new IllegalArgumentException(
159:                                "The transformer array must not contain a null transformer, index "
160:                                        + i + " was null");
161:                    }
162:                }
163:            }
164:
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.