Source Code Cross Referenced for SalomeFileWrapper.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » api » data » 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 » Test Coverage » salome tmf » org.objectweb.salome_tmf.api.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * SalomeFile.java
003:         *
004:         * This file was auto-generated from WSDL
005:         * by the Apache Axis 1.4 Nov 19, 2006 (02:31:34 GMT+00:00) WSDL2Java emitter.
006:         */package org.objectweb.salome_tmf.api.data;
007:
008:        import java.io.BufferedOutputStream;
009:        import java.io.ByteArrayInputStream;
010:        import java.io.File;
011:        import java.io.FileInputStream;
012:        import java.io.FileOutputStream;
013:        import java.io.IOException;
014:        import java.io.InputStream;
015:        import java.util.Properties;
016:
017:        import org.objectweb.salome_tmf.api.ApiConstants;
018:
019:        public class SalomeFileWrapper implements  java.io.Serializable {
020:
021:            private byte[] content;
022:            private long lastModified;
023:            private int length;
024:            private String name;
025:            private String canonicalPath;
026:            private String absolutePath;
027:
028:            // Pour construire l'Url
029:            private String protocol;
030:            private String host;
031:            private int port;
032:            private String fileName;
033:
034:            public SalomeFileWrapper() {
035:            }
036:
037:            public SalomeFileWrapper(File file) throws IOException {
038:                if (file == null) {
039:                    return;
040:                }
041:                content = new byte[(int) file.length()];
042:                length = (int) file.length();
043:                lastModified = file.lastModified();
044:                name = file.getName();
045:                canonicalPath = file.getCanonicalPath().replace(
046:                        File.separatorChar, '/');
047:                absolutePath = file.getAbsolutePath().replace(
048:                        File.separatorChar, '/');
049:                protocol = file.toURL().getProtocol();
050:                host = file.toURL().getHost();
051:                port = file.toURL().getPort();
052:                fileName = file.toURL().getFile();
053:
054:                if (file.exists()) {
055:                    FileInputStream fis = new FileInputStream(file);
056:                    fis.read(content);
057:                }
058:            }
059:
060:            public File toFile() {
061:                return toFile(null);
062:                /*
063:                File f = null;
064:                f = new File(absolutePath);
065:                f.setLastModified(lastModified);
066:                
067:                try {
068:                	FileOutputStream fos = new FileOutputStream(f);
069:                	BufferedOutputStream bos = new BufferedOutputStream(fos);
070:                	
071:                	// Flux du fichier stocké dans la BdD 
072:                	bos.write(content);
073:                	
074:                	//	Fermeture des flux de données
075:                	bos.flush();
076:                	bos.close();
077:                } catch (Exception e) {
078:                	// TODO Auto-generated catch block
079:                	e.printStackTrace();
080:                }
081:                
082:                return f;
083:                 */
084:            }
085:
086:            public File toFile(String filePath) {
087:
088:                String path = filePath;
089:                File file = null;
090:
091:                String tmpDir;
092:                Properties sys = System.getProperties();
093:                String fs = sys.getProperty("file.separator");
094:
095:                if (path == null || path.equals("")) {
096:                    // Repertoire temporaire système
097:                    tmpDir = sys.getProperty("java.io.tmpdir");
098:                    tmpDir = tmpDir + fs + ApiConstants.PATH_TO_ADD_TO_TEMP
099:                            + fs;
100:                } else {
101:                    tmpDir = path;
102:                    if (!path.endsWith(fs)) {
103:                        tmpDir = tmpDir + fs;
104:                    }
105:
106:                }
107:                try {
108:                    file = new File(tmpDir + getName());
109:                    File fPath = new File(file.getCanonicalPath().substring(0,
110:                            file.getCanonicalPath().lastIndexOf(fs) + 1));
111:                    if (!fPath.exists()) {
112:                        fPath.mkdirs();
113:                    }
114:                    file.createNewFile();
115:
116:                    // Flux d'écriture sur le fichier
117:                    FileOutputStream fos = new FileOutputStream(file);
118:                    BufferedOutputStream bos = new BufferedOutputStream(fos);
119:
120:                    // Flux du fichier stocké dans la BdD 
121:                    bos.write(getContent());
122:
123:                    //	Fermeture des flux de données
124:                    bos.flush();
125:                    bos.close();
126:                } catch (Exception e) {
127:                    // TODO Auto-generated catch block
128:                    e.printStackTrace();
129:                }
130:                return file;
131:            }
132:
133:            /**
134:             * Gets the content value for this SalomeFile.
135:             * 
136:             * @return content
137:             */
138:            public byte[] getContent() {
139:                return content;
140:            }
141:
142:            /**
143:             * Gets the inputStream value for this SalomeFile.
144:             * 
145:             * @return inputStream
146:             */
147:            public InputStream openInputStream() {
148:                return new ByteArrayInputStream(content);
149:            }
150:
151:            /**
152:             * Gets the lastModified value for this SalomeFile.
153:             * 
154:             * @return lastModified
155:             */
156:            public long getLastModified() {
157:                return lastModified;
158:            }
159:
160:            /**
161:             * Gets the length value for this SalomeFile.
162:             * 
163:             * @return length
164:             */
165:            public int getLength() {
166:                return length;
167:            }
168:
169:            /**
170:             * Gets the name value for this SalomeFile.
171:             * 
172:             * @return name
173:             */
174:            public java.lang.String getName() {
175:                return name;
176:            }
177:
178:            public boolean exists() {
179:                return (content != null);
180:            }
181:
182:            public String getCanonicalPath() {
183:                return canonicalPath;
184:            }
185:
186:            public String getAbsolutePath() {
187:                return absolutePath;
188:            }
189:
190:            public String getFileName() {
191:                return fileName;
192:            }
193:
194:            public String getHost() {
195:                return host;
196:            }
197:
198:            public int getPort() {
199:                return port;
200:            }
201:
202:            public String getProtocol() {
203:                return protocol;
204:            }
205:
206:            public void setAbsolutePath(String absolutePath) {
207:                this .absolutePath = absolutePath;
208:            }
209:
210:            public void setCanonicalPath(String canonicalPath) {
211:                this .canonicalPath = canonicalPath;
212:            }
213:
214:            public void setContent(byte[] content) {
215:                this .content = content;
216:            }
217:
218:            public void setFileName(String fileName) {
219:                this .fileName = fileName;
220:            }
221:
222:            public void setHost(String host) {
223:                this .host = host;
224:            }
225:
226:            public void setLastModified(long lastModified) {
227:                this .lastModified = lastModified;
228:            }
229:
230:            public void setLength(int length) {
231:                this .length = length;
232:            }
233:
234:            public void setName(String name) {
235:                this .name = name;
236:            }
237:
238:            public void setPort(int port) {
239:                this .port = port;
240:            }
241:
242:            public void setProtocol(String protocol) {
243:                this.protocol = protocol;
244:            }
245:
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.