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


001:        package tide.importtools;
002:
003:        import java.io.*;
004:        import java.util.*;
005:        import tide.project.ProjectSettings;
006:        import snow.utils.storage.*;
007:        import snow.utils.StringUtils;
008:
009:        /** Imports Schmortopf IDE projects.
010:         *  Contain some copied code to import schmortopf vector streams.
011:         */
012:        @SuppressWarnings("unchecked")
013:        public final class Schmortopf {
014:            public static String fileNameEnding = ".Schmortopf";
015:            private final Map<String, Object> map = new HashMap<String, Object>();
016:
017:            public Schmortopf(File projFile, ProjectSettings proj)
018:                    throws Exception {
019:                File tmpFile = new File(projFile.getAbsolutePath() + ".tmp");
020:                tmpFile.deleteOnExit();
021:                FileUtils.gunzip(projFile, tmpFile);
022:
023:                DataInputStream dis = new DataInputStream(new FileInputStream(
024:                        tmpFile));
025:                String fileVersion = dis.readUTF();
026:                Vector sv = receiveVector(dis);
027:
028:                Vector kvec = (Vector) sv.get(0);
029:                Vector vvec = (Vector) sv.get(1);
030:
031:                for (int i = 0; i < kvec.size(); i++) {
032:                    //debug: System.out.println(kvec.get(i)+": "+vvec.get(i));
033:                    map.put("" + kvec.get(i), vvec.get(i));
034:                }
035:
036:                if (proj != null) {
037:                    proj.setProjectName(StringUtils.removeAfterLastIncluded(
038:                            projFile.getName(), "."));
039:                    proj
040:                            .setSources_Home(new File(
041:                                    getProjProp("Project directory path (which contains all java files)")));
042:                    proj.setClasses_Home(new File(
043:                            getProjProp("Outputdirectory for class files")));
044:                    proj
045:                            .setMainSourceFile(new File(
046:                                    getProjProp("Java source file which contains the main() method")));
047:                    proj.setRuntimeArgs(getArgs("Arguments for the JVM"));
048:                    proj.setAppArgs(getArgs("Arguments passed to main()"));
049:                    // Schmortopf has no configurable compiler args :-(. No Xlint possible...
050:                    File javaC = new File(getProjProp("Java compiler pathname"));
051:                    if (javaC.exists()) {
052:                        proj
053:                                .setJava_Home(javaC.getParentFile()
054:                                        .getParentFile());
055:                    }
056:                    proj
057:                            .setExternalJars(getCP("Additional Jar libraries or directories"));
058:                    proj.setProperty("JAR_SRC_DESTINATION", ""
059:                            + map.get("jarFilePathName"));
060:                    proj.setProperty("keystore_password", ""
061:                            + map.get("keystore_password"));
062:                    proj.setProperty("keystore_field", ""
063:                            + map.get("keystore_field"));
064:
065:                }
066:                /*
067:                System.out.println("jarDest="+getProjProp("jarFilePathName"));
068:
069:                System.out.println("src="      +getProjProp("Project directory path (which contains all java files)"));
070:                System.out.println("dest_cl="  +getProjProp("Outputdirectory for class files"));
071:                System.out.println("java_home="+getProjProp("Java compiler pathname"));  // getParentFile()
072:
073:                System.out.println("main="+getProjProp("Java source file which contains the main() method"));
074:
075:                System.out.println("ma="+getArgs("Arguments passed to main()"));
076:
077:                System.out.println("ca="+getArgs("Arguments for the JVM"));
078:
079:                System.out.println("cp="+
080:                  getCP( "Additional Jar libraries or directories"));*/
081:            }
082:
083:            private String getArgs(String key) {
084:                Object ov = map.get(key);
085:                if (ov instanceof  Vector) {
086:                    Vector v = (Vector) ov;
087:                    int n = (Integer) v.get(6);
088:                    StringBuilder args = new StringBuilder();
089:                    for (int i = 7; i < 7 + n; i++) {
090:                        args.append(" " + v.get(i));
091:                    }
092:                    return args.toString().trim();
093:                }
094:                return "" + ov;
095:
096:            }
097:
098:            private List<File> getCP(String key) {
099:                List<File> lf = new ArrayList<File>();
100:                Object ov = map.get(key);
101:                if (ov instanceof  Vector) {
102:                    Vector v = (Vector) ov;
103:                    int n = (Integer) v.get(6);
104:                    for (int i = 7; i < 7 + n; i++) {
105:                        lf.add(new File("" + v.get(i)));
106:                    }
107:
108:                }
109:                return lf;
110:            }
111:
112:            private String getProjProp(String key) {
113:                Object ov = map.get(key);
114:                if (ov instanceof  Vector) {
115:                    return "" + ((Vector) ov).lastElement();
116:                }
117:
118:                return "" + ov;
119:            }
120:
121:            /**
122:             *   Reads a Vector, which was written using SendVector() from
123:             *   the inputstream.
124:             */
125:            private static final Vector receiveVector(final DataInputStream in)
126:                    throws Exception {
127:                int vectorSize = 0;
128:                // First read its size :
129:                vectorSize = in.readInt();
130:                // Then use the recursive worker method for the rest :
131:                final Vector theVector = new Vector();
132:                receiveVectorCoded(in, theVector, vectorSize); // works on theVector
133:                return theVector;
134:            }
135:
136:            private static int IsVectorContent = 1;
137:            private static int IsIntegerContent = 2;
138:            private static int IsBooleanContent = 3;
139:            private static int IsDoubleContent = 4;
140:            private static int IsStringContent = 5;
141:            private static int IsbyteArrayContent = 10;
142:            private static int IsintArrayContent = 11;
143:            private static int IsfloatArrayContent = 12;
144:            private static int IsdoubleArrayContent = 13;
145:            private static int IsLongContent = 14;
146:            private static int IsStringArrayContent = 15;
147:
148:            /**
149:             *  Recursive worker method for ReceiveVector()
150:             *  COPIED FROM SCHMORTOPF SOURCE
151:             */
152:            @SuppressWarnings("unchecked")
153:            private static void receiveVectorCoded(final DataInputStream in,
154:                    final Vector theVector, final int numberOfElements)
155:                    throws Exception {
156:                for (int elementIndex = 0; elementIndex < numberOfElements; elementIndex++) {
157:                    final int this ClassIndex = in.readInt(); // the data type keyword string
158:                    if (this ClassIndex == IsStringContent) {
159:                        String this Value = in.readUTF();
160:                        theVector.add(this Value);
161:                    } else if (this ClassIndex == IsIntegerContent) {
162:                        int this Value = in.readInt();
163:                        theVector.add(this Value);
164:                    } else if (this ClassIndex == IsLongContent) {
165:                        long this Value = in.readLong();
166:                        theVector.add(this Value);
167:                    } else if (this ClassIndex == IsDoubleContent) {
168:                        double this Value = in.readDouble();
169:                        theVector.add(this Value);
170:                    } else if (this ClassIndex == IsBooleanContent) {
171:                        boolean this Value = in.readBoolean();
172:                        theVector.add(this Value);
173:                    } else if (this ClassIndex == IsbyteArrayContent) {
174:                        int arraySize = in.readInt();
175:                        byte[] this Value = new byte[arraySize];
176:                        for (int index = 0; index < arraySize; index++) {
177:                            this Value[index] = in.readByte();
178:                        }
179:                        theVector.add(this Value);
180:                    } else if (this ClassIndex == IsintArrayContent) {
181:                        int arraySize = in.readInt();
182:                        int[] this Value = new int[arraySize];
183:                        for (int index = 0; index < arraySize; index++) {
184:                            this Value[index] = in.readInt();
185:                        }
186:                        theVector.add(this Value);
187:                    } else if (this ClassIndex == IsdoubleArrayContent) {
188:                        int arraySize = in.readInt();
189:                        double[] this Value = new double[arraySize];
190:                        for (int index = 0; index < arraySize; index++) {
191:                            this Value[index] = in.readDouble();
192:                        }
193:                        theVector.add(this Value);
194:                    } else if (this ClassIndex == IsfloatArrayContent) {
195:                        int arraySize = in.readInt();
196:                        float[] this Value = new float[arraySize];
197:                        for (int index = 0; index < arraySize; index++) {
198:                            this Value[index] = in.readFloat();
199:                        }
200:                        theVector.addElement(this Value);
201:                    } else if (this ClassIndex == IsStringArrayContent) {
202:                        int arraySize = in.readInt();
203:                        String[] this Value = new String[arraySize];
204:                        for (int index = 0; index < arraySize; index++) {
205:                            this Value[index] = in.readUTF();
206:                        }
207:                        theVector.addElement(this Value);
208:                    } else if (this ClassIndex == IsVectorContent) {
209:                        int this VectorSize = in.readInt();
210:                        // generate a new Vector and add it :
211:                        Vector this SubVector = new Vector(0, 1);
212:                        theVector.addElement(this SubVector);
213:                        // dive one recursion level deeper :
214:                        receiveVectorCoded(in, this SubVector, this VectorSize);
215:                    } else {
216:                        System.out
217:                                .println("*** FileUtilities.ReceiveVectorCoded error: Only Integer, Double and String types supported.");
218:                        System.out.println("*** The data had classindex = "
219:                                + this ClassIndex);
220:                        throw new Exception(
221:                                "FileUtilities.ReceiveVectorCoded error");
222:                    }
223:                }
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.