|
GigaSpaces XAP 9.7.2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.jini.config.AbstractConfiguration
public abstract class AbstractConfiguration
A skeletal implementation of the Configuration
interface, used
to simplify writing implementations. This class checks the validity of
arguments to the getEntry
methods, checks that the result
matches the requested type, and wraps exceptions other than Error
or
ConfigurationException
in a
ConfigurationException
. Subclasses need to implement the getEntryInternal
method,
which supplies entry values, throws NoSuchEntryException
if no
matching entry is found, and performs any desired primitive conversions. The
getEntryInternal
method should return primitive values as
instances of AbstractConfiguration.Primitive
.
Nested Class Summary | |
---|---|
static class |
AbstractConfiguration.Primitive
Represents the value of an entry with a primitive type. |
Field Summary |
---|
Fields inherited from interface net.jini.config.Configuration |
---|
NO_DATA, NO_DEFAULT |
Constructor Summary | |
---|---|
protected |
AbstractConfiguration()
Creates an instance of this class. |
Method Summary | |
---|---|
Object |
getEntry(String component,
String name,
Class type)
Returns an object of the specified type created using the information in the entry matching the specified component and name, which must be found, and supplying no data. |
Object |
getEntry(String component,
String name,
Class type,
Object defaultValue)
Returns an object of the specified type created using the information in the entry matching the specified component and name, and supplying no data, returning the default value if no matching entry is found and the default value is not Configuration.NO_DEFAULT . |
Object |
getEntry(String component,
String name,
Class type,
Object defaultValue,
Object data)
Returns an object of the specified type created using the information in the entry matching the specified component and name, and using the specified data (unless it is Configuration.NO_DATA ), returning the default
value if no matching entry is found and the default value is not Configuration.NO_DEFAULT . |
protected abstract Object |
getEntryInternal(String component,
String name,
Class type,
Object data)
Returns an object created using the information in the entry matching the specified component and name, and the specified data, for the requested type. |
protected static boolean |
validIdentifier(String name)
Checks if the argument is a valid Identifier, as defined in the Java(TM) Language Specification. |
protected static boolean |
validQualifiedIdentifier(String name)
Checks if the argument is a valid QualifiedIdentifier, as defined in the Java Language Specification. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected AbstractConfiguration()
Method Detail |
---|
public Object getEntry(String component, String name, Class type) throws ConfigurationException
type
is a primitive type,
then the result is returned as an instance of the associated wrapper
class. Repeated calls with the same arguments may or may not return the
identical object.
The default implementation checks that component
,
name
, and type
are not null
; that
component
is a valid qualified identifier; and that
name
is a valid identifier. It returns the result of
calling getEntryInternal
with the specified arguments, as well as Configuration.NO_DEFAULT
and Configuration.NO_DATA
, converting results of type AbstractConfiguration.Primitive
into the associated wrapper type. If the call throws an
exception other than an Error
or a ConfigurationException
, it throws a ConfigurationException
with the original exception as the cause.
getEntry
in interface Configuration
component
- the component being configuredname
- the name of the entry for the componenttype
- the type of the object to be returned
component
and name
NoSuchEntryException
- if no matching entry is found
IllegalArgumentException
- if component
is not
null
and is not a valid QualifiedIdentifier, or if
name
is not null
and is not a valid
Identifier
NullPointerException
- if any argument is null
ConfigurationException
- if a matching entry is found but a
problem occurs creating the object for the entry, or if
type
is a reference type and the result for the matching
entry is not either null
or an instance of
type
, or if type
is a primitive type and the
result is not an instance of the associated wrapper class. Any
Error
thrown while creating the object is propagated to the
caller; it is not wrapped in a ConfigurationException
.Configuration.getEntry(String, String, Class, Object)
public Object getEntry(String component, String name, Class type, Object defaultValue) throws ConfigurationException
Configuration.NO_DEFAULT
. If type
is a
primitive type, then the result is returned as an instance of the
associated wrapper class. Repeated calls with the same arguments may or
may not return the identical object.
The default implementation checks that component
,
name
, and type
are not null
; that
component
is a valid qualified identifier; that
name
is a valid identifier; and that
defaultValue
is of the right type. It returns the result of
calling getEntryInternal
with the specified arguments, as well as Configuration.NO_DATA
, converting results of type AbstractConfiguration.Primitive
into the
associated wrapper type. If the call throws an exception other than an
Error
or a ConfigurationException
, it throws a
ConfigurationException
with the original exception as the
cause.
getEntry
in interface Configuration
component
- the component being configuredname
- the name of the entry for the componenttype
- the type of the object to be returneddefaultValue
- the object to return if no matching entry is found,
or NO_DEFAULT
to specify no default
component
and name
, or
defaultValue
if no matching entry is found and
defaultValue
is not NO_DEFAULT
NoSuchEntryException
- if no matching entry is found and
defaultValue
is NO_DEFAULT
IllegalArgumentException
- if component
is not
null
and is not a valid QualifiedIdentifier; or if
name
is not null
and is not a valid
Identifier; or if type
is a reference type and
defaultValue
is not NO_DEFAULT
,
null
, or an instance of type
; or if
type
is a primitive type and defaultValue
is
not NO_DEFAULT
or an instance of the associated wrapper
class
NullPointerException
- if component
,
name
, or type
is null
ConfigurationException
- if a matching entry is found but a
problem occurs creating the object for the entry, or if
type
is a reference type and the result for the matching
entry is not either null
or an instance of
type
, or if type
is a primitive type and the
result is not an instance of the associated wrapper class. Any
Error
thrown while creating the object is propagated to the
caller; it is not wrapped in a ConfigurationException
.Configuration.getEntry(String, String, Class, Object, Object)
public Object getEntry(String component, String name, Class type, Object defaultValue, Object data) throws ConfigurationException
Configuration.NO_DATA
), returning the default
value if no matching entry is found and the default value is not Configuration.NO_DEFAULT
. If type
is a primitive type, then the result
is returned as an instance of the associated wrapper class. Repeated
calls with the same arguments may or may not return the identical
object.
The default implementation checks that component
,
name
, and type
are not null
; that
component
is a valid qualified identifier; that
name
is a valid identifier; and that
defaultValue
is of the right type. It returns the result of
calling getEntryInternal
with the specified arguments, converting results of
type AbstractConfiguration.Primitive
into the associated wrapper type. If the call
throws an exception other than an Error
or a ConfigurationException
, it throws a ConfigurationException
with the original exception as the cause.
getEntry
in interface Configuration
component
- the component being configuredname
- the name of the entry for the componenttype
- the type of the object to be returneddefaultValue
- the object to return if no matching entry is found,
or NO_DEFAULT
to specify no defaultdata
- an object to use when computing the value of the entry, or
NO_DATA
to specify no data
component
and name
, and using the value of
data
(unless it is NO_DATA
), or
defaultValue
if no matching entry is found and
defaultValue
is not NO_DEFAULT
NoSuchEntryException
- if no matching entry is found and
defaultValue
is NO_DEFAULT
IllegalArgumentException
- if component
is not
null
and is not a valid QualifiedIdentifier; or if
name
is not null
and is not a valid
Identifier; or if type
is a reference type and
defaultValue
is not NO_DEFAULT
,
null
, or an instance of type
; or if
type
is a primitive type and defaultValue
is
not NO_DEFAULT
or an instance of the associated wrapper
class
NullPointerException
- if component
,
name
, or type
is null
ConfigurationException
- if a matching entry is found but a
problem occurs creating the object for the entry, or if
type
is a reference type and the result for the matching
entry is not either null
or an instance of
type
, or if type
is a primitive type and the
result is not an instance of the associated wrapper class. Any
Error
thrown while creating the object is propagated to the
caller; it is not wrapped in a ConfigurationException
.protected abstract Object getEntryInternal(String component, String name, Class type, Object data) throws ConfigurationException
AbstractConfiguration.Primitive
. Implementations may
use type
to perform conversions on primitive values, if
desired, but are not required to check if the object is of the requested
type. Repeated calls with the same arguments may or may not return the
identical object.
The default implementations of the getEntry
methods
delegate to this method; implementations can rely on the fact that calls
made to this method by those methods will have arguments that are not
null
and that have the correct syntax.
component
- the component being configuredname
- the name of the entry for the componenttype
- the type of object requesteddata
- an object to use when computing the value of the entry, or
Configuration.NO_DATA
to specify no data
component
and name
, and using the value of
data
(unless it is NO_DATA
)
NoSuchEntryException
- if no matching entry is found
ConfigurationException
- if a matching entry is found but a
problem occurs creating the object for the entry
NullPointerException
- if component
,
name
, or type
is null
Configuration.getEntry
protected static boolean validIdentifier(String name)
name
- the name to check
true
if name
is a valid
Identifier, else false
protected static boolean validQualifiedIdentifier(String name)
name
- the name to check
true
if name
is a valid
QualifiedIdentifier, else false
|
GigaSpaces XAP 9.7.2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |