Source Code Cross Referenced for BuilderList.java in  » Database-ORM » MMBase » org » mmbase » 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 » Database ORM » MMBase » org.mmbase.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:        This software is OSI Certified Open Source Software.
004:        OSI Certified is a certification mark of the Open Source Initiative.
005:
006:        The license (Mozilla version 1.0) can be read at the MMBase site.
007:        See http://www.MMBase.org/license
008:
009:         */
010:        package org.mmbase.util;
011:
012:        import java.io.*;
013:        import java.util.*;
014:
015:        import javax.xml.transform.stream.StreamResult;
016:        import javax.xml.transform.OutputKeys;
017:        import javax.xml.transform.Transformer;
018:        import javax.xml.transform.TransformerException;
019:        import javax.xml.transform.TransformerFactory;
020:        import javax.xml.transform.dom.DOMSource;
021:
022:        import org.w3c.dom.Document;
023:
024:        /**
025:         * Gives an xml-representation of a dir structure with builders
026:         * Used by the build script to create documentation for builders.
027:         * @since mmbase 1.6
028:         * @author Gerard van Enk
029:         * @author Pierre van Rooden
030:         * @version $Id: BuilderList.java,v 1.11 2007/02/24 21:57:50 nklasens Exp $
031:         */
032:        public class BuilderList {
033:            // logger not used at the moment
034:            //private static Logger log = Logging.getLoggerInstance(BuilderList.class.getName());
035:
036:            /**
037:             * Generates the document and writes it to the result object.
038:             * @param result the StreamResult object where to store the configuration'
039:             */
040:            public void write(Document doc, StreamResult result)
041:                    throws TransformerException {
042:                TransformerFactory tfactory = TransformerFactory.newInstance();
043:                tfactory.setURIResolver(new org.mmbase.util.xml.URIResolver(
044:                        new java.io.File("")));
045:                // This creates a transformer that does a simple identity transform,
046:                // and thus can be used for all intents and purposes as a serializer.
047:                Transformer serializer = tfactory.newTransformer();
048:                // sets indent amount for xalan
049:                // should be done elsewhere, but where?
050:                serializer.setOutputProperty(
051:                        "{http://xml.apache.org/xslt}indent-amount", "2");
052:                // xml output configuration
053:                serializer.setOutputProperty(OutputKeys.INDENT, "yes");
054:                serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
055:                        "yes");
056:                serializer.transform(new DOMSource(doc), result);
057:            }
058:
059:            /**
060:             * Lists all builders within a given path, including builders in sub-paths
061:             * @param ipath the path to start searching. The path need be closed with a File.seperator character.
062:             */
063:            void listBuilders(ResourceLoader config, Writer writer)
064:                    throws IOException {
065:                Set<String> xmls = config.getResourcePaths(
066:                        ResourceLoader.XML_PATTERN, false);
067:                writer.write("<buildertype name=\"" + config.getContext()
068:                        + "\">\n");
069:                Iterator<String> i = xmls.iterator();
070:                while (i.hasNext()) {
071:                    String name = i.next();
072:                    try {
073:                        Document document = config.getDocument(name);
074:                        //only process builder config files
075:                        if (document.getDocumentElement().getTagName().equals(
076:                                "builder")) {
077:                            write(document, new StreamResult(writer));
078:                        }
079:                    } catch (Exception e) {
080:                    }
081:                }
082:                writer.write("</buildertype>\n");
083:                Iterator<String> j = config.getChildContexts(null, false)
084:                        .iterator();
085:                while (j.hasNext()) {
086:                    String sub = j.next();
087:                    if ("CVS".equals(sub))
088:                        continue;
089:                    listBuilders(config.getChildResourceLoader(sub), writer);
090:                }
091:
092:            }
093:
094:            /**
095:             * Main method can be called from an Ant build file and will return
096:             * the xml with a listing of all the builders
097:             *
098:             * @param args base dir to start with, it's possible to use more than one dir seperated by ;
099:             */
100:            public static void main(String[] args)
101:                    throws UnsupportedEncodingException, IOException {
102:                if (args.length != 0) {
103:                    BuilderList bulList = new BuilderList();
104:                    Writer s = new OutputStreamWriter(System.out, "UTF-8");
105:                    s.write("<builders>\n");
106:                    String[] builderDirs = args[0].split(";");
107:                    for (String element : builderDirs) {
108:                        ResourceLoader config = ResourceLoader
109:                                .getConfigurationRoot().getChildResourceLoader(
110:                                        element);
111:                        bulList.listBuilders(config, s);
112:                    }
113:                    s.write("</builders>\n");
114:                    s.flush();
115:                } else {
116:                    System.out
117:                            .println("usage: java BuilderList <basedirwithbuilderconfig>");
118:                }
119:            }
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.