Source Code Cross Referenced for Utilities.java in  » IDE » J » org » armedbear » lisp » 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
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE » J » org.armedbear.lisp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Utilities.java
003:         *
004:         * Copyright (C) 2003-2004 Peter Graves
005:         * $Id: Utilities.java,v 1.8 2004/01/26 00:30:12 piso Exp $
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or (at your option) any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         */
021:
022:        package org.armedbear.lisp;
023:
024:        import java.io.File;
025:        import java.io.IOException;
026:
027:        public final class Utilities extends Lisp {
028:            private static final boolean isPlatformUnix;
029:            private static final boolean isPlatformWindows;
030:
031:            static {
032:                String osName = System.getProperty("os.name");
033:                isPlatformUnix = osName.startsWith("Linux")
034:                        || osName.startsWith("Mac OS X")
035:                        || osName.startsWith("Solaris")
036:                        || osName.startsWith("SunOS")
037:                        || osName.startsWith("AIX");
038:                isPlatformWindows = osName.startsWith("Windows");
039:            }
040:
041:            public static boolean isPlatformUnix() {
042:                return isPlatformUnix;
043:            }
044:
045:            public static boolean isPlatformWindows() {
046:                return isPlatformWindows;
047:            }
048:
049:            public static boolean isFilenameAbsolute(String filename) {
050:                final int length = filename.length();
051:                if (length > 0) {
052:                    char c0 = filename.charAt(0);
053:                    if (c0 == '\\' || c0 == '/')
054:                        return true;
055:                    if (length > 2) {
056:                        if (isPlatformWindows()) {
057:                            // Check for drive letter.
058:                            char c1 = filename.charAt(1);
059:                            if (c1 == ':') {
060:                                if (c0 >= 'a' && c0 <= 'z')
061:                                    return true;
062:                                if (c0 >= 'A' && c0 <= 'Z')
063:                                    return true;
064:                            }
065:                        } else {
066:                            // Unix.
067:                            if (filename.equals("~")
068:                                    || filename.startsWith("~/"))
069:                                return true;
070:                        }
071:                    }
072:                }
073:                return false;
074:            }
075:
076:            public static File getFile(Pathname pathname)
077:                    throws ConditionThrowable {
078:                Pathname defaultPathname = Pathname
079:                        .coerceToPathname(_DEFAULT_PATHNAME_DEFAULTS_
080:                                .symbolValue());
081:                Pathname merged = Pathname.mergePathnames(pathname,
082:                        defaultPathname, NIL);
083:                String namestring = merged.getNamestring();
084:                if (namestring != null)
085:                    return new File(namestring);
086:                signal(new SimpleError("Pathname has no namestring: " + merged));
087:                // Not reached.
088:                return null;
089:            }
090:
091:            public static Pathname getDirectoryPathname(File file)
092:                    throws ConditionThrowable {
093:                try {
094:                    String namestring = file.getCanonicalPath();
095:                    if (namestring != null && namestring.length() > 0) {
096:                        if (namestring.charAt(namestring.length() - 1) != File.separatorChar)
097:                            namestring = namestring.concat(File.separator);
098:                    }
099:                    return new Pathname(namestring);
100:                } catch (IOException e) {
101:                    signal(new LispError(e.getMessage()));
102:                    // Not reached.
103:                    return null;
104:                }
105:            }
106:
107:            public static final char toUpperCase(char c) {
108:                if (c < 128)
109:                    return UPPER_CASE_CHARS[c];
110:                return Character.toUpperCase(c);
111:            }
112:
113:            private static final char[] UPPER_CASE_CHARS = new char[128];
114:
115:            static {
116:                for (int i = UPPER_CASE_CHARS.length; i-- > 0;)
117:                    UPPER_CASE_CHARS[i] = Character.toUpperCase((char) i);
118:            }
119:
120:            public static final char toLowerCase(char c) {
121:                if (c < 128)
122:                    return LOWER_CASE_CHARS[c];
123:                return Character.toLowerCase(c);
124:            }
125:
126:            private static final char[] LOWER_CASE_CHARS = new char[128];
127:
128:            static {
129:                for (int i = LOWER_CASE_CHARS.length; i-- > 0;)
130:                    LOWER_CASE_CHARS[i] = Character.toLowerCase((char) i);
131:            }
132:        }
www.java2java.com | Contact Us
Copyright 2010 - 2030 Java Source and Support. All rights reserved.
All other trademarks are property of their respective owners.