Source Code Cross Referenced for ManifestClassPath.java in  » Inversion-of-Control » hivemind » org » apache » hivemind » ant » 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 » Inversion of Control » hivemind » org.apache.hivemind.ant 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // Copyright 2004, 2005 The Apache Software Foundation
002:        //
003:        // Licensed under the Apache License, Version 2.0 (the "License");
004:        // you may not use this file except in compliance with the License.
005:        // You may obtain a copy of the License at
006:        //
007:        //     http://www.apache.org/licenses/LICENSE-2.0
008:        //
009:        // Unless required by applicable law or agreed to in writing, software
010:        // distributed under the License is distributed on an "AS IS" BASIS,
011:        // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:        // See the License for the specific language governing permissions and
013:        // limitations under the License.
014:
015:        package org.apache.hivemind.ant;
016:
017:        import java.io.File;
018:
019:        import org.apache.tools.ant.BuildException;
020:        import org.apache.tools.ant.Task;
021:        import org.apache.tools.ant.types.Path;
022:
023:        /**
024:         * Utility used to create a manifest class path.
025:         * It takes, as input, a reference to a path.  It converts this
026:         * into a space-separated list of file names.  The default
027:         * behavior is to simply strip off the directory portion of
028:         * each file entirely.
029:         * 
030:         * <p>
031:         * The final result is assigned to the property.
032:         *
033:         * @author Howard Lewis Ship
034:         */
035:        public class ManifestClassPath extends Task {
036:            private String _property;
037:            private Path _classpath;
038:            private File _directory;
039:
040:            public Path createClasspath() {
041:                _classpath = new Path(getProject());
042:
043:                return _classpath;
044:            }
045:
046:            public String getProperty() {
047:                return _property;
048:            }
049:
050:            public void setProperty(String string) {
051:                _property = string;
052:            }
053:
054:            public void execute() {
055:                if (_classpath == null)
056:                    throw new BuildException(
057:                            "You must specify a classpath to generate the manifest entry from");
058:
059:                if (_property == null)
060:                    throw new BuildException(
061:                            "You must specify a property to assign the manifest classpath to");
062:
063:                StringBuffer buffer = new StringBuffer();
064:
065:                String[] paths = _classpath.list();
066:
067:                String stripPrefix = null;
068:
069:                if (_directory != null)
070:                    stripPrefix = _directory.getPath();
071:
072:                // Will paths ever be null?
073:
074:                boolean needSep = false;
075:
076:                for (int i = 0; i < paths.length; i++) {
077:                    String path = paths[i];
078:
079:                    if (stripPrefix != null) {
080:                        if (!path.startsWith(stripPrefix))
081:                            continue;
082:
083:                        // Sometimes, people put the prefix directory in as a
084:                        // classpath entry; we ignore it (otherwise
085:                        // we get a IndexOutOfBoundsException
086:
087:                        if (path.length() == stripPrefix.length())
088:                            continue;
089:
090:                        if (needSep)
091:                            buffer.append(' ');
092:
093:                        // Strip off the directory and the seperator, leaving
094:                        // just the relative path.
095:
096:                        buffer.append(filter(path.substring(stripPrefix
097:                                .length() + 1)));
098:
099:                        needSep = true;
100:
101:                    } else {
102:                        if (needSep)
103:                            buffer.append(' ');
104:
105:                        File f = new File(path);
106:
107:                        buffer.append(f.getName());
108:
109:                        needSep = true;
110:                    }
111:                }
112:
113:                getProject().setProperty(_property, buffer.toString());
114:            }
115:
116:            public File getDirectory() {
117:                return _directory;
118:            }
119:
120:            /**
121:             * Sets a containing directory.  This has two effects:
122:             * <ul>
123:             * <li>Only files in the classpath that are contained by the directory are included.
124:             * <li>The directory path is stripped from each path, leaving a relative path
125:             * to the file.
126:             * </ul>
127:             */
128:            public void setDirectory(File file) {
129:                _directory = file;
130:            }
131:
132:            /**
133:             * Classpath entries must use a forward slash, regardless of what the
134:             * local filesystem uses.
135:             */
136:            protected String filter(String value) {
137:                if (File.separatorChar == '/')
138:                    return value;
139:
140:                return value.replace(File.separatorChar, '/');
141:            }
142:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.