org.eclipse.mtj.core.persistence
Interface IPersistenceProvider
-
public interface IPersistenceProvider
Implementors of this interface provide facility methods for storing and
retrieving persistable objects.
Clients don't need to implement this interface as MTJ already provides the
default implementation.
-
Since:
- 1.0
-
Restriction:
- This interface is not intended to be implemented by clients.
loadBoolean
boolean loadBoolean(
String name)
throws
PersistenceException
- Returns the current value of the boolean-valued persisted element with
the given name.
Returns the default value (false
) if there is no persisted
element with the given name, or if the current value cannot be treated as
an boolean.
-
-
Parameters:
-
name
- the name of the persisted element.
-
Returns:
- the boolean-valued persisted element.
-
Throws:
-
PersistenceException
- if an error was found while retrieving the
boolean-valued persisted element.
loadInteger
int loadInteger(
String name)
throws
PersistenceException
- Returns the current value of the integer-valued persisted element with
the given name.
Returns the default value (0
) if there is no persisted
element with the given name, or if the current value cannot be treated as
an integer.
-
-
Parameters:
-
name
- the name of the persisted element.
-
Returns:
- the integer-valued persisted element.
-
Throws:
-
PersistenceException
- if an error was found while retrieving the
integer-valued persisted element.
loadPersistable
IPersistable loadPersistable(
String name)
throws
PersistenceException
- Returns the current value of the
IPersistable
object with the
given name.
Returns the null
value if there is no persisted element with
the given name.
-
-
Parameters:
-
name
- the name of the persistable object.
-
Returns:
- a newly allocated instance of the persisted element.
-
Throws:
-
PersistenceException
- if could not create a new instance of the
persisted element.
loadProperties
Properties loadProperties(
String name)
throws
PersistenceException
- Returns the current value of the persisted
Properties
object with
the given name.
Returns the null
value if there is no persisted element with
the given name.
-
-
Parameters:
-
name
- the name of the persisted element.
-
Returns:
- the persisted
Properties
object instance.
-
Throws:
-
PersistenceException
- if an error was found while retrieving the
persisted
Properties
.
loadReference
Object loadReference(
String name)
throws
PersistenceException
- Returns the current value of the referenced object.
Returns the null
if there is no preference with the given
name, if the current value cannot be treated as a reference or if the
referenced object could not be found.
-
-
Parameters:
-
name
- the name of the persisted element.
-
Returns:
- the referenced object.
-
Throws:
-
PersistenceException
- if an error was found while retrieving the
reference.
loadString
String loadString(
String name)
throws
PersistenceException
- Returns the current value of the string-valued persisted element with the
given name.
Returns null
if no persisted element with the given name
could be found. In case the persisted element does not have a specified
value will return the empty string ""
.
-
-
Parameters:
-
name
- the name of the persisted element.
-
Returns:
- the string-valued persisted element.
-
Throws:
-
PersistenceException
- if an error was found while retrieving the
string-valued persisted element.
storeBoolean
void storeBoolean(
String name,
boolean value)
throws
PersistenceException
- Store a boolean-valued element using the given name.
-
-
Parameters:
-
name
- the name of the boolean-valued element. This is
case-sensitive and must not be null
or an empty
String ""
. -
value
- the value to be stored.
-
Throws:
-
PersistenceException
- if the boolean-valued element could not be
persisted.
storeInteger
void storeInteger(
String name,
int value)
throws
PersistenceException
- Store a integer-valued element using the given name.
-
-
Parameters:
-
name
- the name of the integer-valued element. This is
case-sensitive and must not be null
or an empty
String ""
. -
value
- the value to be stored.
-
Throws:
-
PersistenceException
- if the integer-valued element could not be
persisted.
storePersistable
void storePersistable(
String name,
IPersistable value)
throws
PersistenceException
- Store a persistable object value using the given name.
-
-
Parameters:
-
name
- the name for the
IPersistable
element. This is
case-sensitive and must not be null
or an empty
String ""
. -
value
- a non-null
IPersistable
to be stored.
For null
values a
PersistenceException
wont be thrown and the invalid value will be ignored.
-
Throws:
-
PersistenceException
- if the element could not be persisted.
storeProperties
void storeProperties(
String name,
Properties value)
throws
PersistenceException
- Store a
Properties
object value using the given name.
-
-
Parameters:
-
name
- the name for the properties element. This is case-sensitive
and must not be null
or an empty String
""
. -
value
- a non-null
Properties
to be stored. For
null
values a
PersistenceException
wont
be thrown and the invalid value will be ignored.
-
Throws:
-
PersistenceException
- if the element could not be persisted.
storeReference
void storeReference(
String name,
Object referenceObject)
throws
PersistenceException
- Store a reference to the specified object using the given name.
NOTE: This object must have previously been stored by
this persistence provider or a persistence exception will be thrown.
-
-
Parameters:
-
name
- the name of the reference element. This is case-sensitive and
must not be null
or an empty String
""
. -
referenceObject
- the object to be referenced.
-
Throws:
-
PersistenceException
- if the referenced object was not previously
been stored by this persistence provider or if the element
could not be persisted.
storeString
void storeString(
String name,
String string)
throws
PersistenceException
- Store the string-valued element using the given name.
-
-
Parameters:
-
name
- the name of the string-valued element. This is case-sensitive
and must not be null
or an empty String
""
. -
string
- the string-valued element to be stored. This is
case-sensitive and must not be null
. For
null
values a
PersistenceException
wont
be thrown and the invalid value will be ignored.
-
Throws:
-
PersistenceException
- if the string-valued element could not be
persisted.