org.apache.tapestry5.internal.model

## Class MutableComponentModelImpl

- java.lang.Object
- - org.apache.tapestry5.internal.model.MutableComponentModelImpl

- All Implemented Interfaces:
    ComponentModel, MutableComponentModel

      public final class MutableComponentModelImpl
      extends java.lang.Object
      implements MutableComponentModel

  Internal implementation of `MutableComponentModel`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MutableComponentModelImpl(java.lang.String componentClassName, org.slf4j.Logger logger, Resource baseResource, ComponentModel parentModel, boolean pageClass, java.lang.String libraryName)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `MutableEmbeddedComponentModel` | `addEmbeddedComponent(java.lang.String id, java.lang.String type, java.lang.String componentClassName, boolean inheritInformalParameters, Location location)` Defines a new embedded component.
    `void` | `addEventHandler(java.lang.String eventType)` Identifies that the component includes an event handler for the indicated event type.
    `void` | `addMixinClassName(java.lang.String mixinClassName, java.lang.String... order)` Adds a mixin to the component's implementation, optionally specifying ordering constraints, as per OrderedConfiguration.
    `void` | `addParameter(java.lang.String name, boolean required, boolean allowNull, java.lang.String defaultBindingPrefix)` Adds a new formal parameter to the model.
    `void` | `addParameter(java.lang.String name, boolean required, boolean allowNull, java.lang.String defaultBindingPrefix, boolean cached)` Adds a new formal parameter to the model.
    `void` | `addRenderPhase(java.lang.Class renderPhase)` Identifies that the component does handle the render phase.
    `void` | `doHandleActivationEventContext()` Relevant for pages only, identifies that the component handle `EventConstants.ACTIVATE` events supporting one of the three special case for catch all rules: ``Object`[]` ``List`` ``EventContext``
    `void` | `enableSupportsInformalParameters()` Sets the internal flag to indicate that this model (and all models that extend from it) support informal parameters.
    `Resource` | `getBaseResource()` Returns the resource corresponding to the class file for this component.
    `java.lang.String` | `getComponentClassName()` The fully qualified class name of the component.
    `java.util.List<java.lang.String>` | `getDeclaredParameterNames()` Returns an alphabetically sorted list of the names of all formal parameters defined by this specific class (parameters inherited from base classes are not identified).
    `java.util.List<java.lang.String>` | `getEmbeddedComponentIds()` Returns the ids of all embedded components defined within the component class (via the `Component` annotation), including those defined by any super-class.
    `EmbeddedComponentModel` | `getEmbeddedComponentModel(java.lang.String componentId)` Returns an embedded component defined by this component or by a super-class.
    `java.lang.String` | `getFieldPersistenceStrategy(java.lang.String fieldName)` Returns the persistent strategy associated with the field.
    `java.util.Set<java.lang.Class>` | `getHandledRenderPhases()` Returns a set of all the render phases that this model (including parent models) that are handled.
    `java.lang.String` | `getLibraryName()` Returns the name of the library that defines this component; this may be the empty string for an application page or component, or will be a name of a library (possibly including "core" for built-in components).
    `org.slf4j.Logger` | `getLogger()` Returns object that will be used to log warnings and errors related to this component.
    `java.lang.String` | `getMeta(java.lang.String key)` Gets a meta value identified by the given key.
    `java.util.List<java.lang.String>` | `getMixinClassNames()` Returns a list of the class names of mixins that are part of the component's implementation.
    `java.lang.String[]` | `getOrderForMixin(java.lang.String mixinClassName)`
    `ParameterModel` | `getParameterModel(java.lang.String parameterName)` Return a single parameter model by parameter name, or null if the parameter is not defined (is not a formal parameter).
    `java.util.List<java.lang.String>` | `getParameterNames()` Returns an alphabetically sorted list of the names of all formal parameters.
    `ComponentModel` | `getParentModel()` Returns the component model for this component's super-class, if it exists.
    `java.util.List<java.lang.String>` | `getPersistentFieldNames()` Returns a list of the names of all persistent fields (within this class, or any super-class).
    `boolean` | `getSupportsInformalParameters()` Returns true if the model indicates that informal parameters, additional parameters beyond the formal parameter defined for the component, are supported.
    `boolean` | `handleActivationEventContext()` Relevant for pages only, indicates that the component handle the `EventConstants.ACTIVATE` events with a catch all rules
    `boolean` | `handlesEvent(java.lang.String eventType)` Determines if the component has an event handler for the indicated event name (case insensitive).
    `boolean` | `isFormalParameter(java.lang.String parameterName)` Returns true if the named parameter is formally defined (there's a ParameterModel).
    `boolean` | `isMixinAfter()` Relevant for component mixins only.
    `boolean` | `isPage()` Is this a model of a page (rather than a component, mixin, or base-class)?
    `boolean` | `isRootClass()` Returns true if the modeled component is a root class, a component class whose parent class is not a component class.
    `java.lang.String` | `setFieldPersistenceStrategy(java.lang.String fieldName, java.lang.String strategy)` Used to define the field persistence strategy for a particular field name.
    `void` | `setMeta(java.lang.String key, java.lang.String value)` Stores a meta data value under the indicated key.
    `void` | `setMixinAfter(boolean mixinAfter)` Changes the value of the mixinAfter flag.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### MutableComponentModelImpl

          public MutableComponentModelImpl(java.lang.String componentClassName,
                                           org.slf4j.Logger logger,
                                           Resource baseResource,
                                           ComponentModel parentModel,
                                           boolean pageClass,
                                           java.lang.String libraryName)

  - ### Method Detail

    - #### getLibraryName

          public java.lang.String getLibraryName()

      Description copied from interface: `ComponentModel`
      Returns the name of the library that defines this component; this may be the empty string for an application page or component, or will be a name of a library (possibly including "core" for built-in components). Library names are defined by the `LibraryMapping` contributions to the `ComponentClassResolver` service.
      Specified by:
        `getLibraryName` in interface `ComponentModel`
      Returns:
        library name containing the component, or empty string for application components

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### getLogger

          public org.slf4j.Logger getLogger()

      Description copied from interface: `ComponentModel`
      Returns object that will be used to log warnings and errors related to this component.
      Specified by:
        `getLogger` in interface `ComponentModel`
      See Also:
        `Log`

    - #### getBaseResource

          public Resource getBaseResource()

      Description copied from interface: `ComponentModel`
      Returns the resource corresponding to the class file for this component. This is used to find related resources, such as the component's template and message catalog.
      Specified by:
        `getBaseResource` in interface `ComponentModel`

    - #### getComponentClassName

          public java.lang.String getComponentClassName()

      Description copied from interface: `ComponentModel`
      The fully qualified class name of the component.
      Specified by:
        `getComponentClassName` in interface `ComponentModel`

    - #### addParameter

          public void addParameter(java.lang.String name,
                                   boolean required,
                                   boolean allowNull,
                                   java.lang.String defaultBindingPrefix,
                                   boolean cached)

      Description copied from interface: `MutableComponentModel`
      Adds a new formal parameter to the model. Each parameter has a unique name (though access to parameters is case insensitive).
      Specified by:
        `addParameter` in interface `MutableComponentModel`
      Parameters:
        `name` - new, unique name for the parameter
        `required` - if true, the parameter must be bound
        `allowNull` - if true, then parameter may be bound to null, if false a null check will be added
        `defaultBindingPrefix` - the default binding prefix for this parameter @throws IllegalArgumentException if a parameter with the given name has already been defined for this model
        `cached` - if true, the parameter value should be cached within the component during rendering
      See Also:
        `Parameter`

    - #### addParameter

          public void addParameter(java.lang.String name,
                                   boolean required,
                                   boolean allowNull,
                                   java.lang.String defaultBindingPrefix)

      Description copied from interface: `MutableComponentModel`
      Adds a new formal parameter to the model. Each parameter has a unique name (though access to parameters is case insensitive).
      Specified by:
        `addParameter` in interface `MutableComponentModel`
      Parameters:
        `name` - new, unique name for the parameter
        `required` - if true, the parameter must be bound
        `allowNull` - if true, then parameter may be bound to null, if false a null check will be added
        `defaultBindingPrefix` - the default binding prefix for this parameter @throws IllegalArgumentException if a parameter with the given name has already been defined for this model
      See Also:
        `Parameter`

    - #### getParameterModel

          public ParameterModel getParameterModel(java.lang.String parameterName)

      Description copied from interface: `ComponentModel`
      Return a single parameter model by parameter name, or null if the parameter is not defined (is not a formal parameter). This may be a parameter defined by this component, or from a base class.
      Specified by:
        `getParameterModel` in interface `ComponentModel`
      Parameters:
        `parameterName` - the name of the parameter (case is ignored)
      Returns:
        the parameter model if found in this model or a parent model, or null if not found

    - #### isFormalParameter

          public boolean isFormalParameter(java.lang.String parameterName)

      Description copied from interface: `ComponentModel`
      Returns true if the named parameter is formally defined (there's a ParameterModel).
      Specified by:
        `isFormalParameter` in interface `ComponentModel`
      Parameters:
        `parameterName` - name of the parameter (case is ignored)

    - #### getParameterNames

          public java.util.List<java.lang.String> getParameterNames()

      Description copied from interface: `ComponentModel`
      Returns an alphabetically sorted list of the names of all formal parameters. This includes parameters defined by a base class.
      Specified by:
        `getParameterNames` in interface `ComponentModel`

    - #### getDeclaredParameterNames

          public java.util.List<java.lang.String> getDeclaredParameterNames()

      Description copied from interface: `ComponentModel`
      Returns an alphabetically sorted list of the names of all formal parameters defined by this specific class (parameters inherited from base classes are not identified).
      Specified by:
        `getDeclaredParameterNames` in interface `ComponentModel`

    - #### addEmbeddedComponent

          public MutableEmbeddedComponentModel addEmbeddedComponent(java.lang.String id,
                                                                    java.lang.String type,
                                                                    java.lang.String componentClassName,
                                                                    boolean inheritInformalParameters,
                                                                    Location location)

      Description copied from interface: `MutableComponentModel`
      Defines a new embedded component.
      Specified by:
        `addEmbeddedComponent` in interface `MutableComponentModel`
      Parameters:
        `id` - the unique id for the embedded component, which must not already exist.
        `type` - the type of the component (posslibly blank)
        `componentClassName` - the fully qualified class name (derived from the field), used if the type is blank
        `inheritInformalParameters` - if true, then the component will inherit informal parameters provided to its container
        `location` - where the component is defined @return a mutable model allowing parameters to be set

    - #### getEmbeddedComponentIds

          public java.util.List<java.lang.String> getEmbeddedComponentIds()

      Description copied from interface: `ComponentModel`
      Returns the ids of all embedded components defined within the component class (via the `Component` annotation), including those defined by any super-class.
      Specified by:
        `getEmbeddedComponentIds` in interface `ComponentModel`

    - #### getEmbeddedComponentModel

          public EmbeddedComponentModel getEmbeddedComponentModel(java.lang.String componentId)

      Description copied from interface: `ComponentModel`
      Returns an embedded component defined by this component or by a super-class.
      Specified by:
        `getEmbeddedComponentModel` in interface `ComponentModel`
      Parameters:
        `componentId` - the id of the embedded component
      Returns:
        the embedded component model, or null if no component exists with that id

    - #### getFieldPersistenceStrategy

          public java.lang.String getFieldPersistenceStrategy(java.lang.String fieldName)

      Description copied from interface: `ComponentModel`
      Returns the persistent strategy associated with the field.
      Specified by:
        `getFieldPersistenceStrategy` in interface `ComponentModel`
      Returns:
        the corresponding strategy, or the empty string

    - #### getPersistentFieldNames

          public java.util.List<java.lang.String> getPersistentFieldNames()

      Description copied from interface: `ComponentModel`
      Returns a list of the names of all persistent fields (within this class, or any super-class). The names are sorted alphabetically.
      Specified by:
        `getPersistentFieldNames` in interface `ComponentModel`
      See Also:
        `Persist`

    - #### setFieldPersistenceStrategy

          public java.lang.String setFieldPersistenceStrategy(java.lang.String fieldName,
                                                              java.lang.String strategy)

      Description copied from interface: `MutableComponentModel`
      Used to define the field persistence strategy for a particular field name. Returns a logical name for the field, which is guaranteed to be unique (this is necessary for handling the case where a subclass has a persistent field with the same name as a persistent field from a super-class).
      Specified by:
        `setFieldPersistenceStrategy` in interface `MutableComponentModel`
      Parameters:
        `fieldName` - the name of the field which is to be made persistent
        `strategy` - the strategy for persisting the field, from `Persist.value()`. This value may be blank, in which case the stategy is inherited from the component, or the component's container.
      Returns:
        a logical name for the field, to be used with `ComponentModel.getFieldPersistenceStrategy(String)`, and with `InternalComponentResources.persistFieldChange(String, Object)`, etc.

    - #### isRootClass

          public boolean isRootClass()

      Description copied from interface: `ComponentModel`
      Returns true if the modeled component is a root class, a component class whose parent class is not a component class. We may in the future require that components only extend from Object.
      Specified by:
        `isRootClass` in interface `ComponentModel`
      Returns:
        true if a root class, false if a subclass

    - #### addMixinClassName

          public void addMixinClassName(java.lang.String mixinClassName,
                                        java.lang.String... order)

      Description copied from interface: `MutableComponentModel`
      Adds a mixin to the component's implementation, optionally specifying ordering constraints, as per OrderedConfiguration.
      Specified by:
        `addMixinClassName` in interface `MutableComponentModel`

    - #### getMixinClassNames

          public java.util.List<java.lang.String> getMixinClassNames()

      Description copied from interface: `ComponentModel`
      Returns a list of the class names of mixins that are part of the component's implementation.
      Specified by:
        `getMixinClassNames` in interface `ComponentModel`

    - #### enableSupportsInformalParameters

          public void enableSupportsInformalParameters()

      Description copied from interface: `MutableComponentModel`
      Sets the internal flag to indicate that this model (and all models that extend from it) support informal parameters.
      Specified by:
        `enableSupportsInformalParameters` in interface `MutableComponentModel`

    - #### getSupportsInformalParameters

          public boolean getSupportsInformalParameters()

      Description copied from interface: `ComponentModel`
      Returns true if the model indicates that informal parameters, additional parameters beyond the formal parameter defined for the component, are supported. This is false in most cases, but may be set to true for specific classes (when the `SupportsInformalParameters` annotation is present, or inherited from a super-class).
      Specified by:
        `getSupportsInformalParameters` in interface `ComponentModel`
      Returns:
        true if this component model supports informal parameters

    - #### getParentModel

          public ComponentModel getParentModel()

      Description copied from interface: `ComponentModel`
      Returns the component model for this component's super-class, if it exists. Remember that only classes in the correct packages, are considered component classes.
      Specified by:
        `getParentModel` in interface `ComponentModel`
      Returns:
        the parent class model, or null if this component's super class is not itself a component class

    - #### isMixinAfter

          public boolean isMixinAfter()

      Description copied from interface: `ComponentModel`
      Relevant for component mixins only. Indicates that the mixin behavior should occur after (not before) the component. Normally, this flag is set by the presence of the `MixinAfter` annotation.
      Specified by:
        `isMixinAfter` in interface `ComponentModel`
      Returns:
        true if the mixin should operate after, not before, the component

    - #### setMixinAfter

          public void setMixinAfter(boolean mixinAfter)

      Description copied from interface: `MutableComponentModel`
      Changes the value of the mixinAfter flag. The default value is false.
      Specified by:
        `setMixinAfter` in interface `MutableComponentModel`

    - #### setMeta

          public void setMeta(java.lang.String key,
                              java.lang.String value)

      Description copied from interface: `MutableComponentModel`
      Stores a meta data value under the indicated key.
      Specified by:
        `setMeta` in interface `MutableComponentModel`

    - #### addRenderPhase

          public void addRenderPhase(java.lang.Class renderPhase)

      Description copied from interface: `MutableComponentModel`
      Identifies that the component does handle the render phase.
      Specified by:
        `addRenderPhase` in interface `MutableComponentModel`
      Parameters:
        `renderPhase` - annotation class corresponding to the render phase
      See Also:
        `ComponentModel.getHandledRenderPhases()`

    - #### addEventHandler

          public void addEventHandler(java.lang.String eventType)

      Description copied from interface: `MutableComponentModel`
      Identifies that the component includes an event handler for the indicated event type.
      Specified by:
        `addEventHandler` in interface `MutableComponentModel`
      Parameters:
        `eventType` - of handled event

    - #### getMeta

          public java.lang.String getMeta(java.lang.String key)

      Description copied from interface: `ComponentModel`
      Gets a meta value identified by the given key. If the current model does not provide a value for the key, then the parent component model (if any) is searched.
      Specified by:
        `getMeta` in interface `ComponentModel`
      Parameters:
        `key` - identifies the value to be accessed
      Returns:
        the value for the key (possibly inherited from a parent model), or null

    - #### getHandledRenderPhases

          public java.util.Set<java.lang.Class> getHandledRenderPhases()

      Description copied from interface: `ComponentModel`
      Returns a set of all the render phases that this model (including parent models) that are handled. Render phases are represented by the corresponding annotation (`BeginRender`, `AfterRender`, etc.).
      Specified by:
        `getHandledRenderPhases` in interface `ComponentModel`
      Returns:
        set of classes

    - #### handlesEvent

          public boolean handlesEvent(java.lang.String eventType)

      Description copied from interface: `ComponentModel`
      Determines if the component has an event handler for the indicated event name (case insensitive). This includes handlers in the component class itself, or its super-classes, but does not include event handlers supplied by implementation or instance mixins.
      Specified by:
        `handlesEvent` in interface `ComponentModel`
      Parameters:
        `eventType` - name of event to check (case insensitive)
      Returns:
        true if event handler present

    - #### getOrderForMixin

          public java.lang.String[] getOrderForMixin(java.lang.String mixinClassName)

      Specified by:
        `getOrderForMixin` in interface `ComponentModel`
      Parameters:
        `mixinClassName` - class name of the mixin for which the ordering is desired
      Returns:
        the ordering constraint(s) for the mixin, potentially null.

    - #### isPage

          public boolean isPage()

      Description copied from interface: `ComponentModel`
      Is this a model of a page (rather than a component, mixin, or base-class)?
      Specified by:
        `isPage` in interface `ComponentModel`
      Returns:
        true if a page

    - #### doHandleActivationEventContext

          public void doHandleActivationEventContext()

      Description copied from interface: `MutableComponentModel`
      Relevant for pages only, identifies that the component handle `EventConstants.ACTIVATE` events supporting one of the three special case for catch all rules:
      - ``Object`[]`
      - ``List``
      - ``EventContext``
      Specified by:
        `doHandleActivationEventContext` in interface `MutableComponentModel`

    - #### handleActivationEventContext

          public boolean handleActivationEventContext()

      Description copied from interface: `ComponentModel`
      Relevant for pages only, indicates that the component handle the `EventConstants.ACTIVATE` events with a catch all rules
      Specified by:
        `handleActivationEventContext` in interface `ComponentModel`
      Returns:
        true if the page implements catch all rules for the activate event context, or false otherwise
      See Also:
        `MutableComponentModel.doHandleActivationEventContext()`

${project.version} - Copyright © 2003-2015 The Apache Software Foundation.