Source Code Cross Referenced for Util.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » nio » 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 » Apache Harmony Java SE » org package » org.apache.harmony.nio 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Licensed to the Apache Software Foundation (ASF) under one or more
002:         * contributor license agreements.  See the NOTICE file distributed with
003:         * this work for additional information regarding copyright ownership.
004:         * The ASF licenses this file to You under the Apache License, Version 2.0
005:         * (the "License"); you may not use this file except in compliance with
006:         * the License.  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:
017:        package org.apache.harmony.nio;
018:
019:        import org.apache.harmony.nio.internal.nls.Messages;
020:
021:        /*
022:         * Static methods. Used by io and nio packages.
023:         * 
024:         */
025:        public final class Util {
026:
027:            // -------------------------------------------------------------------
028:            // Constructor
029:            // -------------------------------------------------------------------
030:
031:            /*
032:             * No instance.
033:             */
034:            private Util() {
035:                super ();
036:            }
037:
038:            // -------------------------------------------------------------------
039:            // Routine methods.
040:            // -------------------------------------------------------------------
041:
042:            /*
043:             * Check array bounds method for methods like doSomething(Object[], offset,
044:             * length). Exception throws order is IndexOutOfBoundsException for negative
045:             * index, NullPointerException for null array, IndexOutOfBoundsException for
046:             * offset+length > array.length
047:             */
048:            public static void assertArrayIndex(Object[] array, int offset,
049:                    int length) {
050:                if (offset < 0 || length < 0) {
051:                    // nio.05=Negative index specified
052:                    throw new IndexOutOfBoundsException(Messages
053:                            .getString("nio.05")); //$NON-NLS-1$
054:                }
055:                if ((long) offset + (long) length > array.length) {
056:                    // nio.04=Size mismatch
057:                    throw new IndexOutOfBoundsException(Messages
058:                            .getString("nio.04")); //$NON-NLS-1$
059:                }
060:            }
061:
062:            public static void assertArrayIndex(boolean[] array, int offset,
063:                    int length) {
064:                if (offset < 0 || length < 0) {
065:                    // nio.05=Negative index specified
066:                    throw new IndexOutOfBoundsException(Messages
067:                            .getString("nio.05")); //$NON-NLS-1$
068:                }
069:                if ((long) offset + (long) length > array.length) {
070:                    // nio.04=Size mismatch
071:                    throw new IndexOutOfBoundsException(Messages
072:                            .getString("nio.04")); //$NON-NLS-1$
073:                }
074:            }
075:
076:            public static void assertArrayIndex(byte[] array, int offset,
077:                    int length) {
078:                if (offset < 0 || length < 0) {
079:                    // nio.05=Negative index specified
080:                    throw new IndexOutOfBoundsException(Messages
081:                            .getString("nio.05")); //$NON-NLS-1$
082:                }
083:                if ((long) offset + (long) length > array.length) {
084:                    // nio.04=Size mismatch
085:                    throw new IndexOutOfBoundsException(Messages
086:                            .getString("nio.04")); //$NON-NLS-1$
087:                }
088:            }
089:
090:            public static void assertArrayIndex(short[] array, int offset,
091:                    int length) {
092:                if (offset < 0 || length < 0) {
093:                    // nio.05=Negative index specified
094:                    throw new IndexOutOfBoundsException(Messages
095:                            .getString("nio.05")); //$NON-NLS-1$
096:                }
097:                if ((long) offset + (long) length > array.length) {
098:                    // nio.04=Size mismatch
099:                    throw new IndexOutOfBoundsException(Messages
100:                            .getString("nio.04")); //$NON-NLS-1$
101:                }
102:            }
103:
104:            public static void assertArrayIndex(int[] array, int offset,
105:                    int length) {
106:                if (offset < 0 || length < 0) {
107:                    // nio.05=Negative index specified
108:                    throw new IndexOutOfBoundsException(Messages
109:                            .getString("nio.05")); //$NON-NLS-1$
110:                }
111:                if ((long) offset + (long) length > array.length) {
112:                    // nio.04=Size mismatch
113:                    throw new IndexOutOfBoundsException(Messages
114:                            .getString("nio.04")); //$NON-NLS-1$
115:                }
116:            }
117:
118:            public static void assertArrayIndex(long[] array, int offset,
119:                    int length) {
120:                if (offset < 0 || length < 0) {
121:                    // nio.05=Negative index specified
122:                    throw new IndexOutOfBoundsException(Messages
123:                            .getString("nio.05")); //$NON-NLS-1$
124:                }
125:                if ((long) offset + (long) length > array.length) {
126:                    // nio.04=Size mismatch
127:                    throw new IndexOutOfBoundsException(Messages
128:                            .getString("nio.04")); //$NON-NLS-1$
129:                }
130:            }
131:
132:            public static void assertArrayIndex(float[] array, int offset,
133:                    int length) {
134:                if (offset < 0 || length < 0) {
135:                    // nio.05=Negative index specified
136:                    throw new IndexOutOfBoundsException(Messages
137:                            .getString("nio.05")); //$NON-NLS-1$
138:                }
139:                if ((long) offset + (long) length > array.length) {
140:                    // nio.04=Size mismatch
141:                    throw new IndexOutOfBoundsException(Messages
142:                            .getString("nio.04")); //$NON-NLS-1$
143:                }
144:            }
145:
146:            public static void assertArrayIndex(double[] array, int offset,
147:                    int length) {
148:                if (offset < 0 || length < 0) {
149:                    // nio.05=Negative index specified
150:                    throw new IndexOutOfBoundsException(Messages
151:                            .getString("nio.05")); //$NON-NLS-1$
152:                }
153:                if ((long) offset + (long) length > array.length) {
154:                    // nio.04=Size mismatch
155:                    throw new IndexOutOfBoundsException(Messages
156:                            .getString("nio.04")); //$NON-NLS-1$
157:                }
158:            }
159:
160:            public static void assertArrayIndex(char[] array, int offset,
161:                    int length) {
162:                if (offset < 0 || length < 0) {
163:                    // nio.05=Negative index specified
164:                    throw new IndexOutOfBoundsException(Messages
165:                            .getString("nio.05")); //$NON-NLS-1$
166:                }
167:                if ((long) offset + (long) length > array.length) {
168:                    // nio.04=Size mismatch
169:                    throw new IndexOutOfBoundsException(Messages
170:                            .getString("nio.04")); //$NON-NLS-1$
171:                }
172:            }
173:
174:            /*
175:             * Check array bounds method for methods like doSomething(Object[], offset,
176:             * length). Exception throws order is IndexOutOfBoundsException for negative
177:             * index, IndexOutOfBoundsException for offset+length > array.length
178:             */
179:            public static void assertArrayIndex(int arrayLength, int offset,
180:                    int length) {
181:                if (offset < 0 || length < 0) {
182:                    // nio.05=Negative index specified
183:                    throw new IndexOutOfBoundsException(Messages
184:                            .getString("nio.05")); //$NON-NLS-1$
185:                }
186:                if ((long) offset + (long) length > arrayLength) {
187:                    // nio.04=Size mismatch
188:                    throw new IndexOutOfBoundsException(Messages
189:                            .getString("nio.04")); //$NON-NLS-1$
190:                }
191:            }
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.