Source Code Cross Referenced for LibraryDisplayer.java in  » Build » ANT » org » apache » tools » ant » taskdefs » optional » extension » 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 » Build » ANT » org.apache.tools.ant.taskdefs.optional.extension 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         *
017:         */
018:        package org.apache.tools.ant.taskdefs.optional.extension;
019:
020:        import java.io.File;
021:        import java.text.ParseException;
022:        import java.util.jar.Manifest;
023:        import org.apache.tools.ant.BuildException;
024:
025:        /**
026:         * Utility class to output the information in a jar relating
027:         * to "Optional Packages" (formely known as "Extensions")
028:         * and Package Specifications.
029:         *
030:         */
031:        class LibraryDisplayer {
032:            /**
033:             * Display the extensions and specifications contained
034:             * within specified file.
035:             *
036:             * @param file the file
037:             * @throws BuildException if fail to read file
038:             */
039:            void displayLibrary(final File file) throws BuildException {
040:                final Manifest manifest = ExtensionUtil.getManifest(file);
041:                displayLibrary(file, manifest);
042:            }
043:
044:            /**
045:             * Display the extensions and specifications contained
046:             * within specified file.
047:             *
048:             * @param file the file to use while reporting
049:             * @param manifest the manifest of file
050:             * @throws BuildException if fail to read file
051:             */
052:            void displayLibrary(final File file, final Manifest manifest)
053:                    throws BuildException {
054:                final Extension[] available = Extension.getAvailable(manifest);
055:                final Extension[] required = Extension.getRequired(manifest);
056:                final Extension[] options = Extension.getOptions(manifest);
057:                final Specification[] specifications = getSpecifications(manifest);
058:
059:                if (0 == available.length && 0 == required.length
060:                        && 0 == options.length && 0 == specifications.length) {
061:                    return;
062:                }
063:
064:                final String message = "File: " + file;
065:                final int size = message.length();
066:                printLine(size);
067:                System.out.println(message);
068:                printLine(size);
069:                if (0 != available.length) {
070:                    System.out.println("Extensions Supported By Library:");
071:                    for (int i = 0; i < available.length; i++) {
072:                        final Extension extension = available[i];
073:                        System.out.println(extension.toString());
074:                    }
075:                }
076:
077:                if (0 != required.length) {
078:                    System.out.println("Extensions Required By Library:");
079:                    for (int i = 0; i < required.length; i++) {
080:                        final Extension extension = required[i];
081:                        System.out.println(extension.toString());
082:                    }
083:                }
084:
085:                if (0 != options.length) {
086:                    System.out
087:                            .println("Extensions that will be used by Library if present:");
088:                    for (int i = 0; i < options.length; i++) {
089:                        final Extension extension = options[i];
090:                        System.out.println(extension.toString());
091:                    }
092:                }
093:
094:                if (0 != specifications.length) {
095:                    System.out.println("Specifications Supported By Library:");
096:                    for (int i = 0; i < specifications.length; i++) {
097:                        final Specification specification = specifications[i];
098:                        displaySpecification(specification);
099:                    }
100:                }
101:            }
102:
103:            /**
104:             * Print out a line of '-'s equal to specified size.
105:             *
106:             * @param size the number of dashes to printout
107:             */
108:            private void printLine(final int size) {
109:                for (int i = 0; i < size; i++) {
110:                    System.out.print("-");
111:                }
112:                System.out.println();
113:            }
114:
115:            /**
116:             * Get specifications from manifest.
117:             *
118:             * @param manifest the manifest
119:             * @return the specifications or null if none
120:             * @throws BuildException if malformed specification sections
121:             */
122:            private Specification[] getSpecifications(final Manifest manifest)
123:                    throws BuildException {
124:                try {
125:                    return Specification.getSpecifications(manifest);
126:                } catch (final ParseException pe) {
127:                    throw new BuildException(pe.getMessage(), pe);
128:                }
129:            }
130:
131:            /**
132:             * Print out specification details.
133:             *
134:             * @param specification the specification
135:             */
136:            private void displaySpecification(final Specification specification) {
137:                final String[] sections = specification.getSections();
138:                if (null != sections) {
139:                    final StringBuffer sb = new StringBuffer("Sections: ");
140:                    for (int i = 0; i < sections.length; i++) {
141:                        sb.append(" ");
142:                        sb.append(sections[i]);
143:                    }
144:                    System.out.println(sb);
145:                }
146:                System.out.println(specification.toString());
147:            }
148:        }
w_ww_.___j__a___v__a2_s.___c___o___m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.