org.kde.koala
Class KConfigGroupSaver

java.lang.Object
  extended by org.kde.koala.KConfigGroupSaver
All Implemented Interfaces:
org.kde.qt.QtSupport

public class KConfigGroupSaver
extends java.lang.Object
implements org.kde.qt.QtSupport

Helper class to facilitate working with KConfig / KSimpleConfig groups. Careful programmers always set the group of a KConfig KSimpleConfig object to the group they want to read from and set it back to the old one of afterwards. This is usually written as:

 String oldgroup config.group();
 config.setGroup( "TheGroupThatIWant" );
 ...
 config.writeEntry( "Blah", "Blubb" );
 config.setGroup( oldgroup );
 
In order to facilitate this task, you can use KConfigGroupSaver. Simply construct such an object ON THE STACK when you want to switch to a new group. Then, when the object goes out of scope, the group will automatically be restored. If you want to use several different groups within a function or method, you can still use KConfigGroupSaver: Simply enclose all work with one group (including the creation of the KConfigGroupSaver object) in one block. KConfigGroup provides similar functionality in a more object oriented way.

Author:
Matthias Kalle Dalheimer
See Also:
KConfigBase, KConfig, KSimpleConfig, KConfigGroup

Constructor Summary
protected KConfigGroupSaver(java.lang.Class dummy)
           
  KConfigGroupSaver(KConfigBase config, java.lang.String group)
          Constructor.
 
Method Summary
 KConfigBase config()
           
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
protected  void finalize()
          Deletes the wrapped C++ instance
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KConfigGroupSaver

protected KConfigGroupSaver(java.lang.Class dummy)

KConfigGroupSaver

public KConfigGroupSaver(KConfigBase config,
                         java.lang.String group)
Constructor. You pass a pointer to the KConfigBase-derived object you want to work with and a string indicating the _new_ group.

Parameters:
config - The KConfigBase-derived object this KConfigGroupSaver works on.
group - The new group that the config object should switch to.
Method Detail

config

public KConfigBase config()

finalize

protected void finalize()
                 throws java.lang.InternalError
Deletes the wrapped C++ instance

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.InternalError

dispose

public void dispose()
Delete the wrapped C++ instance ahead of finalize()


isDisposed

public boolean isDisposed()
Has the wrapped C++ instance been deleted?