Source Code Cross Referenced for Exceptions.java in  » Development » PCJ » bak » pcj » 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 » Development » PCJ » bak.pcj.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Primitive Collections for Java.
003:         *  Copyright (C) 2003  Søren Bak
004:         *
005:         *  This library is free software; you can redistribute it and/or
006:         *  modify it under the terms of the GNU Lesser General Public
007:         *  License as published by the Free Software Foundation; either
008:         *  version 2.1 of the License, or (at your option) any later version.
009:         *
010:         *  This library is distributed in the hope that it will be useful,
011:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         *  Lesser General Public License for more details.
014:         *
015:         *  You should have received a copy of the GNU Lesser General Public
016:         *  License along with this library; if not, write to the Free Software
017:         *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
018:         */
019:        package bak.pcj.util;
020:
021:        import bak.pcj.map.NoSuchMappingException;
022:        import java.util.NoSuchElementException;
023:
024:        /**
025:         *  This class provides static methods for throwing exceptions.
026:         *  It is only provided as a utility class for the collection
027:         *  implementations and is not a part of the API.
028:         *
029:         *  @author     Søren Bak
030:         *  @version    1.0     21-08-2003 18:44
031:         */
032:        public class Exceptions {
033:
034:            public static void indexOutOfBounds(int index, int low, int high)
035:                    throws IndexOutOfBoundsException {
036:                throw new IndexOutOfBoundsException("Index out of bounds: "
037:                        + index + ", valid range is " + low + " to " + high);
038:            }
039:
040:            public static void nullArgument(String name)
041:                    throws NullPointerException {
042:                throw new NullPointerException("The specified " + name
043:                        + " is null");
044:            }
045:
046:            public static void negativeArgument(String name, Object value)
047:                    throws IllegalArgumentException {
048:                throw new IllegalArgumentException(name
049:                        + " cannot be negative: " + String.valueOf(value));
050:            }
051:
052:            public static void negativeOrZeroArgument(String name, Object value)
053:                    throws IllegalArgumentException {
054:                throw new IllegalArgumentException(name
055:                        + " must be a positive value: " + String.valueOf(value));
056:            }
057:
058:            // ---------------------------------------------------------------
059:            //      Iterator errors
060:            // ---------------------------------------------------------------
061:
062:            public static void endOfIterator() throws NoSuchElementException {
063:                throw new NoSuchElementException(
064:                        "Attempt to iterate past iterator's last element.");
065:            }
066:
067:            public static void startOfIterator() throws NoSuchElementException {
068:                throw new NoSuchElementException(
069:                        "Attempt to iterate past iterator's first element.");
070:            }
071:
072:            public static void noElementToRemove() throws IllegalStateException {
073:                throw new IllegalStateException(
074:                        "Attempt to remove element from iterator that has no current element.");
075:            }
076:
077:            public static void noElementToGet() throws IllegalStateException {
078:                throw new IllegalStateException(
079:                        "Attempt to get element from iterator that has no current element. Call next() first.");
080:            }
081:
082:            public static void noElementToSet() throws IllegalStateException {
083:                throw new IllegalStateException(
084:                        "Attempt to set element in iterator that has no current element.");
085:            }
086:
087:            // ---------------------------------------------------------------
088:            //      Map errors
089:            // ---------------------------------------------------------------
090:
091:            public static void noLastElement() throws IllegalStateException {
092:                throw new IllegalStateException(
093:                        "No value to return. Call containsKey() first.");
094:            }
095:
096:            public static void noSuchMapping(Object key)
097:                    throws NoSuchMappingException {
098:                throw new NoSuchMappingException("No such key in map: "
099:                        + String.valueOf(key));
100:            }
101:
102:            // ---------------------------------------------------------------
103:            //      Deque errors
104:            // ---------------------------------------------------------------
105:
106:            public static void dequeNoFirst() throws IndexOutOfBoundsException {
107:                throw new IndexOutOfBoundsException(
108:                        "Attempt to get first element of empty deque");
109:            }
110:
111:            public static void dequeNoLast() throws IndexOutOfBoundsException {
112:                throw new IndexOutOfBoundsException(
113:                        "Attempt to get last element of empty deque");
114:            }
115:
116:            public static void dequeNoFirstToRemove()
117:                    throws IndexOutOfBoundsException {
118:                throw new IndexOutOfBoundsException(
119:                        "Attempt to remove last element of empty deque");
120:            }
121:
122:            public static void dequeNoLastToRemove()
123:                    throws IndexOutOfBoundsException {
124:                throw new IndexOutOfBoundsException(
125:                        "Attempt to remove last element of empty deque");
126:            }
127:
128:            // ---------------------------------------------------------------
129:            //      Adapter value errors
130:            // ---------------------------------------------------------------
131:
132:            public static void nullElementNotAllowed()
133:                    throws IllegalArgumentException {
134:                throw new IllegalArgumentException(
135:                        "Attempt to add a null value to an adapted primitive set.");
136:            }
137:
138:            public static void cannotAdapt(String name)
139:                    throws IllegalStateException {
140:                throw new IllegalStateException(
141:                        "The "
142:                                + name
143:                                + " contains values preventing it from being adapted to a primitive "
144:                                + name);
145:            }
146:
147:            // ---------------------------------------------------------------
148:            //      
149:            // ---------------------------------------------------------------
150:
151:            public static void unsupported(String name)
152:                    throws UnsupportedOperationException {
153:                throw new UnsupportedOperationException(
154:                        "Attempt to invoke unsupported operation: " + name);
155:            }
156:
157:            public static void unmodifiable(String name)
158:                    throws UnsupportedOperationException {
159:                throw new UnsupportedOperationException(
160:                        "Attempt to modify unmodifiable " + name);
161:            }
162:
163:            public static void cloning() throws RuntimeException {
164:                throw new RuntimeException("Clone is not supported");
165:            }
166:
167:            public static void invalidRangeBounds(Object first, Object last)
168:                    throws IllegalArgumentException {
169:                throw new IllegalArgumentException("First (" + first
170:                        + ") cannot be greater than last (" + last + ")");
171:            }
172:
173:            public static void cannotMergeRanges(Object r1, Object r2)
174:                    throws IllegalArgumentException {
175:                throw new IllegalArgumentException("Ranges cannot be merged: "
176:                        + r1.toString() + " and " + r2.toString());
177:            }
178:
179:            // ---------------------------------------------------------------
180:            //      Sorted set errors
181:            // ---------------------------------------------------------------
182:
183:            public static void setNoFirst() throws NoSuchElementException {
184:                throw new NoSuchElementException(
185:                        "Attempt to get first element of empty set");
186:            }
187:
188:            public static void setNoLast() throws NoSuchElementException {
189:                throw new NoSuchElementException(
190:                        "Attempt to get last element of empty set");
191:            }
192:
193:            public static void invalidSetBounds(Object low, Object high)
194:                    throws IllegalArgumentException {
195:                throw new IllegalArgumentException("Lower bound (" + low
196:                        + ") cannot be greater than upper bound (" + high + ")");
197:            }
198:
199:            public static void valueNotInSubRange(Object value)
200:                    throws IllegalArgumentException {
201:                throw new IllegalArgumentException(
202:                        "Attempt to add a value outside valid range: " + value);
203:            }
204:
205:            public static void invalidUpperBound(Object value)
206:                    throws IllegalArgumentException {
207:                throw new IllegalArgumentException(
208:                        "Upper bound is not in valid sub-range: " + value);
209:            }
210:
211:            public static void invalidLowerBound(Object value)
212:                    throws IllegalArgumentException {
213:                throw new IllegalArgumentException(
214:                        "Lower bound is not in valid sub-range: " + value);
215:            }
216:
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.