com.sun.electric.database.text
Class Pref

java.lang.Object
  extended by com.sun.electric.database.text.Pref

public class Pref
extends java.lang.Object

This class manages options. There are two types of options: appearance and meaning. Appearance options affect the way that the design is presented to the user. Examples are grid dot spacing, layer stipple patterns, etc. Meaning options affect the way that a design is produced (for fabrication, simulation, and other outputs). Examples are CIF layer names, technology options, etc.)

All options are saved in a machine-specific way by the Java Preferences class. In addition, "meaning" options are stored in libraries. When the libraries are read back into Electric, the stored meaning options are checked against the current meaning options, the two are reconciled.

Where are these options stored? It varies with each operating system.


Nested Class Summary
static class Pref.Group
           
static class Pref.PrefChangeBatch
           
static class Pref.PrefType
           
 
Constructor Summary
protected Pref(Pref.Group group, java.lang.String name)
          The constructor for the Pref.
protected Pref(java.util.prefs.Preferences prefs, java.lang.String name)
          The constructor for the Pref.
 
Method Summary
static void delayPrefFlushing()
          Method to delay the saving of preferences to disk.
static void exportPrefs(java.lang.String fileName)
          Method to export the preferences to an XML file.
static void gatherPrefChanges()
          Method to start accumulation of Pref changes.
 boolean getBoolean()
          Method to get the boolean value on this Pref object.
 boolean getBooleanFactoryValue()
          Method to get the factory-default boolean value of this Pref object.
 double getDouble()
          Method to get the double value on this Pref object.
 double getDoubleFactoryValue()
          Method to get the factory-default double value of this Pref object.
 java.lang.Object getFactoryValue()
          Method to get the factory-default value of this Pref object.
 int getInt()
          Method to get the integer value on this Pref object.
 int getIntFactoryValue()
          Method to get the factory-default integer value of this Pref object.
 long getLong()
          Method to get the long value on this Pref object.
 long getLongFactoryValue()
          Method to get the factory-default long value of this Pref object.
static Pref.PrefChangeBatch getPrefChanges()
          Method to get the accumulated Pref changes.
 java.lang.String getPrefName()
          Method to get the name of this Pref object.
 java.lang.String getString()
          Method to get the string value on this Pref object.
 java.lang.String getStringFactoryValue()
          Method to get the factory-default String value of this Pref object.
 Pref.PrefType getType()
          Method to get the type of this Pref object.
 java.lang.Object getValue()
          Method to get the value of this Pref object as an Object.
static Pref.Group groupForPackage(java.lang.Class classFromPackage)
           
static void implementPrefChanges(Pref.PrefChangeBatch obj)
          Method to make a collection of preference changes.
static void importPrefs(java.lang.String fileName)
          Method used in regressions so it has to be public.
static void importPrefs(java.net.URL fileURL)
           
protected  void initBoolean(boolean factory)
          Factory methods to create a boolean Pref objects.
protected  void initDouble(double factory)
          Factory methods to create a double Pref objects.
protected  void initInt(int factory)
          Factory methods to create an integer Pref objects.
protected  void initLong(long factory)
          Factory methods to create a long Pref objects.
protected  void initString(java.lang.String factory)
          Factory methods to create a string Pref objects.
static Pref makeBooleanPref(java.lang.String name, Pref.Group group, boolean factory)
          Factory methods to create a boolean Pref objects.
static Pref makeDoublePref(java.lang.String name, Pref.Group group, double factory)
          Factory methods to create a double Pref objects.
static Pref makeIntPref(java.lang.String name, Pref.Group group, int factory)
          Factory methods to create an integer Pref objects.
static Pref makeLongPref(java.lang.String name, Pref.Group group, long factory)
          Factory methods to create a long Pref objects.
static Pref makeStringPref(java.lang.String name, Pref.Group group, java.lang.String factory)
          Factory methods to create a string Pref objects.
static Pref makeStringPref(java.lang.String name, java.util.prefs.Preferences prefs, java.lang.String factory)
           
static void printAllPrefs(java.io.PrintStream out)
           
static void resumePrefFlushing()
          Method to resume the saving of preferences to disk.
 void setBoolean(boolean v)
          Method to set a new boolean value on this Pref object.
 boolean setDouble(double v)
          Method to set a new double value on this Pref object.
 void setInt(int v)
          Method to set a new integer value on this Pref object.
 void setLong(long v)
          Method to set a new long value on this Pref object.
 void setString(java.lang.String str)
          Method to set a new string value on this Pref object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pref

protected Pref(java.util.prefs.Preferences prefs,
               java.lang.String name)
The constructor for the Pref.

Parameters:
name - the name of this Pref.

Pref

protected Pref(Pref.Group group,
               java.lang.String name)
The constructor for the Pref.

Parameters:
name - the name of this Pref.
Method Detail

groupForPackage

public static Pref.Group groupForPackage(java.lang.Class classFromPackage)

importPrefs

public static void importPrefs(java.lang.String fileName)
Method used in regressions so it has to be public.

Parameters:
fileName -

importPrefs

public static void importPrefs(java.net.URL fileURL)

exportPrefs

public static void exportPrefs(java.lang.String fileName)
Method to export the preferences to an XML file. This function is public due to the regressions.

Parameters:
fileName - the file to write.

initBoolean

protected void initBoolean(boolean factory)
Factory methods to create a boolean Pref objects. The proper way to create a boolean Pref is with makeBooleanPref; use of this method is only for subclasses.

Parameters:
factory - the "factory" default value (if nothing is stored).

makeBooleanPref

public static Pref makeBooleanPref(java.lang.String name,
                                   Pref.Group group,
                                   boolean factory)
Factory methods to create a boolean Pref objects.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

initInt

protected void initInt(int factory)
Factory methods to create an integer Pref objects. The proper way to create an integer Pref is with makeIntPref; use of this method is only for subclasses.

Parameters:
factory - the "factory" default value (if nothing is stored).

makeIntPref

public static Pref makeIntPref(java.lang.String name,
                               Pref.Group group,
                               int factory)
Factory methods to create an integer Pref objects.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

initLong

protected void initLong(long factory)
Factory methods to create a long Pref objects. The proper way to create a long Pref is with makeLongPref; use of this method is only for subclasses.

Parameters:
factory - the "factory" default value (if nothing is stored).

makeLongPref

public static Pref makeLongPref(java.lang.String name,
                                Pref.Group group,
                                long factory)
Factory methods to create a long Pref objects.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

initDouble

protected void initDouble(double factory)
Factory methods to create a double Pref objects. The proper way to create a double Pref is with makeDoublePref; use of this method is only for subclasses.

Parameters:
factory - the "factory" default value (if nothing is stored).

makeDoublePref

public static Pref makeDoublePref(java.lang.String name,
                                  Pref.Group group,
                                  double factory)
Factory methods to create a double Pref objects.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

initString

protected void initString(java.lang.String factory)
Factory methods to create a string Pref objects. The proper way to create a string Pref is with makeStringPref; use of this method is only for subclasses.

Parameters:
factory - the "factory" default value (if nothing is stored).

makeStringPref

public static Pref makeStringPref(java.lang.String name,
                                  Pref.Group group,
                                  java.lang.String factory)
Factory methods to create a string Pref objects.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

makeStringPref

public static Pref makeStringPref(java.lang.String name,
                                  java.util.prefs.Preferences prefs,
                                  java.lang.String factory)

getBoolean

public boolean getBoolean()
Method to get the boolean value on this Pref object. The object must have been created as "boolean".

Returns:
the boolean value on this Pref object.

getInt

public int getInt()
Method to get the integer value on this Pref object. The object must have been created as "integer".

Returns:
the integer value on this Pref object.

getLong

public long getLong()
Method to get the long value on this Pref object. The object must have been created as "long".

Returns:
the long value on this Pref object.

getDouble

public double getDouble()
Method to get the double value on this Pref object. The object must have been created as "double".

Returns:
the double value on this Pref object.

getString

public java.lang.String getString()
Method to get the string value on this Pref object. The object must have been created as "string".

Returns:
the string value on this Pref object.

getFactoryValue

public java.lang.Object getFactoryValue()
Method to get the factory-default value of this Pref object.

Returns:
the factory-default value of this Pref object.

getBooleanFactoryValue

public boolean getBooleanFactoryValue()
Method to get the factory-default boolean value of this Pref object.

Returns:
the factory-default boolean value of this Pref object.

getIntFactoryValue

public int getIntFactoryValue()
Method to get the factory-default integer value of this Pref object.

Returns:
the factory-default integer value of this Pref object.

getLongFactoryValue

public long getLongFactoryValue()
Method to get the factory-default long value of this Pref object.

Returns:
the factory-default long value of this Pref object.

getDoubleFactoryValue

public double getDoubleFactoryValue()
Method to get the factory-default double value of this Pref object.

Returns:
the factory-default double value of this Pref object.

getStringFactoryValue

public java.lang.String getStringFactoryValue()
Method to get the factory-default String value of this Pref object.

Returns:
the factory-default String value of this Pref object.

getPrefName

public java.lang.String getPrefName()
Method to get the name of this Pref object.

Returns:
the name of this Pref object.

getValue

public java.lang.Object getValue()
Method to get the value of this Pref object as an Object. The proper way to get the current value is to use one of the type-specific methods such as getInt(), getBoolean(), etc.

Returns:
the Object value of this Pref object.

getType

public Pref.PrefType getType()
Method to get the type of this Pref object.

Returns:
an integer type: either BOOLEAN, INTEGER, LONG, DOUBLE, or STRING.

gatherPrefChanges

public static void gatherPrefChanges()
Method to start accumulation of Pref changes. All changes to preferences after this call are gathered, and not actually implemented. Call "getPrefChanges()" to get the gathered changes, and call "implementPrefChanges()" to actually make the changes.


getPrefChanges

public static Pref.PrefChangeBatch getPrefChanges()
Method to get the accumulated Pref changes. In order to make preference changes on the server, it is necessary to gather them on the client, and send the changes to the server for actual change. This method runs on the client and gets a serializable object that can be sent to the server.

Returns:
a collection of changes to preferences that have been made since the call to "gatherPrefChanges()". Call "implementPrefChanges()" with the returned collection to actually make the changes.

implementPrefChanges

public static void implementPrefChanges(Pref.PrefChangeBatch obj)
Method to make a collection of preference changes. In order to make preference changes on the server, it is necessary to gather them on the client, and send the changes to the server for actual change. This method runs on the server.

Parameters:
obj - the collection of preference changes.

delayPrefFlushing

public static void delayPrefFlushing()
Method to delay the saving of preferences to disk. Since individual saving is time-consuming, batches of preference changes are wrapped with this, and "resumePrefFlushing()".


resumePrefFlushing

public static void resumePrefFlushing()
Method to resume the saving of preferences to disk. Since individual saving is time-consuming, batches of preference changes are wrapped with this, and "resumePrefFlushing()". Besides resuming saving, this method also saves anything queued while saving was delayed.


setBoolean

public void setBoolean(boolean v)
Method to set a new boolean value on this Pref object.

Parameters:
v - the new boolean value of this Pref object.

setInt

public void setInt(int v)
Method to set a new integer value on this Pref object.

Parameters:
v - the new integer value of this Pref object.

setLong

public void setLong(long v)
Method to set a new long value on this Pref object.

Parameters:
v - the new long value of this Pref object.

setDouble

public boolean setDouble(double v)
Method to set a new double value on this Pref object.

Parameters:
v - the new double value of this Pref object.
Returns:
true if preference was really changed.

setString

public void setString(java.lang.String str)
Method to set a new string value on this Pref object.

Parameters:
str - the new string value of this Pref object.

printAllPrefs

public static void printAllPrefs(java.io.PrintStream out)