Source Code Cross Referenced for Common.java in  » IDE » Schmortopf » Language » 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 » IDE » Schmortopf » Language 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package Language;
002:
003:        import java.util.*;
004:        import java.util.zip.*;
005:        import java.io.*;
006:        import javax.swing.table.*;
007:
008:        import Schmortopf.Utility.Vectorizable;
009:        import Schmortopf.Utility.io.FileUtilities;
010:
011:        public class Common {
012:
013:            private Common() {
014:
015:            } // Constructor
016:
017:            public static void StoreVectorToFile(File f, Vector v)
018:                    throws Exception {
019:                FileOutputStream fos = null;
020:                if (f.exists()) {
021:                    if (!f.delete())
022:                        throw new Exception("file " + f
023:                                + " already exists and cannot be deleted");
024:                } else {
025:                    File parent = f.getParentFile();
026:                    if (!parent.exists())
027:                        parent.mkdirs();
028:                }
029:                System.out.println("saving vector in " + f.getAbsolutePath());
030:                try {
031:                    fos = new FileOutputStream(f);
032:                    GZIPOutputStream zipOut = new GZIPOutputStream(fos);
033:                    DataOutputStream dos = new DataOutputStream(zipOut);
034:                    FileUtilities.SendVector(v, dos, null, 0);
035:                    dos.flush();
036:                    dos.close();
037:                } catch (Exception e) {
038:                    throw e;
039:                } finally {
040:                    if (fos != null)
041:                        fos.close();
042:                }
043:            }
044:
045:            public static Vector ReadVectorFromFile(File f) throws Exception {
046:                FileInputStream fis = null;
047:                try {
048:                    fis = new FileInputStream(f);
049:                    GZIPInputStream zipIn = new GZIPInputStream(fis);
050:                    DataInputStream dis = new DataInputStream(zipIn);
051:                    return FileUtilities.ReceiveVector(dis, null, 0);
052:                } catch (Exception e) {
053:                    throw e;
054:                } finally {
055:                    if (fis != null)
056:                        fis.close();
057:                }
058:            }
059:
060:            /** @return the number of spaces at the begining of the string
061:              this is used to avoid translating "hello" and " hello "
062:             */
063:            public static int GetNumberOfSpacesAtBegining(String s) {
064:                for (int i = 0; i < s.length(); i++) {
065:                    if (s.charAt(i) != ' ')
066:                        return i;
067:                }
068:                return s.length();
069:            }
070:
071:            /** @return the number of spaces at the end of the string
072:             */
073:            public static int GetNumberOfSpacesAtEnd(String s) {
074:                for (int i = 0; i < s.length(); i++) {
075:                    if (s.charAt(s.length() - i - 1) != ' ')
076:                        return i;
077:                }
078:                return s.length();
079:            }
080:
081:            /** @return 0 if no arguments are detected in the sentence (%)
082:                 1 if one % is present
083:                 2 if %1 and %2 are present
084:             */
085:            public static int GetNumberOfParametersInSentence(String sentence)
086:                    throws Exception {
087:
088:                if (sentence.indexOf("%2") != -1) {
089:                    if (sentence.indexOf("%1") == -1) {
090:                        throw new Exception(
091:                                "Sentence has only argument %2, %1 is missing ?");
092:                    }
093:                    return 2;
094:                }
095:                if (sentence.indexOf("%1") != -1) {
096:                    if (sentence.indexOf("%2") == -1) {
097:                        throw new Exception(
098:                                "Sentence has only argument %1, %2 is missing ?");
099:                    }
100:                    return 2;
101:                }
102:
103:                if (sentence.indexOf("%") != -1) {
104:                    return 1;
105:                }
106:
107:                return 0;
108:            }
109:
110:            /**  Language/hello.java =>  Language.hello
111:             */
112:            public static String ConvertPathToJavaClassPathSyntax(String _path) {
113:                String path = _path;
114:                // 1) supperss .java
115:                if (path.endsWith(".java"))
116:                    path = path.substring(0, path.length() - 5);
117:
118:                // 2) convert \ to .
119:                int pos = -1;
120:                while ((pos = path.indexOf("\\")) != -1) {
121:                    path = path.substring(0, pos) + "."
122:                            + path.substring(pos + 1);
123:                }
124:
125:                return path;
126:            }
127:
128:        } // Common
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.