You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Oliver Kopp <ko...@gmail.com> on 2013/05/05 01:17:27 UTC

[configuration] Intenttion of class "FileBased"

Hi,

I'm working with the trunk version of apache.commons.configuration. There,
FileHandler allows to have passed a "FileBased" object in the constructor.
I thought, I could implement that interface to provide an abstraction to
the underlying file system. However, if I do it htat way, there is an
exception "No file name has been set!". When going through the code, it
seems that this object is the internal data storage for the configuration
and not the external file storage.

Possibly, just the header comments of this constructor should be updated.
Like sort of saying "this constructor is for internal use only".

Cheers,

Oliver

Re: [configuration] Intenttion of class "FileBased"

Posted by Oliver Heger <ol...@oliver-heger.de>.
Hi Oliver,

great to get some feedback on the new re-designed trunk!

Am 05.05.2013 01:17, schrieb Oliver Kopp:
> Hi,
>
> I'm working with the trunk version of apache.commons.configuration. There,
> FileHandler allows to have passed a "FileBased" object in the constructor.
> I thought, I could implement that interface to provide an abstraction to
> the underlying file system. However, if I do it htat way, there is an
> exception "No file name has been set!". When going through the code, it
> seems that this object is the internal data storage for the configuration
> and not the external file storage.
>
> Possibly, just the header comments of this constructor should be updated.
> Like sort of saying "this constructor is for internal use only".

The purpose of FileHandler is to manage a file description in various 
formats (File, URL, file name, etc.). It can be associated with a 
FileBased object which has a read() and a write() method and thus more 
or less defines the content of the file.

The typical usage scenario is that you create a FileHandler and 
associate it with a FileBased object (all file-based configurations now 
implement this interface). Then you use some of the set() methods to 
define the file name. Finally, you can call load() to get the FileBased 
object loaded. Alternatively, you can use one of the load() methods 
expecting a parameter (again various parameter types are supported).

There is still the FileSystem class which provides an abstraction over 
concrete file operations. So this is probably the class you are after. 
(Note: I plan to move this class also into the io package. And maybe it 
can be a bit simplified.)

HTH
Oliver

>
> Cheers,
>
> Oliver
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org