final boolean superCanRead() { return super.canRead(); }
final boolean superCanWrite() { return super.canWrite(); }
private synchronized FileObject getFileObjectImpl(String name, String ext) { check(); if ((ext == null) || ext.equals("")) { // NOI18N return getChild(name); } else { StringBuffer sb = new StringBuffer(name.length() + 1 + ((ext == null) ? 0 : ext.length())); sb.append(name).append(EXT_SEP).append(ext); return getChild(sb.toString()); } }
/** Tries to find a resource. * @param en enumeration of strings to scan * @return found object or null */ final FileObject find(Enumeration<String> en) { AbstractFolder fo = this; while ((fo != null) && en.hasMoreElements()) { // try to go on // lock to provide safety for getChild synchronized (fo) { // JST: Better to call the check only here, // than in getChild, than it is not called // so often. fo.check(); final String next = en.nextElement(); if ("..".equals(next)) { fo = (AbstractFolder)fo.getParent(); } else { fo = fo.getChild(next); } } } // no next requirements or not found return fo; }
fo = createFile(name); if ((fo != null) && fo.isValid()) { map.put(name, (fo != null) ? createReference(fo) : null); } else { if (onlyValid) {
) { try { getFileSystem().beginAtomicAction(); final String[] newChildren = getNewChildren(list); final Set<String> addedNames; final Map<String, AbstractFolder> removedPairs; removedPairs = (map != null) ? dereferenceValues(map) : null; map = newMap; children = newChildren; if (fire && (addedNames != null) && hasAtLeastOneListeners()) { filesCreated(addedNames, expected); filesDeleted(removedPairs, expected); fire && (added == null) && (removed == null) && !getFileSystem().isReadOnly() && !(this instanceof MultiFileObject) ) { refreshChildren(existingSubFiles(false), nameFilter, expected); getFileSystem().finishAtomicAction();
/** refreshes children recursively.*/ private void refreshChildren(AbstractFolder fo, ResourceElem resElem) { if (fo.isRoot()) { initializeReference(rootRef = new FileObjRef<AbstractFolder>(fo), resElem); } java.util.List<String> nameList = resElem.getChildren(); String[] names = new String[nameList.size()]; ResourceElem[] children = new ResourceElem[names.length]; nameList.toArray(names); for (int i = 0; i < names.length; i++) children[i] = resElem.getChild(names[i]); fo.refresh(null, null, true, true, names); for (int i = 0; i < children.length; i++) { AbstractFolder fo2 = (AbstractFolder) fo.getFileObject(names[i]); FileObjRef currentRef = (FileObjRef) findReference(fo2.getPath()); int diff = initializeReference(currentRef, children[i]); fo2.lastModified(); if (fo2.isFolder()) { refreshChildren(fo2, children[i]); } else { if ((diff & 0x01) != 0) { fo2.fileChanged0(new FileEvent(fo2)); } else { if ((diff & 0x02) != 0) { fo2.fileAttributeChanged0(new FileAttributeEvent(fo2, null, null, null)); } } } } }
/** Fires event */ protected final void fileCreated0(FileEvent fileevent, boolean isData) { /* if(isData) super.fireFileDataCreatedEvent(listeners (), fileevent); else super.fireFileFolderCreatedEvent(listeners (), fileevent); */ dispatchEvent(listeners(), fileevent); if (fileevent.getFile().equals(this) && (parent != null)) { FileEvent ev = new FileEvent(parent, fileevent.getFile(), fileevent.isExpected()); try { ev.inheritPostNotify(fileevent); parent.fileCreated0(ev, isData); } finally { ev.setPostNotify(null); } } }
/** Fires event */ protected final void fileAttributeChanged0(FileAttributeEvent fileattributeevent) { super.fireFileAttributeChangedEvent(listeners(), fileattributeevent); if (fileattributeevent.getFile().equals(this) && (parent != null)) { FileAttributeEvent ev = new FileAttributeEvent( parent, fileattributeevent.getFile(), fileattributeevent.getName(), fileattributeevent.getOldValue(), fileattributeevent.getNewValue(), fileattributeevent.isExpected() ); try { ev.inheritPostNotify(fileattributeevent); parent.fileAttributeChanged0(ev); } finally { ev.setPostNotify(null); } } }
void registerChild(String name) { synchronized (this) { if (map == null) { check(); } Reference<AbstractFolder> o = map.put(name, new WeakReference<AbstractFolder>(null)); if (o != null) { map.put(name, o); } else { String[] newChildren = new String[children.length + 1]; System.arraycopy(children, 0, newChildren, 0, children.length); newChildren[children.length] = name; children = newChildren; } } }
private void refreshChildrenInAtomicAction(AbstractFolder fo, ResourceElem resElem) { try { beginAtomicAction(); Collection<AbstractFolder> oldChildren = new HashSet<AbstractFolder>(Collections.list(fo.existingSubFiles(true))); refreshChildren(fo, resElem); Collection<AbstractFolder> newChildren = Collections.list(fo.existingSubFiles(true)); oldChildren.removeAll(newChildren); for (Iterator<AbstractFolder> it = oldChildren.iterator(); it.hasNext();) { AbstractFileObject invalid = (AbstractFileObject)it.next(); if (invalid.validFlag) { invalid.validFlag = false; invalid.fileDeleted0(new FileEvent(invalid)); } } } finally { finishAtomicAction(); } }
getFileSystem().beginAtomicAction(); final String[] newChildren = getNewChildren(list); final Set addedNames; final Map removedPairs; removedPairs = (map != null) ? dereferenceValues(map) : null;/*<String, AbstractFileObject>*/ map = newMap; children = newChildren; if (fire && addedNames != null && hasAtLeastOneListeners()) { filesCreated(addedNames, expected); removedPairs.remove(removed); filesDeleted(removedPairs, expected); if (fire && added == null && removed == null && !getFileSystem().isReadOnly() && !(this instanceof MultiFileObject)) { Set nameFilter = nameFilter = new HashSet(); if (addedNames != null) nameFilter.addAll(addedNames); if (removedPairs != null) nameFilter.addAll(removedPairs.keySet()); refreshChildren(existingSubFiles(false),nameFilter, expected); getFileSystem().finishAtomicAction();
/** Fires event */ protected final void fileCreated0(FileEvent fileevent, boolean isData) { /* if(isData) super.fireFileDataCreatedEvent(listeners (), fileevent); else super.fireFileFolderCreatedEvent(listeners (), fileevent); */ dispatchEvent(listeners(), fileevent); if(fileevent.getFile().equals(this) && parent != null) { FileEvent ev = new FileEvent(parent, fileevent.getFile(), fileevent.isExpected ()); parent.fileCreated0 (ev, isData); } } /** Creates nad fires event */
private final AbstractFolder getChild (String name, boolean onlyValid) { Reference r = (Reference)map.get (name); if (r == null) { //On OpenVMS, see if the name is stored in a different case //to work around a JVM bug. // if (Utilities.getOperatingSystem() == Utilities.OS_VMS) { if (Character.isLowerCase(name.charAt(0))) r = (Reference)map.get(name.toUpperCase()); else r = (Reference)map.get(name.toLowerCase()); if (r == null) return null; } else return null; } AbstractFolder fo = (AbstractFolder)(r.get ()); if (fo == null) { // object does not exist => have to recreate it fo = createFile (name); if (fo != null && fo.isValid()) { map.put (name, (fo != null) ? createReference(fo) : null); } else { if (onlyValid) { fo = null; } } } return fo; }
/** Fires event */ protected final void fileAttributeChanged0 (FileAttributeEvent fileattributeevent) { super.fireFileAttributeChangedEvent(listeners (), fileattributeevent); if(fileattributeevent.getFile().equals(this) && parent != null) { FileAttributeEvent ev = new FileAttributeEvent( parent, fileattributeevent.getFile(), fileattributeevent.getName(), fileattributeevent.getOldValue(), fileattributeevent.getNewValue(), fileattributeevent.isExpected () ); parent.fileAttributeChanged0 (ev); } }
void registerChild (String name) { synchronized (this) { if (map == null) check (); Object o = map.put(name, new WeakReference(null)); if (o != null) { map.put(name, o); } else { String newChildren[] = new String [children.length + 1]; System.arraycopy(children, 0, newChildren, 0, children.length); newChildren [children.length] = name; children = newChildren; } } }
getFileSystem().beginAtomicAction(); final String[] newChildren = getNewChildren(list); final Set addedNames; final Map removedPairs; removedPairs = (map != null) ? dereferenceValues(map) : null;/*<String, AbstractFileObject>*/ map = newMap; children = newChildren; if (fire && addedNames != null && hasAtLeastOneListeners()) { filesCreated(addedNames, expected); removedPairs.remove(removed); filesDeleted(removedPairs, expected); if (fire && added == null && removed == null && !getFileSystem().isReadOnly() && !(this instanceof MultiFileObject)) { Set nameFilter = nameFilter = new HashSet(); if (addedNames != null) nameFilter.addAll(addedNames); if (removedPairs != null) nameFilter.addAll(removedPairs.keySet()); refreshChildren(existingSubFiles(false),nameFilter, expected); getFileSystem().finishAtomicAction();
public final synchronized FileObject[] getChildren() { check(); if (children == null) { return new FileObject[0]; } int size = children.length; ArrayList<FileObject> aList = new ArrayList<FileObject>(); for (int i = 0; i < size; i++) { FileObject f = getChild(children[i]); if (f != null) { aList.add(f); } } return aList.toArray(new FileObject[0]); }