Source Code Cross Referenced for AntNodeReader.java in  » J2EE » enhydra-IDE-plugin » org » enhydra » kelp » ant » node » 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 » J2EE » enhydra IDE plugin » org.enhydra.kelp.ant.node 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.kelp.ant.node;
002:
003:        //Kelp
004:        import org.enhydra.kelp.common.node.OtterFileNode;
005:        import org.enhydra.kelp.common.node.OtterDocumentNode;
006:        import org.enhydra.kelp.common.node.OtterNode;
007:        import org.enhydra.kelp.common.node.OtterFolderNode; //ToolBox
008:        import org.enhydra.tool.common.PathHandle; //Java
009:        import java.io.File;
010:        import java.util.ArrayList;
011:        import org.enhydra.kelp.common.node.OtterTextFileNode;
012:
013:        /**
014:         * <p>Title: </p>
015:         * <p>Description: This class is used by AntProject. It read all files from
016:         * resource directory using extension filtering and creates Document nodes
017:         * array. All necessary data are provided by AntProject.</p>
018:         * <p>Copyright: Copyright (c) 2003</p>
019:         * <p>Company: </p>
020:         * @author Damir Milovic
021:         * @version 1.0
022:         */
023:
024:        public class AntNodeReader {
025:            private ArrayList list = new ArrayList();
026:            //private OtterProject otterProject = null;
027:            private AntProject project = null;
028:            private AntNodeFactory nodeFactory = null;
029:
030:            public AntNodeReader(AntProject p) {
031:                project = p;
032:                nodeFactory = (AntNodeFactory) project.getNodeFactory();
033:            }
034:
035:            /**
036:             * Read all files from resource directory and create Document nodes using
037:             * extension filtering.
038:             * @param rootDir root directory.
039:             * @return array of all document nodes used for xml compiling.
040:             */
041:            public OtterDocumentNode[] getDocumentNodes(String rootDir) {
042:                OtterDocumentNode[] nodes = new OtterDocumentNode[0];
043:                list.clear();
044:                //Read resources dir
045:                PathHandle resourcesPathHandle = PathHandle
046:                        .createPathHandle(rootDir);
047:                OtterFolderNode rootFolder = nodeFactory.createFolderNode(
048:                        project, resourcesPathHandle.getPath());
049:                String[] docTypes = project.getDocTypes();
050:                readDocument(rootFolder, docTypes); //fill the list
051:                nodes = new OtterDocumentNode[list.size()];
052:                nodes = (OtterDocumentNode[]) list.toArray(nodes);
053:                list.clear();
054:                return nodes;
055:
056:            }
057:
058:            /**
059:             * Read all files from root directory and create TextFile nodes
060:             * @param rootDir root directory.
061:             * @return array of all text files inside rootDir
062:             */
063:            public OtterTextFileNode[] getTextFileNodes(String rootDir) {
064:                OtterTextFileNode[] nodes = new OtterTextFileNode[0];
065:                list.clear();
066:                PathHandle rootPathHandle = PathHandle
067:                        .createPathHandle(rootDir);
068:                OtterFolderNode rootFolder = nodeFactory.createFolderNode(
069:                        project, rootPathHandle.getPath());
070:                readTextFile(rootFolder);
071:                nodes = new OtterTextFileNode[list.size()];
072:                nodes = (OtterTextFileNode[]) list.toArray(nodes);
073:                list.clear();
074:                return nodes;
075:            }
076:
077:            private void readDocument(OtterNode container, String[] extFilters) {
078:
079:                PathHandle current = PathHandle
080:                        .createPathHandle(((OtterFileNode) container)
081:                                .getFilePath());
082:
083:                if (container instanceof  OtterFolderNode) {
084:                    //Read all files inside this directory
085:                    File directory = current.getFile();
086:                    File[] files = directory.listFiles(); //folders or files
087:                    for (int i = 0; i < files.length; i++) {
088:                        //Create node and read it
089:                        File newFile = files[i];
090:                        if (newFile.isDirectory()) { //Create OtterFolderNode
091:                            readDocument(nodeFactory.createFolderNode(
092:                                    container, newFile.getPath()), extFilters);
093:                        } else { //Create OtterDocumentNode
094:                            readDocument(nodeFactory.createDocumentNode(
095:                                    container, newFile.getPath()), extFilters);
096:                        }
097:                    }
098:                } else if (container instanceof  OtterDocumentNode) {
099:                    if (current.getFile().exists()
100:                            && current.hasExtension(extFilters)) {
101:                        OtterDocumentNode docNode = null;
102:                        docNode = nodeFactory.createDocumentNode(container,
103:                                current.getFile().getAbsolutePath());
104:                        checkSelected(docNode);
105:                        list.add(docNode);
106:                    }
107:                }
108:            }
109:
110:            //FIXME should use extensions filter to resolve text files !?
111:            private void readTextFile(OtterNode container) {
112:                PathHandle current = PathHandle
113:                        .createPathHandle(((OtterFileNode) container)
114:                                .getFilePath());
115:
116:                if (container instanceof  OtterFolderNode) {
117:                    //Read all files inside this directory
118:                    File directory = current.getFile();
119:                    File[] files = directory.listFiles(); //folders or files
120:                    for (int i = 0; i < files.length; i++) {
121:                        //Create node and read it
122:                        File newFile = files[i];
123:                        if (newFile.isDirectory()) { //Create OtterFolderNode
124:
125:                            readTextFile(nodeFactory.createFolderNode(
126:                                    container, newFile.getPath()));
127:                        } else { //Create OtterDocumentNode
128:                            readTextFile(nodeFactory.createTextFileNode(
129:                                    container, newFile.getPath()));
130:                        }
131:                    }
132:                } else if (container instanceof  OtterTextFileNode) {
133:                    if (current.getFile().exists()) {
134:                        OtterTextFileNode textFileNode = null;
135:                        textFileNode = nodeFactory.createTextFileNode(
136:                                container, current.getFile().getAbsolutePath());
137:                        list.add(textFileNode);
138:                    }
139:                }
140:
141:            }
142:
143:            private void checkSelected(OtterDocumentNode docNode) {
144:                if (project.getProperty(AntProject.XMLC_INCLUDES)
145:                        .equalsIgnoreCase(AntProject.XMLC_RESOURCES_ALL)) {
146:                    //All documents need to compile
147:                    docNode.setSelected(true);
148:                } else {
149:                    //Just selected documents need to compile
150:                    OtterDocumentNode[] selectedDoc = project
151:                            .getSelectedDocuments();
152:                    docNode.setSelected(false);
153:                    //File docFile = new File(docNode.getFilePath());
154:                    //File selectedFile = null;
155:                    String docPath = docNode.getFilePath().replace('\\', '/');
156:                    for (int i = 0; i < selectedDoc.length; i++) {
157:                        String selectedPath = selectedDoc[i].getFilePath()
158:                                .replace('\\', '/');
159:                        if (docPath.equalsIgnoreCase(selectedPath)) {
160:                            //found selected
161:                            docNode.setSelected(true);
162:                            break;
163:                        }
164:                    }
165:                }
166:
167:            }
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.