List of usage examples for org.apache.commons.vfs NameScope DESCENDENT
NameScope DESCENDENT
To view the source code for org.apache.commons.vfs NameScope DESCENDENT.
Click Source Link
From source file:com.pongasoft.util.io.IOUtils.java
/** * Returns a child of the provided file object designated by the uri path * * @param uriPath the path to the child/*from w w w . j av a 2 s .co m*/ * @param fileObject the file object (root) * @return the new file object * @throws IOException if there is something wrong */ public static FileObject resolveFile(FileObject fileObject, URIPath uriPath) throws IOException { String fullPath = uriPath.getFullPath(); if ("".equals(fullPath) || "/".equals(fullPath)) return fileObject; else return fileObject.resolveFile(fullPath, NameScope.DESCENDENT); }
From source file:com.pongasoft.kiwidoc.builder.KiwidocBuilder.java
/** * Builds the kiwidoc for the given library * * @param library (optional, <code>null</code> ok) dependencies * @return the model builder//from w w w . j a va 2s . com * @throws BuilderException when there is a problem indexing */ public LibraryModelBuilder buildKiwidoc(Library library) throws IOException, BuilderException { Set<BuiltFrom> builtFrom = EnumSet.noneOf(BuiltFrom.class); Manifest manifest = null; LibraryModelBuilder libFromByteCode = null; // if we have the library itself (jar file) if (library.classes != null) { builtFrom.add(BuiltFrom.BYTECODE); // manifest FileObject manifestResource = library.classes.resolveFile("META-INF/MANIFEST.MF"); if (manifestResource.exists()) { manifest = new Manifest(); InputStream is = manifestResource.getContent().getInputStream(); try { manifest.read(new BufferedInputStream(is)); } finally { is.close(); } } // byte code libFromByteCode = new LibraryModelBuilder(library.libraryVersionResource); new ByteCodeParser().parseClasses(libFromByteCode, library.classes); } LibraryModelBuilder libFromSource = null; // if we have the source code if (library.sources != null) { try { libFromSource = new LibraryModelBuilder(library.libraryVersionResource); if (libFromByteCode != null) libFromSource.setJdkVersion(libFromByteCode.getJdkVersion()); else libFromSource.setJdkVersion(library.jdkVersion); int sourceCount = new SourceCodeParser().parseSources(libFromSource, library.sources, library.overviewFilename, library.publicOnly ? library.javadoc : null, library.classpath); if (sourceCount == 0) { libFromSource = null; log.warn("No sources found in " + library.sources); } else { builtFrom.add(BuiltFrom.SOURCE); } } catch (IOException e) { throw e; } catch (Throwable th) { throw new BuilderException(th); } } // compute which version to use (source code wins if available) LibraryModelBuilder lib = new LibraryModelBuilder(library.libraryVersionResource); if (libFromByteCode != null) { lib = libFromByteCode; } if (libFromSource != null) { lib = libFromSource; } log.info("Processed source|bytecode: " + (libFromSource == null ? "N/A" : libFromSource.getClassCount()) + " | " + (libFromByteCode == null ? "N/A" : libFromByteCode.getClassCount())); // TODO MED YP: use byte code for resolving unresolved types during javadoc processing // if we have the original javadoc (used for determining exported classes) if (library.javadoc != null) { builtFrom.add(BuiltFrom.JAVADOC); for (PackageModelBuilder packageModelBuilder : lib.getAllPackages()) { for (ClassModelBuilder classModelBuilder : packageModelBuilder.getAllClasses()) { String javadocFile = classModelBuilder.getFqcn(); javadocFile = javadocFile.replace('.', '/'); javadocFile = javadocFile.replace('$', '.'); // for inner classes javadocFile += ".html"; try { classModelBuilder.setExportedClass( library.javadoc.resolveFile(javadocFile, NameScope.DESCENDENT).exists()); } catch (FileSystemException e) { log.warn("Error while setting exported class on " + javadocFile + " [" + classModelBuilder.getFqcn() + "]", e); } } } } // dependencies lib.setDependencies(library.dependencies); // manifest lib.setManifest(manifest); // built from lib.addBuiltFrom(builtFrom); return lib; }