Container

public class Container

An object that provides access to container values. Container objects must be created via openContainer(String, Container.Callback) or ContainerOpener. Once a container is created, it can be queried for key values which may depend on rules established for the container. A container is automatically refreshed periodically (every 12 hours), but can also be manually refreshed with refresh().

Nested Class Summary

interface Container.Callback Callback will be invoked after the resource has been successfully loaded. 
interface Container.FunctionCallMacroHandler Handler that is provided by the application to calculate the value of a custom macro. 
interface Container.FunctionCallTagHandler Handler that is provided by the application to execute a custom tag. 
enum Container.RefreshFailure Ways in which a refresh can fail. 
enum Container.RefreshType Origin of container refresh. 

Public Method Summary

synchronized void
close()
boolean
getBoolean(String key)
String
double
getDouble(String key)
synchronized Container.FunctionCallMacroHandler
getFunctionCallMacroHandler(String customMacroName)
synchronized Container.FunctionCallTagHandler
getFunctionCallTagHandler(String customTagName)
long
long
getLong(String key)
String
getString(String key)
boolean
synchronized void
synchronized void
registerFunctionCallMacroHandler(String customMacroName, Container.FunctionCallMacroHandler customMacroHandler)
synchronized void
registerFunctionCallTagHandler(String customTagName, Container.FunctionCallTagHandler customTagHandler)

Public Methods

public synchronized void close ()

Closes this container so that it will no longer be refreshed. After it is closed, it should not be used.

public boolean getBoolean (String key)

Returns a boolean representing the configuration value for the given key. If the container has no value for this key, false will be returned.

public String getContainerId ()

Returns the container id.

public double getDouble (String key)

Returns a double representing the configuration value for the given key. If the container has no value for this key, 0 will be returned.

public synchronized Container.FunctionCallMacroHandler getFunctionCallMacroHandler (String customMacroName)

Returns the macro handler registered for the given function call macro.

public synchronized Container.FunctionCallTagHandler getFunctionCallTagHandler (String customTagName)

Returns the tag handler registered for the given function call tag.

public long getLastRefreshTime ()

Returns the last time (in milliseconds since midnight, January 1, 1970 UTC) that this container was refreshed from the network.

public long getLong (String key)

Returns a long representing the configuration value for the given key. If the container has no value for this key, 0 will be returned.

public String getString (String key)

Returns a string representing the configuration value for the given key. If the container has no value for this key, an empty string will be returned.

public boolean isDefault ()

Returns whether this is a default container, or one refreshed from the server.

public synchronized void refresh ()

Requests that this container be refreshed from the network. This call is asynchronous, so the refresh will take place on another thread.

After you call refresh(), you need to wait at least 15 minutes to try to call this method again, otherwise, the subsequent call may be a no-op.

public synchronized void registerFunctionCallMacroHandler (String customMacroName, Container.FunctionCallMacroHandler customMacroHandler)

Registers the given macro handler to handle a given function call macro.

Parameters
customMacroName the name of the macro which is being registered
customMacroHandler the handler. If null, unregisters any existing handler for that macro.

public synchronized void registerFunctionCallTagHandler (String customTagName, Container.FunctionCallTagHandler customTagHandler)

Registers the tag handler to handle a given function call tag.

Parameters
customTagName the name of the tag which is being registered
customTagHandler the handler. If null, unregisters any existing handler for that tag.