Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.puremvc.java.core
Class Model

    java.lang.Object
      org.puremvc.java.core.Model

All Implemented Interfaces:
  IModel

    public class Model

extends java.lang.Object
implements IModel

A Singleton `IModel` implementation.

In PureMVC, the `Model` class provides access to model objects (Proxies) by named lookup.

The `Model` assumes these responsibilities:

- Maintain a cache of `IProxy` instances.
- Provide methods for registering, retrieving, and removing `IProxy` instances.

Your application must register `IProxy` instances with the `Model`. Typically, you use an `ICommand` to create and register `IProxy` instances once the `Facade` has initialized the Core actors.

See Also:
  `Proxy`, `IProxy`

Field Summary
`protected static Model` | `instance` Singleton instance
`protected java.util.Map<java.lang.String,IProxy>` | `proxyMap` Mapping of proxyNames to IProxy instances

Constructor Summary
`protected` | `Model()` Constructor.

Method Summary
`static Model` | `getInstance()` `Model` Multiton Factory method.
`boolean` | `hasProxy(java.lang.String proxyName)` Check if a Proxy is registered
`protected void` | `initializeModel()` Initialize the Singleton `Model` instance.
`void` | `registerProxy(IProxy proxy)` Register an `Proxy` with the `Model`.
`IProxy` | `removeProxy(java.lang.String proxyName)` Remove an `Proxy` from the `Model`.
`IProxy` | `retrieveProxy(java.lang.String proxy)` Retrieve an `Proxy` from the `Model`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### instance

    protected static Model instance

  Singleton instance

### proxyMap

    protected java.util.Map<java.lang.String,IProxy> proxyMap

  Mapping of proxyNames to IProxy instances

Constructor Detail

### Model

    protected Model()

  Constructor.

  This `IModel` implementation is a Multiton, so you should not call the constructor directly, but instead call the static Multiton Factory method `Model.getInstance( multitonKey )`

  Throws:
    `java.lang.Error` - Error if instance for this Multiton key instance has already been constructed

Method Detail

### initializeModel

    protected void initializeModel()

  Initialize the Singleton `Model` instance.

  Called automatically by the constructor, this is your opportunity to initialize the Singleton instance in your subclass without overriding the constructor.

### getInstance

    public static Model getInstance()

  `Model` Multiton Factory method.

  Returns:
    the instance for this Multiton key

### registerProxy

    public void registerProxy(IProxy proxy)

  Register an `Proxy` with the `Model`.

  Specified by:
    `registerProxy` in interface `IModel`
  Parameters:
    `proxy` - an `Proxy` to be held by the `Model`.

### removeProxy

    public IProxy removeProxy(java.lang.String proxyName)

  Remove an `Proxy` from the `Model`.

  Specified by:
    `removeProxy` in interface `IModel`
  Parameters:
    `proxyName` - Name of the `Proxy` instance to be removed.
  Returns:
    The `IProxy` that was removed from the `Model`

### retrieveProxy

    public IProxy retrieveProxy(java.lang.String proxy)

  Retrieve an `Proxy` from the `Model`.

  Specified by:
    `retrieveProxy` in interface `IModel`
  Parameters:
    `proxy` -
  Returns:
    the `Proxy` instance previously registered with the given `proxyName`.

### hasProxy

    public boolean hasProxy(java.lang.String proxyName)

  Check if a Proxy is registered

  Specified by:
    `hasProxy` in interface `IModel`
  Parameters:
    `proxyName` - Name of the `Proxy` object to check for existance.
  Returns:
    Whether a Proxy is currently registered with the given `proxyName`.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD