Source Code Cross Referenced for AntImport.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 org.xml.sax.helpers.*;
007:        import org.xml.sax.*;
008:
009:        /** A very easy ant import, just reads the some project paths
010:         *   TODO: import ext libs... classes...
011:         */
012:        public final class AntImport extends DefaultHandler {
013:            public static String fileNameEnding = ".xml"; // normally build.xml
014:            final File baseDir;
015:
016:            final ProjectSettings proj;
017:            final private List<File> libs = new ArrayList<File>();
018:            final private Map<String, String> properties = new HashMap<String, String>();
019:
020:            public AntImport(File propFile, ProjectSettings proj)
021:                    throws Exception {
022:                super ();
023:
024:                this .proj = proj;
025:                this .baseDir = propFile.getParentFile();
026:
027:                System.out
028:                        .println("Importing ant project " + baseDir.getName());
029:                if (proj != null) {
030:                    proj.setProjectName(baseDir.getName());
031:                }
032:
033:                XMLReader xr = XMLReaderFactory.createXMLReader();
034:                xr.setContentHandler(this );
035:                xr.setErrorHandler(this );
036:
037:                // Important: since 1.6, crashes if inputsource made with string path (unknown protocol "c") !!
038:                xr.parse(new InputSource(new FileInputStream(propFile)));
039:
040:                System.out.println("\nPROPS=" + properties);
041:                System.out.println("\nKEYS=" + properties.keySet());
042:
043:                if (proj != null) {
044:                    proj.setSources_Home(new File(this 
045:                            .getResolvedPropValue("src")));
046:                }
047:                System.out.println("Src=" + this .getResolvedPropValue("src"));
048:                System.out.println("out=" + this .getResolvedPropValue("out"));
049:
050:            }
051:
052:            @Override
053:            public void startElement(String uri, String name, String qName,
054:                    Attributes atts) {
055:
056:                if (qName.equals("property") && "".equals(uri)) {
057:                    //System.out.println("Start element: {" + uri + "} " + name);
058:                    // top level props
059:                    /*for(int i=0; i<atts.getLength(); i++)
060:                    {
061:                       System.out.println("PROPERTY  "+atts.getLocalName(i)+" = "+atts.getValue(i));
062:                    }*/
063:
064:                    if (atts.getValue("name") != null) {
065:                        properties.put(atts.getValue("name"), atts
066:                                .getValue("value"));
067:                    } else {
068:                        System.out.println("### Start element: {" + uri + "} "
069:                                + name);
070:                        for (int i = 0; i < atts.getLength(); i++) {
071:                            System.out.println("   PROPERTY  "
072:                                    + atts.getLocalName(i) + " = "
073:                                    + atts.getValue(i));
074:                        }
075:                    }
076:                } else {
077:                    if (qName.equals("project")) {
078:                        if (proj != null)
079:                            proj.setProjectName(atts.getValue("name"));
080:                        System.out.println("ANT Project name = "
081:                                + atts.getValue("name"));
082:                    } else {
083:                        System.out.println("Start element: {" + uri + "} "
084:                                + name + " (" + qName + ")");
085:                        for (int i = 0; i < atts.getLength(); i++) {
086:                            System.out.println("  ATTRS:  "
087:                                    + atts.getLocalName(i) + " = "
088:                                    + atts.getValue(i));
089:                        }
090:                    }
091:                }
092:
093:                /*if(qName.equals("classpathentry"))
094:                {
095:                  if( atts.getValue("kind").equals("src"))
096:                  {
097:                     System.out.println("### Source path = "+getFile(atts.getValue("path")));
098:                     if(proj!=null)
099:                     {
100:                        proj.setSources_Home( getFile(atts.getValue("path")) );
101:                     }
102:                  }
103:
104:                  if( atts.getValue("kind").equals("lib"))
105:                  {
106:                     File path = getFile(atts.getValue("path"));
107:                     libs.add( path );
108:                  }
109:
110:                  if( atts.getValue("kind").equals("output"))
111:                  {
112:                     if(proj!=null)
113:                     {
114:                       proj.setClasses_Home( new File(atts.getValue("path")) );
115:                     }
116:                  }
117:
118:                }*/
119:
120:            }
121:
122:            @Override
123:            public void endElement(String uri, String name, String qName) {
124:                /* if ("".equals (uri))
125:                    System.out.println("End element: " + qName);
126:                 else
127:                    System.out.println("End element:   {" + uri + "}" + name);
128:                 */
129:            }
130:
131:            @Override
132:            public void characters(char[] ch, int start, int length) {
133:
134:                //System.out.println("chars: '"+new String(ch, start, length)+"'");
135:            }
136:
137:            @Override
138:            public void endDocument() {
139:                System.out.println("Classpath=" + libs);
140:                if (proj != null) {
141:                    proj.setExternalJars(libs);
142:                }
143:            }
144:
145:            private String getResolvedPropValue(String name) {
146:                String raw = properties.get(name);
147:                if (raw == null)
148:                    return null;
149:
150:                raw = raw.replace("${basedir}", this .baseDir.getAbsolutePath());
151:
152:                return raw;
153:            }
154:            /*
155:             public static void main(String[] args) throws Exception
156:             {
157:             new AntImport(new File("C:/Java/asm/asm-cvs-2006-09-19/asm/build.xml"), null);
158:             }
159:             */
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.