Oracle Fusion Middleware
Java API Reference for Oracle PDK Java
11g Release 1 (11.1.1)
E10691-01

oracle.portal.provider.v2.preference
Class PreferenceStore

java.lang.Object
  extended by oracle.portal.provider.v2.preference.PreferenceStore
All Implemented Interfaces:
Validateable
Direct Known Subclasses:
DBPreferenceStore, FCFDBPreferenceStore, FilePreferenceStore

public abstract class PreferenceStore
extends java.lang.Object
implements Validateable

A PreferenceStore is a generic storage mechanism for loading and saving data items held in PreferenceDataObjects. Data is stored under a 'key' represented by a Preference whose primary components are a 'reference path' and a 'preference type'. See the Preference class for more details.

Note that a reference path, as returned by Preference.getReferencePath(), is a standard Java unicode String, and as such may contain multibyte characters. Implementations of PreferenceStore may therefore have to encode the String into a format more suitable for the underlying storage mechanism.


Field Summary
static java.lang.String DEFAULT_CUSTOMIZATION_TYPE
          Path type used for storing system default and locale default level portlet customizations.
static char PATH_SEPARATOR_CHAR
          The character used betwen path components in reference paths.
static java.lang.String PATH_SEPARATOR_STRING
          String containing the single character used betwen path components in reference paths.
static java.lang.String USER_CUSTOMIZATION_TYPE
          Path type used for storing user level portlet customizations.
 
Constructor Summary
PreferenceStore()
           
 
Method Summary
 void copy(Preference sourcePref, Preference destPref, boolean overwrite)
          Copies the data persisted for the given source Preference to the given destination Preference.
 void copy(java.lang.String sourceContext, java.lang.String destContext, boolean overwrite)
          Copies the data from all the Preference objects in this PreferenceStore with the given source context path to the given destination context path.
 void copy(java.lang.String sourceContext, java.lang.String destContext, boolean overwrite, java.util.List preferenceTypes)
          Copies the data from all the Preference objects in this PreferenceStore with the given source context path and one of the given preference types to the given destination context path.
abstract  void destroy(Preference pref)
          Destroys the data persisted for the given Preference.
 void destroy(java.lang.String context)
          Destroys all of the Preference objects in this PreferenceStore stored under the given context path.
abstract  void destroy(java.lang.String context, java.util.List preferenceTypes)
          Destroys all of the Preference objects in this PreferenceStore stored under the given context path with one of the given preference types.
abstract  boolean exists(Preference pref)
          Returns true if persisted data exists for the given Preference.
abstract  java.io.InputStream getInputStream(Preference pref)
          Gets an InputStream for reading the data of the given Preference.
 java.lang.String getName()
          Gets the name that should be used to identify this PreferenceStore.
abstract  java.io.OutputStream getOutputStream(Preference pref, boolean overwrite)
          Gets an OutputStream for writing the data of the given Preference directly into storage.
 java.util.Iterator list(java.lang.String context)
          Gets an Iterator over all of the Preference objects in this PreferenceStore stored under the given context path.
abstract  java.util.Iterator list(java.lang.String context, java.util.List preferenceTypes)
          Gets an Iterator over all of the Preference objects in this PreferenceStore stored under the given context path with one of the given preference types.
 void read(Preference pref)
          Loads a PreferenceDataObject into the given Preference.
 void setName(java.lang.String name)
          Sets the name that should be used to identify this PreferenceStore.
 void validate(java.lang.String context, ValidationError errors)
          Validates the internal state of this PreferenceStore instance.
 void write(Preference pref, boolean overwrite)
          Saves the PreferenceDataObject in the given Preference to storage.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_SEPARATOR_CHAR

public static final char PATH_SEPARATOR_CHAR
The character used betwen path components in reference paths.

See Also:
Constant Field Values

PATH_SEPARATOR_STRING

public static final java.lang.String PATH_SEPARATOR_STRING
String containing the single character used betwen path components in reference paths.

See Also:
Constant Field Values

USER_CUSTOMIZATION_TYPE

public static final java.lang.String USER_CUSTOMIZATION_TYPE
Path type used for storing user level portlet customizations. For backward compatibility with older versions of PDK-Java, this path type must be given special treatment by the default PreferenceStore implementations, hence the reason why it is defined at this level.

See Also:
Constant Field Values

DEFAULT_CUSTOMIZATION_TYPE

public static final java.lang.String DEFAULT_CUSTOMIZATION_TYPE
Path type used for storing system default and locale default level portlet customizations. For backward compatibility with older versions of PDK-Java, this path type must be given special treatment by the default PreferenceStore implementations, hence the reason why it is defined at this level.

See Also:
Constant Field Values
Constructor Detail

PreferenceStore

public PreferenceStore()
Method Detail

setName

public void setName(java.lang.String name)
Sets the name that should be used to identify this PreferenceStore.

Parameters:
name - name that should be used to identify this PreferenceStore.

getName

public final java.lang.String getName()
Gets the name that should be used to identify this PreferenceStore.

Returns:
the name that should be used to identify this PreferenceStore.

list

public java.util.Iterator list(java.lang.String context)
                        throws PreferenceStoreException
Gets an Iterator over all of the Preference objects in this PreferenceStore stored under the given context path. Note that this listing is 'recursive', in that Preferences stored in context paths below the given one will also be returned. Provided as shorthand for list(context, null).

Parameters:
context - the context path under which Preferences should be listed.
Throws:
PreferenceStoreException - if an error occurs during the operation.

list

public abstract java.util.Iterator list(java.lang.String context,
                                        java.util.List preferenceTypes)
                                 throws PreferenceStoreException
Gets an Iterator over all of the Preference objects in this PreferenceStore stored under the given context path with one of the given preference types. Note that this listing is 'recursive', in that Preferences stored in context paths below the given one will also be returned. Note also that the data object is not loaded into any of the listed Preferences.

Parameters:
context - the context path under which Preferences should be listed.
preferenceTypes - a list of strings, naming the preference types to include, or null if all preference types should be included.
Throws:
PreferenceStoreException - if an error occurs during the operation.

copy

public void copy(java.lang.String sourceContext,
                 java.lang.String destContext,
                 boolean overwrite)
          throws EntryAlreadyExistsException,
                 PreferenceStoreException
Copies the data from all the Preference objects in this PreferenceStore with the given source context path to the given destination context path. Note that this copy is 'recursive', in that Preferences stored in context paths below the given source context path will also be copied (with new context paths calculated relative to the given destination context path). Provided as shorthand for copy(sourceContext, destContext, overwrite, null).

Parameters:
sourceContext - the source context path from which Preferences should be copied.
destContext - the destination context path to which Preferences should be copied.
overwrite - boolean indicating whether preferences existing under the destination context path should be overwritten.
Throws:
EntryAlreadyExistsException - if overwrite was false and one or more Preferences were found to already exist under their destination context paths.
PreferenceStoreException - if any other error occurs during the operation.

copy

public void copy(java.lang.String sourceContext,
                 java.lang.String destContext,
                 boolean overwrite,
                 java.util.List preferenceTypes)
          throws EntryAlreadyExistsException,
                 PreferenceStoreException
Copies the data from all the Preference objects in this PreferenceStore with the given source context path and one of the given preference types to the given destination context path. Note that this copy is 'recursive', in that Preferences stored in context paths below the given source context path will also be copied (with new context paths calculated relative to the given destination context path).

Parameters:
sourceContext - the source context path from which Preferences should be copied.
destContext - the destination context path to which Preferences should be copied.
overwrite - boolean indicating whether preferences existing under the destination context path should be overwritten.
preferenceTypes - a list of strings, naming the preference types to include, or null if all preference types should be included.
Throws:
EntryAlreadyExistsException - if overwrite was false and one or more Preferences were found to already exist under their destination context paths.
PreferenceStoreException - if any other error occurs during the operation.

destroy

public void destroy(java.lang.String context)
             throws PreferenceStoreException
Destroys all of the Preference objects in this PreferenceStore stored under the given context path. Note that this operation is 'recursive', in that Preferences stored in context paths below the given one will also be destroyed. Provided as shorthand for destroy(context, null).

Parameters:
context - the context path under which Preferences should be listed.
Throws:
PreferenceStoreException - if an error occurs during the operation.

destroy

public abstract void destroy(java.lang.String context,
                             java.util.List preferenceTypes)
                      throws PreferenceStoreException
Destroys all of the Preference objects in this PreferenceStore stored under the given context path with one of the given preference types. Note that this operation is 'recursive', in that Preferences stored in context paths below the given one will also be destroyed.

Parameters:
context - the context path under which Preferences should be listed.
preferenceTypes - a list of strings, naming the preference types to include, or null if all preference types should be included.
Throws:
PreferenceStoreException - if an error occurs during the operation.

exists

public abstract boolean exists(Preference pref)
                        throws PreferenceStoreException
Returns true if persisted data exists for the given Preference.

Returns:
true if persisted data exists for the given Preference, false otherwise.
Throws:
PreferenceStoreException

read

public void read(Preference pref)
          throws EntryNotFoundException,
                 PreferenceStoreException
Loads a PreferenceDataObject into the given Preference.

Throws:
EntryNotFoundException - if no data for the given Preference exists.
PreferenceStoreException - if any other error occurs during the operation.

getInputStream

public abstract java.io.InputStream getInputStream(Preference pref)
                                            throws EntryNotFoundException,
                                                   PreferenceStoreException
Gets an InputStream for reading the data of the given Preference.

This method is provided in conjunction with getOutputStream(oracle.portal.provider.v2.preference.Preference, boolean) as a way of streamlining the process of copying data between PreferenceStores, since data can be copied directly from the InputStream of one Preference to the OutputStream of another, without having to instantiate a PreferenceDataObject.

Throws:
EntryNotFoundException - if no data for the given Preference exists.
PreferenceStoreException - if any other error occurs during the operation.

write

public void write(Preference pref,
                  boolean overwrite)
           throws EntryAlreadyExistsException,
                  PreferenceStoreException
Saves the PreferenceDataObject in the given Preference to storage.

Parameters:
overwrite - boolean indicating whether data already existing for this Preference should be overwritten.
Throws:
EntryAlreadyExistsException - if overwrite was false and data for the given Preference already exists in storage.
PreferenceStoreException - if any other error occurs during the operation.

getOutputStream

public abstract java.io.OutputStream getOutputStream(Preference pref,
                                                     boolean overwrite)
                                              throws EntryAlreadyExistsException,
                                                     PreferenceStoreException
Gets an OutputStream for writing the data of the given Preference directly into storage.

This method is provided in conjunction with getInputStream(oracle.portal.provider.v2.preference.Preference) as a way of streamlining the process of copying data between PreferenceStores, since data can be copied directly from the InputStream of one Preference to the OutputStream of another, without having to instantiate a PreferenceDataObject.

Throws:
EntryAlreadyExistsException - if overwrite was false and data for the given Preference already exists in storage.
PreferenceStoreException - if any other error occurs during the operation.

copy

public void copy(Preference sourcePref,
                 Preference destPref,
                 boolean overwrite)
          throws EntryAlreadyExistsException,
                 PreferenceStoreException
Copies the data persisted for the given source Preference to the given destination Preference.

Parameters:
sourcePref - the Preference to copy data from.
destPref - the Preference to copy data to.
overwrite - boolean indicating whether data already existing for destPref should be overwritten.
Throws:
EntryAlreadyExistsException - if overwrite was false and data was found to already exist for destPref.
PreferenceStoreException - if any other error occurs during the operation.

destroy

public abstract void destroy(Preference pref)
                      throws PreferenceStoreException
Destroys the data persisted for the given Preference.

Parameters:
pref - the Preference whose persisted data should be destroyed.
Throws:
PreferenceStoreException - if an error occurs during the operation.

validate

public void validate(java.lang.String context,
                     ValidationError errors)
Validates the internal state of this PreferenceStore instance. Errors found are reported using the supplied ValidationError instance.

Specified by:
validate in interface Validateable
Parameters:
context - The context of the calling instance.
errors - The current list of errors.

Oracle Fusion Middleware
Java API Reference for Oracle PDK Java
11g Release 1 (11.1.1)
E10691-01

Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.