Source Code Cross Referenced for BaseClassPathSupport.java in  » IDE-Netbeans » java » org » netbeans » modules » java » api » common » classpath » j2ee » 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 Netbeans » java » org.netbeans.modules.java.api.common.classpath.j2ee 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * If you wish your version of this file to be governed by only the CDDL
025:         * or only the GPL Version 2, indicate your decision by adding
026:         * "[Contributor] elects to include this software in this distribution
027:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
028:         * single choice of license, a recipient has the option to distribute
029:         * your version of this file under either the CDDL, the GPL Version 2 or
030:         * to extend the choice of license to its licensees as provided above.
031:         * However, if you add GPL Version 2 code and therefore, elected the GPL
032:         * Version 2 license, then the option applies only if the new code is
033:         * made subject to such option by the copyright holder.
034:         *
035:         * Contributor(s):
036:         *
037:         * Portions Copyrighted 2008 Sun Microsystems, Inc.
038:         */
039:
040:        package org.netbeans.modules.java.api.common.classpath.j2ee;
041:
042:        import java.io.File;
043:        import java.net.URI;
044:        import java.net.URL;
045:        import java.util.Iterator;
046:        import java.util.List;
047:        import org.netbeans.api.project.ant.AntArtifact;
048:        import org.netbeans.api.project.libraries.Library;
049:        import org.netbeans.modules.java.api.common.classpath.ClassPathItem;
050:        import org.netbeans.modules.java.api.common.classpath.ClassPathSupport;
051:        import org.netbeans.spi.project.support.ant.AntProjectHelper;
052:        import org.netbeans.spi.project.support.ant.EditableProperties;
053:        import org.netbeans.spi.project.support.ant.PropertyEvaluator;
054:        import org.netbeans.spi.project.support.ant.ReferenceHelper;
055:        import org.openide.filesystems.FileObject;
056:        import org.openide.filesystems.FileUtil;
057:        import org.openide.filesystems.URLMapper;
058:        import org.w3c.dom.Node;
059:        import org.w3c.dom.NodeList;
060:        import org.w3c.dom.Text;
061:
062:        // will be moved to j2ee.common
063:        /**
064:         *
065:         * @author Tomas Mysik
066:         * @since 1.21
067:         */
068:        abstract class BaseClassPathSupport<T extends BaseClassPathSupport.Item> {
069:
070:            static final String ATTR_FILES = "files"; // NOI18N
071:            static final String ATTR_DIRS = "dirs"; // NOI18N
072:
073:            final AntProjectHelper antProjectHelper;
074:            final ClassPathSupport delegate;
075:            final String projectConfigurationNameSpace;
076:
077:            BaseClassPathSupport(PropertyEvaluator evaluator,
078:                    ReferenceHelper referenceHelper,
079:                    AntProjectHelper antProjectHelper, String[] wellKnownPaths,
080:                    String libraryPrefix, String librarySuffix,
081:                    String antArtifactPrefix,
082:                    String projectConfigurationNameSpace) {
083:                // XXX call Parameters here as well?
084:                assert projectConfigurationNameSpace != null;
085:
086:                this .antProjectHelper = antProjectHelper;
087:                this .projectConfigurationNameSpace = projectConfigurationNameSpace;
088:                delegate = ClassPathSupport.create(evaluator, referenceHelper,
089:                        antProjectHelper, wellKnownPaths, libraryPrefix,
090:                        librarySuffix, antArtifactPrefix);
091:            }
092:
093:            /**
094:             * Creates list of <CODE>Items</CODE> from given property.
095:             */
096:            public Iterator<T> itemsIterator(String propertyValue,
097:                    String libraryElementName) {
098:                // XXX More performance frendly impl. would retrun a lazzy iterator.
099:                return itemsList(propertyValue, libraryElementName).iterator();
100:            }
101:
102:            public abstract List<T> itemsList(String propertyValue,
103:                    String libraryElementName);
104:
105:            public abstract String[] encodeToStrings(final List<T> items,
106:                    String libraryElementName);
107:
108:            // XXX move into utilities module
109:            public static void getFilesForItem(Item item, List<File> files,
110:                    List<File> dirs) {
111:                if (item.isBroken()) {
112:                    return;
113:                }
114:                switch (item.getType()) {
115:                case LIBRARY:
116:                    List<URL> roots = item.getLibrary().getContent("classpath"); // NOI18N
117:                    for (URL rootUrl : roots) {
118:                        FileObject root = URLMapper.findFileObject(rootUrl);
119:                        if ("jar".equals(rootUrl.getProtocol())) { // NOI18N
120:                            root = FileUtil.getArchiveFile(root);
121:                        }
122:                        File f = FileUtil.toFile(root);
123:                        if (f != null) {
124:                            if (f.isFile()) {
125:                                files.add(f);
126:                            } else {
127:                                dirs.add(f);
128:                            }
129:                        }
130:                    }
131:                    break;
132:                case JAR:
133:                    File root = item.getFile();
134:                    if (root != null) {
135:                        if (root.isFile()) {
136:                            files.add(root);
137:                        } else {
138:                            dirs.add(root);
139:                        }
140:                    }
141:                    break;
142:                case ARTIFACT:
143:                    String artifactFolder = item.getArtifact()
144:                            .getScriptLocation().getParent();
145:                    URI[] locations = item.getArtifact().getArtifactLocations();
146:                    for (URI location : locations) {
147:                        String fullLocation = artifactFolder + File.separator
148:                                + location;
149:                        if (fullLocation.endsWith(File.separator)) {
150:                            dirs.add(new File(fullLocation));
151:                        } else {
152:                            files.add(new File(fullLocation));
153:                        }
154:                    }
155:                    break;
156:                default:
157:                    // noop
158:                    break;
159:                }
160:            }
161:
162:            public String getLibraryReference(T item) {
163:                return delegate.getLibraryReference(item.delegate);
164:            }
165:
166:            /**
167:             * Tokenize library classpath and try to relativize all the jars.
168:             * @param ep the editable properties in which the result should be stored
169:             * @param aph AntProjectHelper used to resolve files
170:             * @param libCpProperty the library classpath property
171:             */
172:            public static boolean relativizeLibraryClassPath(
173:                    final EditableProperties ep, final AntProjectHelper aph,
174:                    final String libCpProperty) {
175:                return ClassPathSupport.relativizeLibraryClassPath(ep, aph,
176:                        libCpProperty);
177:            }
178:
179:            /**
180:             * Extracts <b>the first</b> nested text from an element.
181:             * Currently does not handle coalescing text nodes, CDATA sections, etc.
182:             * @param parent a parent element
183:             * @return the nested text, or null if none was found
184:             */
185:            static String findText(Node parent) {
186:                NodeList l = parent.getChildNodes();
187:                for (int i = 0; i < l.getLength(); i++) {
188:                    if (l.item(i).getNodeType() == Node.TEXT_NODE) {
189:                        Text text = (Text) l.item(i);
190:                        return text.getNodeValue();
191:                    }
192:                }
193:                return null;
194:            }
195:
196:            abstract static class Item implements  ClassPathItem {
197:
198:                final ClassPathSupport.Item delegate;
199:                private String property;
200:                private String raw;
201:
202:                Item(ClassPathSupport.Item delegate, String property, String raw) {
203:                    this .delegate = delegate;
204:                    this .property = property;
205:                    this .raw = raw;
206:                }
207:
208:                void setReference(String property) {
209:                    this .property = property;
210:                }
211:
212:                public ClassPathItem.Type getType() {
213:                    return delegate.getType();
214:                }
215:
216:                public Library getLibrary() {
217:                    return delegate.getLibrary();
218:                }
219:
220:                public File getFile() {
221:                    return delegate.getFile();
222:                }
223:
224:                public AntArtifact getArtifact() {
225:                    return delegate.getArtifact();
226:                }
227:
228:                public URI getArtifactURI() {
229:                    return delegate.getArtifactURI();
230:                }
231:
232:                public String getReference() {
233:                    return delegate.getReference();
234:                }
235:
236:                public boolean isBroken() {
237:                    return delegate.isBroken();
238:                }
239:
240:                public String getRaw() {
241:                    return raw;
242:                }
243:
244:                @Override
245:                public int hashCode() {
246:                    return delegate.hashCode();
247:                }
248:
249:                @Override
250:                public boolean equals(Object itemObject) {
251:                    if (itemObject instanceof  Item) {
252:                        Item item = (Item) itemObject;
253:                        return delegate.equals(item);
254:                    }
255:                    return false;
256:                }
257:            }
258:        }
w__ww._j__a__v___a__2__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.