/** * Create a virtual tree hierarchy with a file supporting the leaf. * @param path Position of the file in the hierarchy, including its name * @param file The actual file, or directory , abcking the end leaf * @return The FSEntry root for this hierarchy * @throws Exception Invalid parameter */ static public FSEntry getPositionedFile(String path, File file) throws Exception { List<String> pathFrags = FSEntrySupport.interpretPath(path); // Start at leaf and work our way back int index = pathFrags.size() - 1; FSEntry root = new FSEntryFile(pathFrags.get(index), file); --index; while(index >= 0){ FSEntryVirtualDirectory parent = new FSEntryVirtualDirectory(pathFrags.get(index)); parent.addChildEntry(root); root = parent; --index; } return root; }
/** * Create a virtual tree hierarchy with a buffer supporting the leaf. * @param path Position of the buffer in the hierarchy, including its name * @param content The actual buffer backing the end leaf * @return The FSEntry root for this hierarchy * @throws Exception Invalid parameter */ static public FSEntry getPositionedBuffer(String path, byte[] content) throws Exception { List<String> pathFrags = FSEntrySupport.interpretPath(path); // Start at leaf and work our way back int index = pathFrags.size() - 1; FSEntry root = new FSEntryBuffer(pathFrags.get(index), content); --index; while(index >= 0){ FSEntryVirtualDirectory parent = new FSEntryVirtualDirectory(pathFrags.get(index)); parent.addChildEntry(root); root = parent; --index; } return root; }
/** * Create a virtual tree hierarchy with a buffer supporting the leaf. * @param path Position of the buffer in the hierarchy, including its name * @param content The actual content, expressed as a String, backing the end leaf * @return The FSEntry root for this hierarchy * @throws Exception Invalid parameter */ static public FSEntry getPositionedBuffer(String path, String content) throws Exception { List<String> pathFrags = FSEntrySupport.interpretPath(path); // Start at leaf and work our way back int index = pathFrags.size() - 1; FSEntry root = new FSEntryBuffer(pathFrags.get(index), content); --index; while(index >= 0){ FSEntryVirtualDirectory parent = new FSEntryVirtualDirectory(pathFrags.get(index)); parent.addChildEntry(root); root = parent; --index; } return root; }
/** * 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; }