Source Code Cross Referenced for System.java in  » Ajax » GWT » com » google » gwt » emul » java » lang » 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 » Ajax » GWT » com.google.gwt.emul.java.lang 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Google Inc.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License. You may obtain a copy of
006:         * 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, WITHOUT
012:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013:         * License for the specific language governing permissions and limitations under
014:         * the License.
015:         */
016:        package java.lang;
017:
018:        import java.io.PrintStream;
019:
020:        /**
021:         * General-purpose low-level utility methods. GWT only supports a limited subset
022:         * of these methods due to browser limitations. Only the documented methods are
023:         * available.
024:         */
025:        public final class System {
026:
027:            /**
028:             * Does nothing in web mode. To get output in web mode, subclass PrintStream
029:             * and call {@link #setErr(PrintStream)}.
030:             */
031:            public static final PrintStream err = new PrintStream(null);
032:
033:            /**
034:             * Does nothing in web mode. To get output in web mode, subclass
035:             * {@link PrintStream} and call {@link #setOut(PrintStream)}.
036:             */
037:            public static final PrintStream out = new PrintStream(null);
038:
039:            public static void arraycopy(Object src, int srcOfs, Object dest,
040:                    int destOfs, int len) {
041:                if (src == null || dest == null) {
042:                    throw new NullPointerException();
043:                }
044:
045:                // TODO: use Class objects when Class.getComponentType() is supported.
046:                String srcTypeName = src.getClass().getName();
047:                String destTypeName = dest.getClass().getName();
048:                if (srcTypeName.charAt(0) != '['
049:                        || destTypeName.charAt(0) != '[') {
050:                    throw new ArrayStoreException("Must be array types");
051:                }
052:                if (srcTypeName.charAt(1) != destTypeName.charAt(1)) {
053:                    throw new ArrayStoreException("Array types must match");
054:                }
055:                int srclen = getArrayLength(src);
056:                int destlen = getArrayLength(dest);
057:                if (srcOfs < 0 || destOfs < 0 || len < 0
058:                        || srcOfs + len > srclen || destOfs + len > destlen) {
059:                    throw new IndexOutOfBoundsException();
060:                }
061:                /*
062:                 * If the arrays are not references or if they are exactly the same type, we
063:                 * can copy them in native code for speed. Otherwise, we have to copy them
064:                 * in Java so we get appropriate errors.
065:                 */
066:                if ((srcTypeName.charAt(1) == 'L' || srcTypeName.charAt(1) == '[')
067:                        && !srcTypeName.equals(destTypeName)) {
068:                    // copy in Java to make sure we get ArrayStoreExceptions if the values
069:                    // aren't compatible
070:                    Object[] srcArray = (Object[]) src;
071:                    Object[] destArray = (Object[]) dest;
072:                    if (src == dest && srcOfs < destOfs) {
073:                        // TODO(jat): how does backward copies handle failures in the middle?
074:                        // copy backwards to avoid destructive copies
075:                        srcOfs += len;
076:                        for (int destEnd = destOfs + len; destEnd-- > destOfs;) {
077:                            destArray[destEnd] = srcArray[--srcOfs];
078:                        }
079:                    } else {
080:                        for (int destEnd = destOfs + len; destOfs < destEnd;) {
081:                            destArray[destOfs++] = srcArray[srcOfs++];
082:                        }
083:                    }
084:                } else {
085:                    nativeArraycopy(src, srcOfs, dest, destOfs, len);
086:                }
087:            }
088:
089:            public static native long currentTimeMillis() /*-{
090:               return (new Date()).getTime();
091:             }-*/;
092:
093:            /**
094:             * Has no effect; just here for source compatibility.
095:             * 
096:             * @skip
097:             */
098:            public static native void gc() /*-{
099:             }-*/;
100:
101:            public static native int identityHashCode(Object o) /*-{
102:               return @com.google.gwt.core.client.Impl::getHashCode(Ljava/lang/Object;)(o);
103:             }-*/;
104:
105:            public static native void setErr(PrintStream err) /*-{
106:               @java.lang.System::err = err;
107:             }-*/;
108:
109:            public static native void setOut(PrintStream out) /*-{
110:               @java.lang.System::out = out;
111:             }-*/;
112:
113:            /**
114:             * Returns the length of an array via Javascript.
115:             */
116:            private static native int getArrayLength(Object array) /*-{
117:               return array.length;
118:             }-*/;
119:
120:            /**
121:             * Copy an array using native Javascript. The destination array must be a real
122:             * Java array (ie, already has the GWT type info on it).  No error checking is
123:             * performed -- the caller is expected to have verified everything first.
124:             * 
125:             * @param src source array for copy
126:             * @param srcOfs offset into source array
127:             * @param dest destination array for copy
128:             * @param destOfs offset into destination array
129:             * @param len number of elements to copy
130:             */
131:            private static native void nativeArraycopy(Object src, int srcOfs,
132:                    Object dest, int destOfs, int len) /*-{
133:               Array.prototype.splice.apply(dest, [destOfs, len].concat(src.slice(srcOfs, srcOfs + len)));
134:             }-*/;
135:
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.