Item item2 = (Item)map.get (fo); if (item2 != null) { DataFolder df = (DataFolder) item2.getDataObjectOrNull(); if (df != null) { VALIDATOR.refreshFolderOf (df);
item.changePrimaryFile (newFile); newFolder.dispose (); list = reassignList (newFile, true);
doh = new Item (fo); map.put (fo, doh); countRegistration(fo); obj = doh.getDataObjectOrNull (); doh = new Item (fo); map.put (fo, doh); countRegistration(fo); doh = new Item (fo); map.put (fo, doh); countRegistration(fo);
DataObject obj = item.getDataObjectOrNull (); if (obj != null) { lp.fireOperationEvent (
/** Checks whether there is a data object with primary file * passed thru the parameter. * * @param fo the file to check * @return data object with fo as primary file or null */ public DataObject find (FileObject fo) { synchronized (this) { Item doh = (Item)map.get (fo); if (doh == null) { return null; } // do not return DOs before their creation were notified to OperationListeners if (toNotify.contains (doh)) { // special test for data objects calling this method from // their own constructor, those are ok to be returned if // they exist List l = (List)FIND.get (); if (l == null || !l.contains (doh)) { return null; } } return doh.getDataObjectOrNull (); } }
/** Create list of all files for given collection of data objects. * @param c collection of DataObjectPool.Item * @return set of files */ private static Set createSetOfAllFiles (Collection c) { HashSet set = new HashSet (c.size () * 7); Iterator it = c.iterator(); while (it.hasNext()) { Item item = (Item)it.next (); DataObject obj = item.getDataObjectOrNull (); if (obj != null) { getPOOL ().waitNotified (obj); set.addAll (obj.files ()); } } return set; }
/** Allows subclasses to discard the object. When an object is discarded, * it is released from the list of objects registered in the system. * Then the contents of the parent folder (if it still exists) are rescanned, which * may result in the creation of a new data object for the primary file. * <P> * The normal use of this method is to change the type of a data object. * Because this would usually only be invoked from * the original data object, it is protected. */ protected void dispose () { DataObjectPool.Item item = this.item; if (item != null) { item.deregister (true); item.setDataObject(null); firePropertyChange (PROP_VALID, Boolean.TRUE, Boolean.FALSE); } }
/** Setter for the data object. Called immediatelly as possible. * @param obj the data object for this item */ public void setDataObject (DataObject obj) { this.obj = new ItemReference (obj, this); if (obj != null && !obj.getPrimaryFile ().isValid ()) { // if the primary file is already invalid => // mark the object as invalid deregister (false); } synchronized (DataObjectPool.getPOOL()) { DataObjectPool.getPOOL().notifyAll(); } }
/** Getter for the data object. * @return the data object * @exception IllegalStateException if the data object has been lost * due to weak references (should not happen) */ public DataObject getDataObject () { DataObject obj = getDataObjectOrNull (); if (obj == null) { throw new IllegalStateException (); } return obj; }
public void fileDeleted (FileEvent fe) { for( Iterator it = getTargets(fe); it.hasNext(); ) { DataObject dobj = ((Item)it.next()).getDataObjectOrNull(); if (dobj != null) dobj.notifyFileDeleted(fe); } }
public void fileRenamed (FileRenameEvent fe) { for( Iterator it = getTargets(fe); it.hasNext(); ) { DataObject dobj = ((Item)it.next()).getDataObjectOrNull(); if (dobj != null) dobj.notifyFileRenamed(fe); } }
/** Deregister one reference. * @param refresh true if the parent folder should be refreshed */ public void deregister (boolean refresh) { getPOOL().deregister (this, refresh); }
public void fileDataCreated (FileEvent fe) { for( Iterator it = getTargets(fe); it.hasNext(); ) { DataObject dobj = ((Item)it.next()).getDataObjectOrNull(); if (dobj != null) dobj.notifyFileDataCreated(fe); } }
public void fileChanged(FileEvent fe) { for( Iterator it = getTargets(fe); it.hasNext(); ) { DataObject dobj = ((Item)it.next()).getDataObjectOrNull(); if (dobj != null) dobj.notifyFileChanged(fe); } }
public void run () throws IOException { files[1] = handleRename (name); if (files[0] != files[1]) item.changePrimaryFile (files[1]); } });
/** Private constructor. At this time the constructor receives * the primary file and pool item where it should register itself. * * @param pf primary file * @param item the item to register into * @param loader loader that created the data object */ private DataObject (FileObject pf, DataObjectPool.Item item, DataLoader loader) { this.item = item; this.loader = loader; item.setDataObject (this); }
public void fileAttributeChanged (FileAttributeEvent fe) { for( Iterator it = getTargets(fe); it.hasNext(); ) { DataObject dobj = ((Item)it.next()).getDataObjectOrNull(); if (dobj != null) dobj.notifyAttributeChanged(fe); } } }
/** Test whether the data object is still valid and usable. * <P> * The object can become invalid when it is deleted, its files are deleted, or * {@link #dispose} is called. * <P> * When the validity of the object changes a property change event is fired, so * anyone can listen and be notified when the object is deleted/disposed. */ public final boolean isValid () { return item.isValid (); }
public void run () throws IOException { handleDelete (); item.deregister(false); item.setDataObject(null); } });
/** Does the cleanup of the reference */ public void run () { item.deregister(false); item = null; }