/** * Adds a child to this file. * * @param baseName The base FileName. * @param type The FileType. * @throws Exception if an error occurs. */ public void attachChild(final FileName baseName, final FileType type) throws Exception { final FileType oldType = doGetType(); if (children.add(baseName.getBaseName())) { childrenChanged(baseName, type); } maybeTypeChanged(oldType); }
/** * Checks whether the file's type has changed, and fires the appropriate events. * * @param oldType The old FileType. * @throws Exception if an error occurs. */ private void maybeTypeChanged(final FileType oldType) throws Exception { final FileType newType = doGetType(); if (oldType == FileType.IMAGINARY && newType != FileType.IMAGINARY) { handleCreate(newType); } else if (oldType != FileType.IMAGINARY && newType == FileType.IMAGINARY) { handleDelete(); } }
/** * Attaches or detaches the target file. * * @param file The FileObject. * @throws Exception if an error occurs. */ public void setFile(final FileObject file) throws Exception { final FileType oldType = doGetType(); if (file != null) { WeakRefFileListener.installListener(file, this); } this.file = file; maybeTypeChanged(oldType); }
junctionFile.setFile(targetFile); DelegateFileObject file = (DelegateFileObject) getFileFromCache(parentName); if (file == null) { file = new DelegateFileObject(parentName, this, null); putFileToCache(file); } else { done = file.exists(); file.attachChild(childName, FileType.FOLDER);
/** * Creates a file object. This method is called only if the requested file is not cached. */ @Override protected FileObject createFile(final AbstractFileName name) throws Exception { // Find the file that the name points to final FileName junctionPoint = getJunctionForFile(name); final FileObject file; if (junctionPoint != null) { // Resolve the real file final FileObject junctionFile = junctions.get(junctionPoint); final String relName = junctionPoint.getRelativeName(name); file = junctionFile.resolveFile(relName, NameScope.DESCENDENT_OR_SELF); } else { file = null; } // Return a wrapper around the file return new DelegateFileObject(name, this, file); }
/** * Called when a file is created. * * @param event The FileChangeEvent. * @throws Exception if an error occurs. */ @Override public void fileCreated(final FileChangeEvent event) throws Exception { if (event.getFile() != file) { return; } if (!ignoreEvent) { handleCreate(file.getType()); } }
/** * Called when a file is deleted. * * @param event The FileChangeEvent. * @throws Exception if an error occurs. */ @Override public void fileDeleted(final FileChangeEvent event) throws Exception { if (event.getFile() != file) { return; } if (!ignoreEvent) { handleDelete(); } }
/** * Called when a file is changed. * <p> * This will only happen if you monitor the file using {@link org.apache.commons.vfs2.FileMonitor}. * * @param event The FileChangeEvent. * @throws Exception if an error occurs. */ @Override public void fileChanged(final FileChangeEvent event) throws Exception { if (event.getFile() != file) { return; } if (!ignoreEvent) { handleChanged(); } }
/** * Lists the children of the file. */ @Override protected String[] doListChildren() throws Exception { if (file != null) { final FileObject[] children; try { children = file.getChildren(); } // VFS-210 catch (final FileNotFolderException e) { throw new FileNotFolderException(getName(), e); } final String[] childNames = new String[children.length]; for (int i = 0; i < children.length; i++) { childNames[i] = children[i].getName().getBaseName(); } return childNames; } return children.toArray(new String[children.size()]); }
junctionFile.setFile(targetFile); DelegateFileObject file = (DelegateFileObject) getFileFromCache(parentName); if (file == null) { file = new DelegateFileObject(parentName, this, null); putFileToCache(file); } else { done = file.exists(); file.attachChild(childName, FileType.FOLDER);
/** * Attaches or detaches the target file. * * @param file The FileObject. * @throws Exception if an error occurs. */ public void setFile(final FileObject file) throws Exception { final FileType oldType = doGetType(); if (file != null) { WeakRefFileListener.installListener(file, this); } this.file = file; maybeTypeChanged(oldType); }
/** * Creates a file object. This method is called only if the requested file is not cached. */ @Override protected FileObject createFile(final AbstractFileName name) throws Exception { // Find the file that the name points to final FileName junctionPoint = getJunctionForFile(name); final FileObject file; if (junctionPoint != null) { // Resolve the real file final FileObject junctionFile = junctions.get(junctionPoint); final String relName = junctionPoint.getRelativeName(name); file = junctionFile.resolveFile(relName, NameScope.DESCENDENT_OR_SELF); } else { file = null; } // Return a wrapper around the file return new DelegateFileObject(name, this, file); }
/** * Called when a file is created. * * @param event The FileChangeEvent. * @throws Exception if an error occurs. */ @Override public void fileCreated(final FileChangeEvent event) throws Exception { if (event.getFile() != file) { return; } if (!ignoreEvent) { handleCreate(file.getType()); } }
/** * Called when a file is deleted. * * @param event The FileChangeEvent. * @throws Exception if an error occurs. */ @Override public void fileDeleted(final FileChangeEvent event) throws Exception { if (event.getFile() != file) { return; } if (!ignoreEvent) { handleDelete(); } }
/** * Called when a file is changed. * <p> * This will only happen if you monitor the file using {@link org.apache.commons.vfs2.FileMonitor}. * * @param event The FileChangeEvent. * @throws Exception if an error occurs. */ @Override public void fileChanged(final FileChangeEvent event) throws Exception { if (event.getFile() != file) { return; } if (!ignoreEvent) { handleChanged(); } }
/** * Lists the children of the file. */ @Override protected String[] doListChildren() throws Exception { if (file != null) { final FileObject[] children; try { children = file.getChildren(); } // VFS-210 catch (final FileNotFolderException e) { throw new FileNotFolderException(getName(), e); } final String[] childNames = new String[children.length]; for (int i = 0; i < children.length; i++) { childNames[i] = children[i].getName().getBaseName(); } return childNames; } return children.toArray(new String[children.size()]); }
junctionFile.setFile(targetFile); DelegateFileObject file = (DelegateFileObject) getFileFromCache(parentName); if (file == null) { file = new DelegateFileObject(parentName, this, null); putFileToCache(file); } else { done = file.exists(); file.attachChild(childName, FileType.FOLDER);
/** * Adds a child to this file. * * @param baseName The base FileName. * @param type The FileType. * @throws Exception if an error occurs. */ public void attachChild(final FileName baseName, final FileType type) throws Exception { final FileType oldType = doGetType(); if (children.add(baseName.getBaseName())) { childrenChanged(baseName, type); } maybeTypeChanged(oldType); }
/** * Checks whether the file's type has changed, and fires the appropriate events. * * @param oldType The old FileType. * @throws Exception if an error occurs. */ private void maybeTypeChanged(final FileType oldType) throws Exception { final FileType newType = doGetType(); if (oldType == FileType.IMAGINARY && newType != FileType.IMAGINARY) { handleCreate(newType); } else if (oldType != FileType.IMAGINARY && newType == FileType.IMAGINARY) { handleDelete(); } }
/** * Attaches or detaches the target file. * * @param file The FileObject. * @throws Exception if an error occurs. */ public void setFile(final FileObject file) throws Exception { final FileType oldType = doGetType(); if (file != null) { WeakRefFileListener.installListener(file, this); } this.file = file; maybeTypeChanged(oldType); }