ProspectDirector.Web.UI.Packagers.PackagerValueProviderFactory =
Class.extend({

    //================================
    // PUBLIC METHODS
    //================================

    getHandler: function (command) {

        var result = null;

        this._ensureHandlersAreRegistered();

        this._handlers().each(function (index, handler) {
            if (handler.canProcessValue(command.get_value())) {
                result = handler;
                return false;
            }
        });

        return result;

    },

    //================================
    // PRIVATE METHODS
    //================================

    _handlers: function () {
        return ProspectDirector.Web.UI.Packagers.PackagerValueProviderFactory._handlers;
    },

    _ensureHandlersAreRegistered: function () {

        var NS = ProspectDirector.Web.UI.Packagers,
            type = NS.PackagerValueProviderFactory;

        if (type._handlers == null) {
            type._handlers = new ProspectDirector.Web.List();
            type._handlers.add(new NS.ContextValueProvider());
            type._handlers.add(new NS.FormFieldValueProvider());
        }

    }

});