Source Code Cross Referenced for FileListing.java in  » Workflow-Engines » Dalma » com » sun » jbi » binding » file » util » 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 » Workflow Engines » Dalma » com.sun.jbi.binding.file.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright (c) 2004-2005 Sun Microsystems Inc., All Rights Reserved.
002:
003:        /*
004:         * FileListing.java
005:         *
006:         * SUN PROPRIETARY/CONFIDENTIAL.
007:         * This software is the proprietary information of Sun Microsystems, Inc.
008:         * Use is subject to license terms.
009:         *
010:         */
011:        package com.sun.jbi.binding.file.util;
012:
013:        import java.io.File;
014:        import java.io.FilenameFilter;
015:
016:        import java.util.ArrayList;
017:        import java.util.Arrays;
018:        import java.util.Iterator;
019:        import java.util.List;
020:        import java.util.logging.Logger;
021:
022:        /**
023:         * Helper class for listing files / folders.
024:         *
025:         * @author Sun Microsystems, Inc.
026:         */
027:        public final class FileListing {
028:            /**
029:             * Flag to indicate recursive listing.
030:             */
031:            private static boolean sRecurse = false;
032:
033:            /**
034:             * Filter class to be used.
035:             */
036:            private static FilenameFilter sFilter = null;
037:
038:            /**
039:             * Logger object.
040:             */
041:            private static Logger sLog = Logger
042:                    .getLogger("com.sun.jbi.binding.file.util");
043:
044:            /**
045:             * Gets the list of files in a folder.
046:             *
047:             * @param aDir folder name.
048:             * @param bRecurse will recurse if true.
049:             * @param aFilter filname filter.
050:             *
051:             * @return List of file names.
052:             */
053:            public static synchronized List getFileListing(File aDir,
054:                    boolean bRecurse, FilenameFilter aFilter) {
055:                sRecurse = bRecurse;
056:                sFilter = aFilter;
057:
058:                if ((aDir == null) || (aDir.getName().trim().equals(""))) {
059:                    sLog.severe("Directory is null");
060:
061:                    return null;
062:                }
063:
064:                return getListing(aDir);
065:            }
066:
067:            /**
068:             * Recursively walk a directory tree and return a List of all Files found;
069:             * the List is sorted using File.compareTo.
070:             *
071:             * @param aDir is a valid directory, which can be read.
072:             *
073:             * @return array of folder names
074:             */
075:            public static synchronized String[] getFolderListing(File aDir) {
076:                File[] dirs = aDir.listFiles();
077:
078:                if (dirs == null) {
079:                    return null;
080:                }
081:
082:                List filesDirs = Arrays.asList(dirs);
083:
084:                if (filesDirs == null) {
085:                    return null;
086:                }
087:
088:                Iterator filesIter = filesDirs.iterator();
089:                String[] result = new String[filesDirs.size()];
090:                File file = null;
091:                int counter = 0;
092:
093:                while (filesIter.hasNext()) {
094:                    file = (File) filesIter.next();
095:
096:                    if (!file.isFile()) {
097:                        result[counter] = file.getAbsolutePath();
098:                        counter++;
099:                    }
100:                }
101:
102:                return result;
103:            }
104:
105:            /**
106:             * Util method to get the list of folders.
107:             *
108:             * @param aDir folder name for which contents have to be listed.
109:             *
110:             * @return array of folder names.
111:             */
112:            public static synchronized String[] getFolderNameListing(File aDir) {
113:                File[] dirs = aDir.listFiles();
114:
115:                if (dirs == null) {
116:                    return null;
117:                }
118:
119:                List filesDirs = Arrays.asList(dirs);
120:
121:                if (filesDirs == null) {
122:                    return null;
123:                }
124:
125:                Iterator filesIter = filesDirs.iterator();
126:                String[] result = new String[filesDirs.size()];
127:                File file = null;
128:                int counter = 0;
129:
130:                while (filesIter.hasNext()) {
131:                    file = (File) filesIter.next();
132:
133:                    if (!file.isFile()) {
134:                        result[counter] = file.getName();
135:                        counter++;
136:                    }
137:                }
138:
139:                return result;
140:            }
141:
142:            /**
143:             * Returns a WSDL file from the deployment artifact.
144:             *
145:             * @param path Path of the ASA
146:             *
147:             * @return WSDL file path
148:             */
149:            public static String getWSDLFile(String path) {
150:                InputFileFilter myFilter = new InputFileFilter();
151:                myFilter.setFilterexpression(".*\\.wsdl");
152:
153:                String wsdlfile = null;
154:
155:                try {
156:                    File dir = new File(path);
157:                    File[] filesAndDirs = dir.listFiles(myFilter);
158:
159:                    if (filesAndDirs == null) {
160:                        wsdlfile = null;
161:                    } else {
162:                        if (filesAndDirs.length > 0) {
163:                            wsdlfile = filesAndDirs[0].getAbsolutePath();
164:                        }
165:                    }
166:                } catch (Exception e) {
167:                    ;
168:                }
169:
170:                return wsdlfile;
171:            }
172:
173:            /**
174:             * Returns an XML file path from the deployment artifact.
175:             *
176:             * @param path path of the deployment artifact.
177:             *
178:             * @return XML file path.
179:             */
180:            public static String getXMLFile(String path) {
181:                InputFileFilter myFilter = new InputFileFilter();
182:                myFilter.setFilterexpression(".*\\.xml");
183:
184:                String xmlfile = null;
185:
186:                try {
187:                    File dir = new File(path);
188:                    File[] filesAndDirs = dir.listFiles(myFilter);
189:
190:                    if (filesAndDirs == null) {
191:                        xmlfile = null;
192:                    } else {
193:                        if (filesAndDirs.length > 0) {
194:                            xmlfile = filesAndDirs[0].getAbsolutePath();
195:                        }
196:                    }
197:                } catch (Exception e) {
198:                    ;
199:                }
200:
201:                return xmlfile;
202:            }
203:
204:            /**
205:             * Recursively walk a directory tree and return a List of all Files found;
206:             * the List is sorted using File.compareTo.
207:             *
208:             * @param aDir is a valid directory, which can be read.
209:             *
210:             * @return list of files.
211:             */
212:            private static List getListing(File aDir) {
213:                List result = new ArrayList();
214:                File[] filesAndDirs = aDir.listFiles(sFilter);
215:
216:                if (filesAndDirs == null) {
217:                    return null;
218:                }
219:
220:                List filesDirs = Arrays.asList(filesAndDirs);
221:
222:                if (filesDirs == null) {
223:                    return null;
224:                }
225:
226:                Iterator filesIter = filesDirs.iterator();
227:                File file = null;
228:
229:                while (filesIter.hasNext()) {
230:                    file = (File) filesIter.next();
231:
232:                    if (!file.isFile()) {
233:                        if (sRecurse) {
234:                            List deeperList = getListing(file);
235:                            result.addAll(deeperList);
236:                        }
237:                    } else {
238:                        if (FileBindingUtil.canAdd(file)) {
239:                            result.add(file);
240:                        }
241:
242:                        if (result.size() >= ConfigData.BATCH_SIZE) {
243:                            return result;
244:                        }
245:                    }
246:                }
247:
248:                return result;
249:            }
250:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.