org.apache.pluto.internal.impl
Class PortletPreferencesImpl

java.lang.Object
  extended by org.apache.pluto.internal.impl.PortletPreferencesImpl
All Implemented Interfaces:
PortletPreferences

public class PortletPreferencesImpl
extends java.lang.Object
implements PortletPreferences

Implementation of the javax.portlet.PortletPreferences interface.

See Also:
PortletPreferences, PortletPreferenceImpl

Constructor Summary
PortletPreferencesImpl(PortletContainer container, InternalPortletWindow window, InternalPortletRequest request, java.lang.Integer methodId)
          Constructs an instance.
 
Method Summary
 java.util.Map getMap()
          Returns a Map of the preferences.
 java.util.Enumeration getNames()
          Returns all of the keys that have an associated value, or an empty Enumeration if no keys are available.
 java.lang.String getValue(java.lang.String key, java.lang.String defaultValue)
          Returns the first String value associated with the specified key of this preference.
 java.lang.String[] getValues(java.lang.String key, java.lang.String[] defaultValues)
          Returns the String array value associated with the specified key in this preference.
 boolean isReadOnly(java.lang.String key)
          Returns true, if the value of this key is defined as read-only and thus cannot be modified by the user.
 void reset(java.lang.String key)
          Resets or removes the value associated with the specified key.
 void setValue(java.lang.String key, java.lang.String value)
          Associates the specified String value with the specified key in this preference.
 void setValues(java.lang.String key, java.lang.String[] values)
          Associates the specified String array value with the specified key in this preference.
 void store()
          Stores the portlet preferences to a persistent storage.
 java.lang.String toString()
          Returns the string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PortletPreferencesImpl

public PortletPreferencesImpl(PortletContainer container,
                              InternalPortletWindow window,
                              InternalPortletRequest request,
                              java.lang.Integer methodId)
Constructs an instance.

Parameters:
container - the portlet container.
window - the internal portlet window.
request - the internal portlet request.
methodId - the request method ID: render request or action request.
Method Detail

isReadOnly

public boolean isReadOnly(java.lang.String key)
Description copied from interface: PortletPreferences
Returns true, if the value of this key is defined as read-only and thus 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, like the CONFIG mode, 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.

Note that even if this call returns false and the preference key is modifiable in general it does not mean that it is modifiable in the scope of the current request, e.g. if this request is a render request.

Specified by:
isReadOnly in interface PortletPreferences
Returns:
false, if the value of this key can be changed, or if the key is not known

getValue

public java.lang.String getValue(java.lang.String key,
                                 java.lang.String defaultValue)
Description copied from interface: PortletPreferences
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. A null value is treated as a non-existent value.

Specified by:
getValue in interface PortletPreferences
Parameters:
key - key for which the associated value is to be returned
defaultValue - the value to be returned in the event that there is no value available associated with this key.
Returns:
the value associated with key, or def if no value is associated with key, or the backing store is inaccessible.
See Also:
PortletPreferences.getValues(String, String[])

getValues

public java.lang.String[] getValues(java.lang.String key,
                                    java.lang.String[] defaultValues)
Description copied from interface: PortletPreferences
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. A null value is treated as a non-existent value.

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

Specified by:
getValues in interface PortletPreferences
Parameters:
key - key for which associated value is to be returned.
defaultValues - 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.
Returns:
the String array value associated with key, or def if the associated value does not exist.
See Also:
PortletPreferences.getValue(String,String)

setValue

public void setValue(java.lang.String key,
                     java.lang.String value)
              throws ReadOnlyException
Description copied from interface: PortletPreferences
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.

If the same key contained already a String or String[] value it must be replaced by the new value.

Specified by:
setValue in interface PortletPreferences
Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Throws:
ReadOnlyException - if this preference cannot be modified for this request
See Also:
PortletPreferences.setValues(String, String[])

setValues

public void setValues(java.lang.String key,
                      java.lang.String[] values)
               throws ReadOnlyException
Description copied from interface: PortletPreferences
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.

If the same key contained already a String or String[] value it must be replaced by the new value.

Specified by:
setValues in interface PortletPreferences
Parameters:
key - key with which the value is to be associated
values - values to be associated with key
Throws:
ReadOnlyException - if this preference cannot be modified for this request
See Also:
PortletPreferences.setValue(String,String)

getNames

public java.util.Enumeration getNames()
Description copied from interface: PortletPreferences
Returns all of the keys that have an associated value, or an empty Enumeration if no keys are available.

Specified by:
getNames in interface PortletPreferences
Returns:
an Enumeration of the keys that have an associated value, or an empty Enumeration if no keys are available.

getMap

public java.util.Map getMap()
Description copied from interface: PortletPreferences
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.

Specified by:
getMap in interface PortletPreferences
Returns:
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 void reset(java.lang.String key)
           throws ReadOnlyException
Description copied from interface: PortletPreferences
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.

Specified by:
reset in interface PortletPreferences
Parameters:
key - to reset
Throws:
ReadOnlyException - if this preference cannot be modified for this request

store

public void store()
           throws java.io.IOException,
                  ValidatorException
Stores the portlet preferences to a persistent storage. This method should only be invoked within processAction() method.

Specified by:
store in interface PortletPreferences
Throws:
java.lang.IllegalStateException - if this method is not invoked within processAction() method.
ValidatorException - if the portlet preferences are not valid.
java.io.IOException - if an error occurs with the persistence mechanism.
See Also:
internalStore()

toString

public java.lang.String toString()
Returns the string representation of this object. Preferences are separated by ';' character, while values in one preference are separated by ',' character.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of this object.
See Also:
Object.toString()


Copyright © 2003-2010 Apache Software Foundation. All Rights Reserved.