crystalspace.jbind.impl.csutil.cfgfile
Class csConfigFile

java.lang.Object
  extended bycrystalspace.jbind.impl.csNativeObject
      extended bycrystalspace.jbind.impl.csutil.scf.csBase
          extended bycrystalspace.jbind.impl.csutil.cfgfile.csConfigFile
All Implemented Interfaces:
iBase, iConfigFile, iPointer
Direct Known Subclasses:
csConfigManager

public class csConfigFile
extends csBase
implements iConfigFile

Author:
Quentin Anciaux

Field Summary
 
Fields inherited from class crystalspace.jbind.impl.csNativeObject
ImplFactory, nPointer
 
Constructor Summary
csConfigFile(iPointer nPointer)
           
 
Method Summary
 void clear()
          Delete all options and rewind all iterators.
 void deleteKey(java.lang.String Key)
          Delete a key and its value and comment.
 iConfigIterator enumerate()
          Enumerate selected keys.
 iConfigIterator enumerate(java.lang.String Subsection)
          Enumerate selected keys.
 boolean getBool(java.lang.String Key)
          Get a booleanean value from the configuration.
 boolean getBool(java.lang.String Key, boolean Def)
          Get a booleanean value from the configuration.
 java.lang.String getComment(java.lang.String Key)
          Get the comment of the given key, or 0 if no comment exists.
 java.lang.String getEOFComment()
          return the final comment at the end of the configuration file Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.
 java.lang.String getFileName()
          Get configuration file name.
 float getFloat(java.lang.String Key)
          Get a float value from the configuration.
 float getFloat(java.lang.String Key, float Def)
          Get a float value from the configuration.
 int getInt(java.lang.String Key)
          Get an integer value from the configuration.
 int getInt(java.lang.String Key, int Def)
          Get an integer value from the configuration.
static java.lang.Class getInterfaceClass()
           
static java.lang.String getInterfaceName()
           
static int getInterfaceVersion()
           
 java.lang.String getName()
          Return the name of the interface
 java.lang.String getStr(java.lang.String Key)
          Get a string value from the configuration.
 java.lang.String getStr(java.lang.String Key, java.lang.String Def)
          Get a string value from the configuration.
 int getVersion()
          Return the version of the interface
 iVFS getVFS()
          Get the VFS object on which this file is stored (if any);.
static void initSCF()
           
protected  boolean isNativePointerValidSafe(long pointer)
           
 boolean keyExists(java.lang.String Key)
          Test if a key exists.
 boolean load(java.lang.String iFileName)
          Load a configuration file.
 boolean load(java.lang.String iFileName, iVFS vfs)
          Load a configuration file.
 boolean load(java.lang.String iFileName, iVFS vfs, boolean Merge)
          Load a configuration file.
 boolean load(java.lang.String iFileName, iVFS vfs, boolean Merge, boolean NewWins)
          Load a configuration file.
 boolean save()
          Save configuration to the same place from which it was loaded.
 boolean save(java.lang.String iFileName)
          Save configuration into the given file (on VFS or on the physical filesystem);.
 boolean save(java.lang.String iFileName, iVFS vfs)
          Save configuration into the given file (on VFS or on the physical filesystem);.
 void setBool(java.lang.String Key, boolean Value)
          Set a booleanean value.
 void setComment(java.lang.String Key, java.lang.String Text)
          Set the comment for given key.
 void setEOFComment(java.lang.String Text)
          set the final comment at the end of the configuration file Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.
 void setFileName(java.lang.String Name, iVFS vfs)
          Set config file name.
 void setFloat(java.lang.String Key, float Value)
          Set a floating-point value.
 void setInt(java.lang.String Key, int Value)
          Set an integer value.
 void setStr(java.lang.String Key, java.lang.String Val)
          Set an string value.
 boolean subsectionExists(java.lang.String Subsection)
          Test if at least one key exists with the given Subsection prefix.
 
Methods inherited from class crystalspace.jbind.impl.csutil.scf.csBase
decRef, equals, finalize, getRefCount, incRef, nDelete, queryInterface, queryInterfaceSafe
 
Methods inherited from class crystalspace.jbind.impl.csNativeObject
changePointer, getPointer, getPointer, getPointerArray, hashCode, isMemoryOwner, isNativePointerValid, newNativeObject, setMemoryOwner, toString
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface crystalspace.jbind.interfaces.iutil.scf.iBase
decRef, getRefCount, incRef, queryInterface, queryInterfaceSafe
 
Methods inherited from interface crystalspace.jbind.interfaces.iPointer
changePointer, getPointer, isMemoryOwner, setMemoryOwner
 

Constructor Detail

csConfigFile

public csConfigFile(iPointer nPointer)
Parameters:
nPointer -
Method Detail

getVersion

public int getVersion()
Description copied from interface: iBase
Return the version of the interface

Specified by:
getVersion in interface iBase
Specified by:
getVersion in class csBase

getName

public java.lang.String getName()
Description copied from interface: iBase
Return the name of the interface

Specified by:
getName in interface iBase
Specified by:
getName in class csBase

initSCF

public static void initSCF()

getInterfaceVersion

public static int getInterfaceVersion()

getInterfaceName

public static java.lang.String getInterfaceName()

getInterfaceClass

public static java.lang.Class getInterfaceClass()

isNativePointerValidSafe

protected boolean isNativePointerValidSafe(long pointer)
Specified by:
isNativePointerValidSafe in class csNativeObject
See Also:
csNativeObject.isNativePointerValidSafe(long)

clear

public void clear()
Description copied from interface: iConfigFile
Delete all options and rewind all iterators. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
clear in interface iConfigFile
See Also:
iConfigFile.clear()

deleteKey

public void deleteKey(java.lang.String Key)
Description copied from interface: iConfigFile
Delete a key and its value and comment. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
deleteKey in interface iConfigFile
Parameters:
Key -
See Also:
iConfigFile.deleteKey(java.lang.String)

enumerate

public iConfigIterator enumerate()
Description copied from interface: iConfigFile
Enumerate selected keys. If a subsection is given, only those keys which are prefixed by the subsection string will be enumerated. The returned iterator does not yet point to a valid key. You must call Next(); to set it to the first key. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
enumerate in interface iConfigFile
Returns:
See Also:
iConfigFile.enumerate()

enumerate

public iConfigIterator enumerate(java.lang.String Subsection)
Description copied from interface: iConfigFile
Enumerate selected keys. If a subsection is given, only those keys which are prefixed by the subsection string will be enumerated. The returned iterator does not yet point to a valid key. You must call Next(); to set it to the first key. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
enumerate in interface iConfigFile
Parameters:
Subsection -
Returns:
See Also:
iConfigFile.enumerate(java.lang.String)

getBool

public boolean getBool(java.lang.String Key)
Description copied from interface: iConfigFile
Get a booleanean value from the configuration. The optional default value (Def parameter); will be used if the key was not found. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
getBool in interface iConfigFile
Parameters:
Key -
Returns:
See Also:
iConfigFile.getBool(java.lang.String)

getBool

public boolean getBool(java.lang.String Key,
                       boolean Def)
Description copied from interface: iConfigFile
Get a booleanean value from the configuration. The optional default value (Def parameter); will be used if the key was not found. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
getBool in interface iConfigFile
Parameters:
Key -
Def -
Returns:
See Also:
iConfigFile.getBool(java.lang.String, boolean)

getComment

public java.lang.String getComment(java.lang.String Key)
Description copied from interface: iConfigFile
Get the comment of the given key, or 0 if no comment exists. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
getComment in interface iConfigFile
Parameters:
Key -
Returns:
See Also:
iConfigFile.getComment(java.lang.String)

getEOFComment

public java.lang.String getEOFComment()
Description copied from interface: iConfigFile
return the final comment at the end of the configuration file Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
getEOFComment in interface iConfigFile
Returns:
See Also:
iConfigFile.getEOFComment()

getFileName

public java.lang.String getFileName()
Description copied from interface: iConfigFile
Get configuration file name. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, csPrefixConfig, and csDefaultsConfig.

Specified by:
getFileName in interface iConfigFile
Returns:
See Also:
iConfigFile.getFileName()

getFloat

public float getFloat(java.lang.String Key)
Description copied from interface: iConfigFile
Get a float value from the configuration. The optional default value (Def parameter); will be used if the key was not found. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
getFloat in interface iConfigFile
Parameters:
Key -
Returns:
See Also:
iConfigFile.getFloat(java.lang.String)

getFloat

public float getFloat(java.lang.String Key,
                      float Def)
Description copied from interface: iConfigFile
Get a float value from the configuration. The optional default value (Def parameter); will be used if the key was not found. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
getFloat in interface iConfigFile
Parameters:
Key -
Def -
Returns:
See Also:
iConfigFile.getFloat(java.lang.String, float)

getInt

public int getInt(java.lang.String Key)
Description copied from interface: iConfigFile
Get an integer value from the configuration. The optional default value (Def parameter); will be used if the key was not found. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
getInt in interface iConfigFile
Parameters:
Key -
Returns:
See Also:
iConfigFile.getInt(java.lang.String)

getInt

public int getInt(java.lang.String Key,
                  int Def)
Description copied from interface: iConfigFile
Get an integer value from the configuration. The optional default value (Def parameter); will be used if the key was not found. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
getInt in interface iConfigFile
Parameters:
Key -
Def -
Returns:
See Also:
iConfigFile.getInt(java.lang.String, int)

getStr

public java.lang.String getStr(java.lang.String Key)
Description copied from interface: iConfigFile
Get a string value from the configuration. The optional default value (Def parameter); will be used if the key was not found. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
getStr in interface iConfigFile
Parameters:
Key -
Returns:
See Also:
iConfigFile.getStr(java.lang.String)

getStr

public java.lang.String getStr(java.lang.String Key,
                               java.lang.String Def)
Description copied from interface: iConfigFile
Get a string value from the configuration. The optional default value (Def parameter); will be used if the key was not found. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
getStr in interface iConfigFile
Parameters:
Key -
Def -
Returns:
See Also:
iConfigFile.getStr(java.lang.String, java.lang.String)

getVFS

public iVFS getVFS()
Description copied from interface: iConfigFile
Get the VFS object on which this file is stored (if any);. Returns 0 if this file resides within the real (non-VFS); filesystem. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
getVFS in interface iConfigFile
Returns:
See Also:
iConfigFile.getVFS()

keyExists

public boolean keyExists(java.lang.String Key)
Description copied from interface: iConfigFile
Test if a key exists. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
keyExists in interface iConfigFile
Parameters:
Key -
Returns:
See Also:
iConfigFile.keyExists(java.lang.String)

load

public boolean load(java.lang.String iFileName)
Description copied from interface: iConfigFile
Load a configuration file. If the file resides in a real filesystem, rather than a VFS filesystem, then pass 0 for the VFS argument. You can set the Merge flag to merge the newly loaded configuration information into the existing information. If you do so, nothing will happen if the named file doesn't exist. The NewWins flag determines the behavior in case of configuration key conflicts. If true, then the new configuration value replaces the old for that key. If false, then the old value is kept, and the new value is ignored. The recorded file name will be set to the name of the newly loaded file if the Merge flag is false; otherwise it will retain the old name. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
load in interface iConfigFile
Parameters:
iFileName -
Returns:
See Also:
iConfigFile.load(java.lang.String)

load

public boolean load(java.lang.String iFileName,
                    iVFS vfs)
Description copied from interface: iConfigFile
Load a configuration file. If the file resides in a real filesystem, rather than a VFS filesystem, then pass 0 for the VFS argument. You can set the Merge flag to merge the newly loaded configuration information into the existing information. If you do so, nothing will happen if the named file doesn't exist. The NewWins flag determines the behavior in case of configuration key conflicts. If true, then the new configuration value replaces the old for that key. If false, then the old value is kept, and the new value is ignored. The recorded file name will be set to the name of the newly loaded file if the Merge flag is false; otherwise it will retain the old name. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
load in interface iConfigFile
Parameters:
iFileName -
vfs -
Returns:
See Also:
iConfigFile.load(java.lang.String, crystalspace.jbind.interfaces.iutil.vfs.iVFS)

load

public boolean load(java.lang.String iFileName,
                    iVFS vfs,
                    boolean Merge)
Description copied from interface: iConfigFile
Load a configuration file. If the file resides in a real filesystem, rather than a VFS filesystem, then pass 0 for the VFS argument. You can set the Merge flag to merge the newly loaded configuration information into the existing information. If you do so, nothing will happen if the named file doesn't exist. The NewWins flag determines the behavior in case of configuration key conflicts. If true, then the new configuration value replaces the old for that key. If false, then the old value is kept, and the new value is ignored. The recorded file name will be set to the name of the newly loaded file if the Merge flag is false; otherwise it will retain the old name. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
load in interface iConfigFile
Parameters:
iFileName -
vfs -
Merge -
Returns:
See Also:
iConfigFile.load(java.lang.String, crystalspace.jbind.interfaces.iutil.vfs.iVFS, boolean)

load

public boolean load(java.lang.String iFileName,
                    iVFS vfs,
                    boolean Merge,
                    boolean NewWins)
Description copied from interface: iConfigFile
Load a configuration file. If the file resides in a real filesystem, rather than a VFS filesystem, then pass 0 for the VFS argument. You can set the Merge flag to merge the newly loaded configuration information into the existing information. If you do so, nothing will happen if the named file doesn't exist. The NewWins flag determines the behavior in case of configuration key conflicts. If true, then the new configuration value replaces the old for that key. If false, then the old value is kept, and the new value is ignored. The recorded file name will be set to the name of the newly loaded file if the Merge flag is false; otherwise it will retain the old name. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
load in interface iConfigFile
Parameters:
iFileName -
vfs -
Merge -
NewWins -
Returns:
See Also:
iConfigFile.load(java.lang.String, crystalspace.jbind.interfaces.iutil.vfs.iVFS, boolean, boolean)

save

public boolean save(java.lang.String iFileName)
Description copied from interface: iConfigFile
Save configuration into the given file (on VFS or on the physical filesystem);. If the second parameter is skipped, the file will be written to the physical filesystem, otherwise it is stored on given VFS filesystem. This method does not change the internally stored file name. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
save in interface iConfigFile
Parameters:
iFileName -
Returns:
See Also:
iConfigFile.save(java.lang.String)

save

public boolean save(java.lang.String iFileName,
                    iVFS vfs)
Description copied from interface: iConfigFile
Save configuration into the given file (on VFS or on the physical filesystem);. If the second parameter is skipped, the file will be written to the physical filesystem, otherwise it is stored on given VFS filesystem. This method does not change the internally stored file name. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
save in interface iConfigFile
Parameters:
iFileName -
vfs -
Returns:
See Also:
iConfigFile.save(java.lang.String, crystalspace.jbind.interfaces.iutil.vfs.iVFS)

save

public boolean save()
Description copied from interface: iConfigFile
Save configuration to the same place from which it was loaded. Returns true if the save operation succeeded. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
save in interface iConfigFile
Returns:
See Also:
iConfigFile.save()

setBool

public void setBool(java.lang.String Key,
                    boolean Value)
Description copied from interface: iConfigFile
Set a booleanean value. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
setBool in interface iConfigFile
Parameters:
Key -
Value -
See Also:
iConfigFile.setBool(java.lang.String, boolean)

setComment

public void setComment(java.lang.String Key,
                       java.lang.String Text)
Description copied from interface: iConfigFile
Set the comment for given key. In addition to an actual comment, you can use "" for Text to place an empty comment line before this key, or 0 to remove the comment entirely. The comment may contain newline characters. Returns false if the key does not exist. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
setComment in interface iConfigFile
Parameters:
Key -
Text -
See Also:
iConfigFile.setComment(java.lang.String, java.lang.String)

setEOFComment

public void setEOFComment(java.lang.String Text)
Description copied from interface: iConfigFile
set the final comment at the end of the configuration file Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
setEOFComment in interface iConfigFile
Parameters:
Text -
See Also:
iConfigFile.setEOFComment(java.lang.String)

setFileName

public void setFileName(java.lang.String Name,
                        iVFS vfs)
Description copied from interface: iConfigFile
Set config file name. You can use this if you want Save(); to write to another file. This will set the dirty flag. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
setFileName in interface iConfigFile
Parameters:
Name -
vfs -
See Also:
iConfigFile.setFileName(java.lang.String, crystalspace.jbind.interfaces.iutil.vfs.iVFS)

setFloat

public void setFloat(java.lang.String Key,
                     float Value)
Description copied from interface: iConfigFile
Set a floating-point value. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
setFloat in interface iConfigFile
Parameters:
Key -
Value -
See Also:
iConfigFile.setFloat(java.lang.String, float)

setInt

public void setInt(java.lang.String Key,
                   int Value)
Description copied from interface: iConfigFile
Set an integer value. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
setInt in interface iConfigFile
Parameters:
Key -
Value -
See Also:
iConfigFile.setInt(java.lang.String, int)

setStr

public void setStr(java.lang.String Key,
                   java.lang.String Val)
Description copied from interface: iConfigFile
Set an string value. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
setStr in interface iConfigFile
Parameters:
Key -
Val -
See Also:
iConfigFile.setStr(java.lang.String, java.lang.String)

subsectionExists

public boolean subsectionExists(java.lang.String Subsection)
Description copied from interface: iConfigFile
Test if at least one key exists with the given Subsection prefix. Implemented in csWin32RegistryConfig, csConfigFile, csConfigManager, and csDefaultsConfig.

Specified by:
subsectionExists in interface iConfigFile
Parameters:
Subsection -
Returns:
See Also:
iConfigFile.subsectionExists(java.lang.String)