This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 29354
Collapse All | Expand All

(-)openide/src/org/openide/filesystems/MultiFileObject.java (-6 / +6 lines)
Lines 138-144 Link Here
138
        if (led != null) {
138
        if (led != null) {
139
            // otherwise leave the leader to be last file that represented
139
            // otherwise leave the leader to be last file that represented
140
            // this one
140
            // this one
141
            if (led != this.leader && this.leader != null) {
141
            if (!led.equals(this.leader) && this.leader != null) {
142
                // isValid prevents here from firing events after MFO.delete
142
                // isValid prevents here from firing events after MFO.delete
143
                if (isData() && isValid ())
143
                if (isData() && isValid ())
144
                    fileChanged0 (new FileEvent (this));
144
                    fileChanged0 (new FileEvent (this));
Lines 191-197 Link Here
191
                    FileObject oldLeader = findLeader (oldFileSystems, path);
191
                    FileObject oldLeader = findLeader (oldFileSystems, path);
192
                    FileObject newLeader = findLeader (fileSystems, path);
192
                    FileObject newLeader = findLeader (fileSystems, path);
193
                    
193
                    
194
                    if (oldLeader != null && newLeader != null && oldLeader != newLeader) {
194
                    if (oldLeader != null && newLeader != null && !oldLeader.equals(newLeader)) {
195
                        mfo.fileAttributeChanged0(new FileAttributeEvent(mfo,null,null,null));
195
                        mfo.fileAttributeChanged0(new FileAttributeEvent(mfo,null,null,null));
196
                    }
196
                    }
197
                }
197
                }
Lines 631-637 Link Here
631
            FileObject localFo = lastAttrCacheFile;
631
            FileObject localFo = lastAttrCacheFile;
632
            String cachedAttrName = lastAttrCacheName;
632
            String cachedAttrName = lastAttrCacheName;
633
            
633
            
634
            if (localFo != null && localFo != this && cachedAttrName.equals(attrName)) { 
634
            if (localFo != null && !localFo.equals(this) && cachedAttrName.equals(attrName)) { 
635
635
636
                if (localFo.isRoot() && prefixattr != null) {
636
                if (localFo.isRoot() && prefixattr != null) {
637
                    try {
637
                    try {
Lines 1209-1215 Link Here
1209
     */
1209
     */
1210
    public void fileChanged(FileEvent fe) {
1210
    public void fileChanged(FileEvent fe) {
1211
        FileObject changedFile = this;
1211
        FileObject changedFile = this;
1212
        if (fe.getSource() == leader && hasAtLeastOneListeners() && !fe.firedFrom(markAtomicAction)) {
1212
        if (fe.getSource().equals(leader) && hasAtLeastOneListeners() && !fe.firedFrom(markAtomicAction)) {
1213
            /**There should not dissapear information about source and changed file*/
1213
            /**There should not dissapear information about source and changed file*/
1214
            if (!fe.getFile().equals(fe.getSource()))
1214
            if (!fe.getFile().equals(fe.getSource()))
1215
                changedFile = getFileObject(fe.getFile().getName(), fe.getFile().getExt());
1215
                changedFile = getFileObject(fe.getFile().getName(), fe.getFile().getExt());
Lines 1258-1270 Link Here
1258
        
1258
        
1259
        /** If change is not fired from leader then leader may mask this attribute
1259
        /** If change is not fired from leader then leader may mask this attribute
1260
         *  and then event should not be fired */
1260
         *  and then event should not be fired */
1261
        if (fe.getFile() != leader && fe.getName() != null && 
1261
        if (!fe.getFile().equals(leader) && fe.getName() != null && 
1262
            leader.getAttribute (fe.getName()) != null)
1262
            leader.getAttribute (fe.getName()) != null)
1263
            return;
1263
            return;
1264
            
1264
            
1265
        /** If change is not fired from leader then another delegate may mask this attribute
1265
        /** If change is not fired from leader then another delegate may mask this attribute
1266
         *  and then event should not be fired. */
1266
         *  and then event should not be fired. */
1267
        if (fe.getFile() != leader && fe.getNewValue() != null && fe.getName() != null && 
1267
        if (!fe.getFile().equals(leader) && fe.getNewValue() != null && fe.getName() != null && 
1268
            !fe.getNewValue().equals (getAttribute (fe.getName())))
1268
            !fe.getNewValue().equals (getAttribute (fe.getName())))
1269
            return;
1269
            return;
1270
                   
1270
                   
(-)core/src/org/netbeans/core/projects/cache/BinaryFS.java (-1 / +93 lines)
Lines 294-305 Link Here
294
        private boolean initialized = false;
294
        private boolean initialized = false;
295
        private Map attrs = Collections.EMPTY_MAP; //Map<String->Attribute>
295
        private Map attrs = Collections.EMPTY_MAP; //Map<String->Attribute>
296
        
296
        
297
        // for equality comparisons
298
        private int hash = 0;
299
        
297
        public BFSBase(String name, FileObject parent, int offset) {
300
        public BFSBase(String name, FileObject parent, int offset) {
298
            this.name = name;
301
            this.name = name;
299
            this.parent = parent;
302
            this.parent = parent;
300
            this.offset = offset;
303
            this.offset = offset;
301
        }
304
        }
302
        
305
        
306
        public boolean equals(Object o) {
307
            if (!(o instanceof BFSBase)) return false;
308
            BFSBase f = (BFSBase)o;
309
            if (f.hashCode() != hashCode()) return false;
310
            return f.getPath().equals(getPath()) && specificEquals(f);
311
        }
312
        
313
        public int hashCode() {
314
            if (hash == 0) {
315
                hash = getPath().hashCode() ^ (specificHashCode() + 265478956);
316
            }
317
            return hash;
318
        }
319
        
320
        protected abstract boolean specificEquals(BFSBase f);
321
        protected abstract int specificHashCode();
322
        
303
        /** no-op implementations of read-only, fixed, never firing FS */
323
        /** no-op implementations of read-only, fixed, never firing FS */
304
        public void addFileChangeListener(FileChangeListener fcl) {}
324
        public void addFileChangeListener(FileChangeListener fcl) {}
305
        public void removeFileChangeListener(FileChangeListener fcl) {}
325
        public void removeFileChangeListener(FileChangeListener fcl) {}
Lines 636-641 Link Here
636
        public boolean isFolder() {
657
        public boolean isFolder() {
637
            return false;
658
            return false;
638
        }
659
        }
660
        
661
        private byte[] data() throws IOException {
662
            if (len == -1) throw new IllegalArgumentException();
663
            return new Pointer(contentOffset).getBytes(len);
664
        }
639
       
665
       
640
        /** Get input stream. */
666
        /** Get input stream. */
641
        public InputStream getInputStream() throws java.io.FileNotFoundException {
667
        public InputStream getInputStream() throws java.io.FileNotFoundException {
Lines 643-649 Link Here
643
            try {
669
            try {
644
                return len == -1 ?          // URI or not
670
                return len == -1 ?          // URI or not
645
                    new URL(uri).openConnection().getInputStream() : // len from URI
671
                    new URL(uri).openConnection().getInputStream() : // len from URI
646
                    new ByteArrayInputStream(new Pointer(contentOffset).getBytes(len));
672
                    new ByteArrayInputStream(data());
647
            } catch (Exception e) {
673
            } catch (Exception e) {
648
                FileNotFoundException x = new FileNotFoundException (e.getMessage());
674
                FileNotFoundException x = new FileNotFoundException (e.getMessage());
649
                ErrorManager.getDefault().annotate(x,e);
675
                ErrorManager.getDefault().annotate(x,e);
Lines 676-682 Link Here
676
            contentOffset = ptr.getOffset();
702
            contentOffset = ptr.getOffset();
677
            if (len == -1) uri = ptr.getString();
703
            if (len == -1) uri = ptr.getString();
678
        }
704
        }
705
        
706
        // hashCode and equals compare data: URI or byte contents.
679
707
708
        protected int specificHashCode() {
709
            initialize();
710
            if (len == -1) {
711
                return uri.hashCode();
712
            } else {
713
                byte[] data;
714
                try {
715
                    data = data();
716
                } catch (IOException ioe) {
717
                    return 55;
718
                }
719
                int x = 0;
720
                for (int i = 0; i < data.length; i++) {
721
                    x += 876824551;
722
                    x ^= data[i];
723
                }
724
                return x;
725
            }
726
        }
727
        
728
        protected boolean specificEquals(BFSBase _f) {
729
            if (!(_f instanceof BFSFile)) return false;
730
            BFSFile f = (BFSFile)_f;
731
            initialize();
732
            f.initialize();
733
            if (len == -1 && f.len == -1) {
734
                return uri.equals(f.uri);
735
            } else if (len != -1 && f.len != -1) {
736
                byte[] data, fdata;
737
                try {
738
                    data = data();
739
                    fdata = f.data();
740
                } catch (IOException ioe) {
741
                    return false;
742
                }
743
                if (data.length != fdata.length) return false;
744
                for (int i = 0; i < data.length; i++) {
745
                    if (data[i] != fdata[i]) return false;
746
                }
747
                return true;
748
            } else {
749
                return false;
750
            }
751
        }
752
        
680
    }
753
    }
681
    
754
    
682
    private class BFSFolder extends BFSBase {
755
    private class BFSFolder extends BFSBase {
Lines 742-746 Link Here
742
                }
815
                }
743
            }
816
            }
744
        }
817
        }
818
        
819
        // hashCode and equals compare contents recursively.
820
        
821
        protected int specificHashCode() {
822
            initialize();
823
            int x = 0;
824
            Iterator it = childrenMap.values().iterator();
825
            while (it.hasNext()) {
826
                x ^= ((BFSBase)it.next()).hashCode();
827
            }
828
            return x;
829
        }
830
        
831
        protected boolean specificEquals(BFSBase _f) {
832
            if (!(_f instanceof BFSFolder)) return false;
833
            BFSFolder f = (BFSFolder)_f;
834
            initialize();
835
            return childrenMap.equals(f.childrenMap);
836
        }
837
        
745
    }
838
    }
746
}
839
}

Return to bug 29354