What are *.settings files?

Apache NetBeans Wiki Index

Note: These pages are being reviewed.

.settings files are similar to [[DevFaqInstanceDataObject| .instance files]], with the difference that they are XML format, and can contain serialized data rather than just default instances.

Since the introduction of [http://bits.netbeans.org/dev/javadoc/org-openide-util/org/openide/util/NbPreferences.html NbPreferences] to replace [http://bits.netbeans.org/dev/javadoc/org-openide-options/org/openide/options/SystemOption.html SystemOption], very little new code uses these files, and they should be considered semi-deprecated. They are difficult and error-prone to use, and have a fair amount of overhead. The Window System still requires them to be used to persist the state of opened windows/tabs (caret position, what file is opened, or other state that should be restored when reopening a [http://bits.netbeans.org/dev/javadoc/org-openide-windows/org/openide/windows/TopComponent.html TopComponent] after a restart) across application runs.

A .settings file can encode the entire parent class and interface hierarchy of the object it represents, so that a query about whether an object of a given type is present (such as using Lookups.forPath("path/to/folder").allItems()) can be answered without actually creating an instance of the object.

Settings files are also useful if you are declaring some objects in a layer file (see DevFaqModulesLayerFile) and intend to write them back out to disk after they have been modified in-memory (note this involves writing ugly and inefficient hexadecimal-encoded serialized data into XML files - if the object is a singleton, using NbPreferences will be both more efficient and more readable).

Example

<?xml version="1.0"?>
<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN"
                          "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
<settings version="1.0">
    <module name="org.netbeans.core.io.ui/1" spec="1.6"/>
    <instanceof class="org.openide.windows.TopComponent"/>
    <instanceof class="org.netbeans.core.io.ui.IOWindow$IOWindowImpl"/>
    <serialdata class="org.netbeans.core.io.ui.IOWindow$IOWindowImpl">
        ACED0005737200296F72672E6F70656E6964652E7...
    </serialdata>
</settings>