public abstract class Session extends Object
Serializers and parsers use session objects to retrieve config properties and to use it as a scratchpad during serialize and parse actions.
Modifier | Constructor and Description |
---|---|
protected |
Session(SessionArgs args)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addToCache(Map<String,Object> cacheObjects)
Adds arbitrary objects to this session's cache.
|
void |
addToCache(String key,
Object val)
Adds an arbitrary object to this session's cache.
|
void |
addWarning(String msg,
Object... args)
Logs a warning message.
|
void |
checkForWarnings()
Throws a
BeanRuntimeException if any warnings occurred in this session. |
<T> Class<? extends T> |
getClassProperty(String key,
Class<T> type,
Class<? extends T> def)
Returns the session class property with the specified name.
|
<T> T |
getFromCache(Class<T> c,
String key)
Returns an object stored in the session cache.
|
<T> T[] |
getInstanceArrayProperty(String key,
Class<T> type,
T[] def)
Returns the specified property as an array of instantiated objects.
|
<T> T |
getInstanceProperty(String key,
Class<T> type,
Object def)
Returns an instantiation of the specified class property.
|
protected JuneauLogger |
getLogger()
Returns the logger associated with this session.
|
protected ObjectMap |
getProperties()
Returns the session properties.
|
Object |
getProperty(String key)
Returns the session property with the specified key.
|
<T> T |
getProperty(String key,
Class<T> type,
T... def)
Same as
getProperty(String, Class, Object) but allows for more than one default value. |
<T> T |
getProperty(String key,
Class<T> type,
T def)
Returns the session property with the specified key and type.
|
Set<String> |
getPropertyKeys()
Returns the session property keys.
|
List<String> |
getWarnings()
Returns the warnings that occurred in this session.
|
boolean |
hasProperty(String key)
Returns
|
boolean |
hasWarnings()
Returns
|
ObjectMap |
toMap()
Returns the properties defined on this bean context as a simple map for debugging purposes.
|
String |
toString() |
protected Session(SessionArgs args)
args
- Runtime arguments.public final boolean hasProperty(String key)
key
- The property key.public final Object getProperty(String key)
The returned type is the raw value of the property.
key
- The property key.public final <T> T getProperty(String key, Class<T> type, T def)
key
- The property key.type
- The type to convert the property to.def
- The default value if the session property does not exist or is @SafeVarargs public final <T> T getProperty(String key, Class<T> type, T... def)
getProperty(String, Class, Object)
but allows for more than one default value.key
- The property key.type
- The type to convert the property to.def
- The default values if the session property does not exist or is public final <T> Class<? extends T> getClassProperty(String key, Class<T> type, Class<? extends T> def)
key
- The property name.type
- The class type of the property.def
- The default value.public <T> T getInstanceProperty(String key, Class<T> type, Object def)
key
- The property name.type
- The class type of the property.def
- The default instance or class to instantiate if the property doesn't exist.public <T> T[] getInstanceArrayProperty(String key, Class<T> type, T[] def)
key
- The property name.type
- The class type of the property.def
- The default object to return if the property doesn't exist.protected ObjectMap getProperties()
public Set<String> getPropertyKeys()
public final void addToCache(String key, Object val)
Can be used to store objects for reuse during a session.
key
- The key. Can be any string.val
- The cached object.public final void addToCache(Map<String,Object> cacheObjects)
Can be used to store objects for reuse during a session.
cacheObjects
- The objects to add to this session's cache.
No-op if public final <T> T getFromCache(Class<T> c, String key)
c
- The class type of the object.key
- The session object key.public final void addWarning(String msg, Object... args)
msg
- The warning message.args
- Optional MessageFormat
-style arguments.public final boolean hasWarnings()
public final List<String> getWarnings()
protected final JuneauLogger getLogger()
Subclasses can override this method to provide their own logger.
public void checkForWarnings()
BeanRuntimeException
if any warnings occurred in this session.public ObjectMap toMap()
Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.