org.seasar.portlet.util
クラス PortletPreferencesUtil

java.lang.Object
  上位を拡張 org.seasar.portlet.util.PortletPreferencesUtil

public class PortletPreferencesUtil
extends java.lang.Object

This class is a utility class to use PortletPreference on Seasar2 environment.

作成者:
Shinsuke Sugaya

コンストラクタの概要
PortletPreferencesUtil()
           
 
メソッドの概要
static java.util.Map getMap()
          Returns a Map of the preferences.
static java.util.Enumeration getNames()
          Returns all of the keys that have an associated value, or an empty Enumeration if no keys are available.
static javax.portlet.PortletPreferences getPortletPreferences()
           
static java.lang.String getValue(java.lang.String key, java.lang.String def)
          Returns the first String value associated with the specified key of this preference.
static java.lang.String[] getValues(java.lang.String key, java.lang.String[] def)
          Returns the String array value associated with the specified key in this preference.
static boolean isReadOnly(java.lang.String key)
          Returns true, if the value of this key cannot be modified by the user.
static void reset(java.lang.String key)
          Resets or removes the value associated with the specified key.
static void setValue(java.lang.String key, java.lang.String value)
          Associates the specified String value with the specified key in this preference.
static void setValues(java.lang.String key, java.lang.String[] values)
          Associates the specified String array value with the specified key in this preference.
static void store()
          Commits all changes made to the preferences via the set methods in the persistent store.
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

PortletPreferencesUtil

public PortletPreferencesUtil()
メソッドの詳細

getPortletPreferences

public static javax.portlet.PortletPreferences getPortletPreferences()

isReadOnly

public static boolean isReadOnly(java.lang.String key)
Returns true, if the value of this key cannot be modified by the user.

Modifiable preferences can be changed by the portlet in any standard portlet mode (EDIT, HELP, VIEW). Per default every preference is modifiable.

Read-only preferences cannot be changed by the portlet in any standard portlet mode, but inside of custom modes it may be allowed changing them. Preferences are read-only, if they are defined in the deployment descriptor with read-only set to true, or if the portlet container restricts write access.

戻り値:
false, if the value of this key can be changed, or if the key is not known
例外:
java.lang.IllegalArgumentException - if key is null.

getValue

public static java.lang.String getValue(java.lang.String key,
                                        java.lang.String def)
Returns the first String value associated with the specified key of this preference. If there is one or more preference values associated with the given key it returns the first associated value. If there are no preference values associated with the given key, or the backing preference database is unavailable, it returns the given default value.

パラメータ:
key - key for which the associated value is to be returned
def - the value to be returned in the event that there is no value available associated with this key.
戻り値:
the value associated with key, or def if no value is associated with key, or the backing store is inaccessible.
例外:
java.lang.IllegalArgumentException - if key is null. (A null value for def is permitted.)
関連項目:
getValues(String, String[])

getValues

public static java.lang.String[] getValues(java.lang.String key,
                                           java.lang.String[] def)
Returns the String array value associated with the specified key in this preference.

Returns the specified default if there is no value associated with the key, or if the backing store is inaccessible.

If the implementation supports stored defaults and such a default exists and is accessible, it is used in favor of the specified default.

パラメータ:
key - key for which associated value is to be returned.
def - the value to be returned in the event that this preference node has no value associated with key or the associated value cannot be interpreted as a String array, or the backing store is inaccessible.
戻り値:
the String array value associated with key, or def if the associated value does not exist.
例外:
java.lang.IllegalArgumentException - if key is null. (A null value for def is permitted.)
関連項目:
getValue(String,String)

setValue

public static void setValue(java.lang.String key,
                            java.lang.String value)
                     throws java.io.IOException
Associates the specified String value with the specified key in this preference.

The key cannot be null, but null values for the value parameter are allowed.

パラメータ:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
例外:
java.io.IOException - if this preference cannot be modified for this request
java.lang.IllegalArgumentException - if key is null, or key.length() or value.length are to long. The maximum length for key and value are implementation specific.
関連項目:
setValues(String, String[])

setValues

public static void setValues(java.lang.String key,
                             java.lang.String[] values)
                      throws java.io.IOException
Associates the specified String array value with the specified key in this preference.

The key cannot be null, but null values in the values parameter are allowed.

パラメータ:
key - key with which the value is to be associated
values - values to be associated with key
例外:
java.lang.IllegalArgumentException - if key is null, or key.length() is to long or value.size is to large. The maximum length for key and maximum size for value are implementation specific.
java.io.IOException - if this preference cannot be modified for this request
関連項目:
setValue(String,String)

getNames

public static java.util.Enumeration getNames()
Returns all of the keys that have an associated value, or an empty Enumeration if no keys are available.

戻り値:
an Enumeration of the keys that have an associated value, or an empty Enumeration if no keys are available.

getMap

public static java.util.Map getMap()
Returns a Map of the preferences.

The values in the returned Map are from type String array (String[]).

If no preferences exist this method returns an empty Map.

戻り値:
an immutable Map containing preference names as keys and preference values as map values, or an empty Map if no preference exist. The keys in the preference map are of type String. The values in the preference map are of type String array (String[]).

reset

public static void reset(java.lang.String key)
                  throws java.io.IOException
Resets or removes the value associated with the specified key.

If this implementation supports stored defaults, and there is such a default for the specified preference, the given key will be reset to the stored default.

If there is no default available the key will be removed.

パラメータ:
key - to reset
例外:
java.lang.IllegalArgumentException - if key is null.
java.io.IOException - if this preference cannot be modified for this request

store

public static void store()
                  throws java.io.IOException
Commits all changes made to the preferences via the set methods in the persistent store.

If this call returns succesfull, all changes are made persistent. If this call fails, no changes are made in the persistent store. This call is an atomic operation regardless of how many preference attributes have been modified.

All changes made to preferences not followed by a call to the store method are discarded when the portlet finishes the processAction method.

If a validator is defined for this preferences in the deployment descriptor, this validator is called before the actual store is performed to check wether the given preferences are vaild. If this check fails a ValidatorException is thrown.

例外:
java.io.IOException - if changes cannot be written into the backend store
javax.portlet.ValidatorException - if the validation performed by the associated validator fails
java.lang.IllegalStateException - if this method is called inside a render call
関連項目:
PreferencesValidator


Copyright 2006 null. All Rights Reserved.