/** * Creates an instance of FSEntryResource to represent an entry based on the resource * specified by the classLoader and resource name. * @param classLoader Class loader used to find the resource * @param resourceName Actual name of resource * @return An entry representing the specified resource. * @throws Exception Invalid request */ static public FSEntryResource create(ClassLoader classLoader, String resourceName) throws Exception { return create(null, classLoader, resourceName); }
@Override public List<FSEntry> getChildren() { return getChildren(FSEntryNameFilter.all); }
FSEntryResource childEntry = new FSEntryResource(childFile.getName(), childFile); result.add(childEntry); String childName = nameFromJarEntry(entry); childEntry = new FSEntryResource(childName, jarFile, entry); String childName = nameFromJarEntry(entry); childEntry = new FSEntryResource(childName, jarFile, entry); if( filter.accept(this, childEntry.getName()) ) { result.add(childEntry);
File childFile = new File(file,name); if( childFile.exists() ) { result = new FSEntryResource(childFile.getName(), childFile); || entryName.equals(expectedNameDir) ) { String childName = nameFromJarEntry(entry); result = new FSEntryResource(childName, jarFile, entry);
name = nameFromJarEntry(jarEntry); return new FSEntryResource(name, jarFile, jarEntry); name = file.getName(); return new FSEntryResource(name, file);
/** * Create a virtual tree hierarchy with a resource supporting the leaf. * @param path Position of the file in the hierarchy, including its name * @param classLoader Class loader used to find the needed resource * @param resourceName Name of the actual resource to obtain using class loader * @return The FSEntry root for this hierarchy * @throws Exception Invalid parameter */ static public FSEntry getPositionedResource(String path, ClassLoader classLoader, String resourceName) throws Exception { List<String> pathFrags = FSEntrySupport.interpretPath(path); // Start at leaf and work our way back int index = pathFrags.size() - 1; FSEntry root = create(pathFrags.get(index), classLoader, resourceName); --index; while(index >= 0){ FSEntryVirtualDirectory parent = new FSEntryVirtualDirectory(pathFrags.get(index)); parent.addChildEntry(root); root = parent; --index; } return root; }
FSEntryResource resourceFile = FSEntryResource.create(UserDesignDocument.class.getClassLoader(), "userDesignDocument"); Document doc = DocumentFile.createDocument(resourceFile, resourceFile);