com.tensegrity.generic.util.prefs
Class PreferenceUtilities

java.lang.Object
  extended bycom.tensegrity.generic.util.prefs.PreferenceUtilities

public class PreferenceUtilities
extends java.lang.Object

Class PreferenceUtilities provides several helpful utility methods. These static methods are useful in situations when dealing with lists of attributes.

Version:
$Id: PreferenceUtilities.java,v 1.24 2006/01/26 17:18:02 MichaelKegel Exp $
Author:
Andreas Ebbert

Method Summary
static void addToFifoList(Preferences prefs, java.lang.String key, java.lang.String value, int listLength)
          Adds the given value to the list of values set for key key.
static void removeFromFifoList(Preferences prefs, java.lang.String key, java.lang.String value)
          Removes value value from the list associated with the given key.
static void resizeList(Preferences prefs, java.lang.String key, int newSize)
          Resizes the list associated to key key to the given size by dropping out all items coming after index newSize.
static java.lang.String shortenFileName(java.lang.String fileName, int len)
          Shortens the given filename to fit length len.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addToFifoList

public static final void addToFifoList(Preferences prefs,
                                       java.lang.String key,
                                       java.lang.String value,
                                       int listLength)
Adds the given value to the list of values set for key key. The element is added with a FIFO-strategy. If the list length exceeds listLength, the first added element in the list will be dropped out. This method is useful, if you want to offer a list of recently used files in your application using the preferences. The value will not be added, if the list already contains it.

Parameters:
prefs - The preferences instance to work on
key - the key of the value list.
value - the value to add to the list.
listLength - the maximum list length.

Find more information in the class documentation


removeFromFifoList

public static final void removeFromFifoList(Preferences prefs,
                                            java.lang.String key,
                                            java.lang.String value)
Removes value value from the list associated with the given key.

Parameters:
prefs - The preferences instance to work on
key - the key of the list.
value - the value to be removed.

Find more information in the class documentation


resizeList

public static final void resizeList(Preferences prefs,
                                    java.lang.String key,
                                    int newSize)
Resizes the list associated to key key to the given size by dropping out all items coming after index newSize. Nothing will be done if the new size is greater than the number of elements currently stored in the list associated with the given key.

Parameters:
prefs - The preferences instance to work on
key - the key associated to the list.
newSize - the new size of the list.

Find more information in the class documentation


shortenFileName

public static final java.lang.String shortenFileName(java.lang.String fileName,
                                                     int len)
Shortens the given filename to fit length len. It tries to get as much of the original filename into the shortened version as possible.

Parameters:
fileName - the filename to shorten.
len - the desired length.
Returns:
the shortened filename.
Throws:
InvalidArgumentException - if fileName is null or len lesser than a minimum length.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.