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.

Bug 29608 - Improve useability of FileSets API
Summary: Improve useability of FileSets API
Status: CLOSED INVALID
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Infrastructure (show other bugs)
Version: 3.x
Hardware: Sun Solaris
: P1 blocker (vote)
Assignee: Jan Pokorsky
URL:
Keywords: API
Depends on:
Blocks:
 
Reported: 2002-12-17 23:34 UTC by Chris Webster
Modified: 2004-04-19 16:17 UTC (History)
0 users

See Also:
Issue Type: TASK
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Webster 2002-12-17 23:34:51 UTC
The following code slide illustrates a problem
which was detected when using
FileSets.createFileObjectSet. The documentation
states that a FileObject should be returned from
the iterator (since keepBrokenLinks is false
broken links would not persist). This is breaking
a regression test in the compilation module.

MutableFileSet mfs =
FileSets.createFileObjectSet(false,
ReferenceResolver.getDefault() );
mfs.add(aFileObject);
Iterator it = mfs.iterator();
while (it.hasNext()) {
    Object fobj = it.next();
    //fobj.getClass().equals(java.net.URL) 
    // instead of FileObject
}
Comment 1 Vitezslav Stejskal 2002-12-19 21:27:02 UTC
Actually it is correct. The usage of FileSets API is pretty cryptic in
this area. I think we should change it somehow, but you can remember
simple rule for now. All instances of FileSet provide iterators which
return URL when you call next(), no matter what kind of FileSet you
have created. If you really want to have typed iterator (that one
returning FileObject or DataObject) you have to use appropriate
factory method which takes the fileset and returns java.util.Set. Then
take iterator from that Set and you can safely typecast objects
returned from this iterator's next() method.

Please, don't confuse the two createFileObjectSet methods - first
returning MutableFileSet and second returning java.util.Set.

We talked already about this with jpokorsky and he had some idea about
how to improve the API as I can remember. Adding keywords to make this
issue more visible :-). Honzo, please, look at it.
Comment 2 Chris Webster 2002-12-19 22:05:56 UTC
The problem with the api here is that if I use the method returning
Set then I no longer have the ordering guarantee, since java.util.Set
does not guarantee ordering (java.util.List guarantee ordering), which
violates the contract or will the supplied Set preserve ordering.
Comment 3 Vitezslav Stejskal 2002-12-19 22:25:21 UTC
I think that returned Set will keep the ordering if source FileSet
does. The Set delegates to the FileSet passed to the factory method
which created this Set. In other words the Set is just another way how
to access contents of the FileSet and its behavior is equivalent to
the source FileSet

IMO the javadoc describes poorly concepts of FileSets API, at least I
would not guess this behavior without knowing the code. (E.g. javadoc
says that createFileObjectSet(FileSet, boolean) returns immutable set
of FileObjects acquired from the source FileSet. It's only partialy
true, the Set can't be modified externally, but its contents can
change when the source FileSet's contents changes.)
Comment 4 Jan Pokorsky 2003-01-13 11:36:59 UTC
You have to use Set FileSets.createFileObjectSet(FileSet src, boolean
brokenLinks) to obtain fileset's items as translated FileObject.

And yes, the Set returned from FileSets.createXXXObjectSet keeps
ordering of the original fileset. I can update the javadoc to mention
keeping the ordering feature by the returned Set.
Comment 5 Jan Becicka 2003-11-25 14:02:53 UTC
As described in
http://www.netbeans.org/servlets/ReadMsg?msgId=619519&listName=nbdiscuss the
current work on projects prototype has been stopped.

Marking issue as VERIFIED --->
Comment 6 Jan Becicka 2003-11-25 14:11:53 UTC
---> CLOSED