This project has retired. For details please refer to its Attic page.
DefinitionsImpl (Tiles 2 2.0.7 API)

org.apache.tiles.definition
Class DefinitionsImpl

Package class diagram package DefinitionsImpl
java.lang.Object
  extended by org.apache.tiles.definition.DefinitionsImpl
All Implemented Interfaces:
Definitions

public class DefinitionsImpl
extends Object
implements Definitions

Version:
$Rev: 605994 $ $Date: 2007-12-20 19:41:47 +0100 (Thu, 20 Dec 2007) $

Constructor Summary
DefinitionsImpl()
          Creates a new instance of DefinitionsImpl.
 
Method Summary
 void addDefinitions(Map<String,Definition> defsMap)
          Adds new Definition objects to the internal collection and resolves inheritance attraibutes.
 void addDefinitions(Map<String,Definition> defsMap, Locale locale)
          Adds new locale-specific Definition objects to the internal collection and resolves inheritance attraibutes.
 Map<String,Definition> getBaseDefinitions()
          Returns base definitions collection.
 Definition getDefinition(String name)
          Returns a Definition object that matches the given name.
 Definition getDefinition(String name, Locale locale)
          Returns a Definition object that matches the given name and locale.
protected  Definition getDefinitionByAttribute(Attribute attr, Locale locale)
          Searches for a definition specified as an attribute.
protected  void overload(Definition parent, Definition child)
          Overloads a child definition with a given parent.
 void reset()
          Clears definitions.
protected  void resolveInheritance(Definition definition, Locale locale, Set<String> alreadyResolvedDefinitions)
          Resolve locale-specific inheritance.
 void resolveInheritances()
          Resolve extended instances.
 void resolveInheritances(Locale locale)
          Resolve locale-specific extended instances.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefinitionsImpl

public DefinitionsImpl()
Creates a new instance of DefinitionsImpl.

Method Detail

getDefinition

public Definition getDefinition(String name)
Returns a Definition object that matches the given name.

Specified by:
getDefinition in interface Definitions
Parameters:
name - The name of the Definition to return.
Returns:
the Definition matching the given name or null if none is found.

addDefinitions

public void addDefinitions(Map<String,Definition> defsMap)
                    throws NoSuchDefinitionException
Adds new Definition objects to the internal collection and resolves inheritance attraibutes.

Specified by:
addDefinitions in interface Definitions
Parameters:
defsMap - The new definitions to add.
Throws:
NoSuchDefinitionException - If something goes wrong during addition.

addDefinitions

public void addDefinitions(Map<String,Definition> defsMap,
                           Locale locale)
                    throws NoSuchDefinitionException
Adds new locale-specific Definition objects to the internal collection and resolves inheritance attraibutes.

Specified by:
addDefinitions in interface Definitions
Parameters:
defsMap - The new definitions to add.
locale - The locale to add the definitions to.
Throws:
NoSuchDefinitionException - If something goes wrong during inheritance resolution.

getDefinition

public Definition getDefinition(String name,
                                Locale locale)
Returns a Definition object that matches the given name and locale.

Specified by:
getDefinition in interface Definitions
Parameters:
name - The name of the Definition to return.
locale - The locale to use to resolve the definition.
Returns:
the Definition matching the given name or null if none is found.

resolveInheritances

public void resolveInheritances()
                         throws NoSuchDefinitionException
Resolve extended instances.

Specified by:
resolveInheritances in interface Definitions
Throws:
NoSuchDefinitionException - If a parent definition is not found.

resolveInheritances

public void resolveInheritances(Locale locale)
                         throws NoSuchDefinitionException
Resolve locale-specific extended instances.

Specified by:
resolveInheritances in interface Definitions
Parameters:
locale - The locale to use.
Throws:
NoSuchDefinitionException - If a parent definition is not found.

reset

public void reset()
Clears definitions.

Specified by:
reset in interface Definitions

getBaseDefinitions

public Map<String,Definition> getBaseDefinitions()
Returns base definitions collection.

Specified by:
getBaseDefinitions in interface Definitions
Returns:
The base (i.e. not depending on any locale) definitions map.

getDefinitionByAttribute

protected Definition getDefinitionByAttribute(Attribute attr,
                                              Locale locale)
Searches for a definition specified as an attribute.

Parameters:
attr - The attribute to use.
locale - The locale to search into.
Returns:
The required definition if found, otherwise it returns null.

resolveInheritance

protected void resolveInheritance(Definition definition,
                                  Locale locale,
                                  Set<String> alreadyResolvedDefinitions)
                           throws NoSuchDefinitionException
Resolve locale-specific inheritance. First, resolve parent's inheritance, then set template to the parent's template. Also copy attributes setted in parent, and not set in child If instance doesn't extend anything, do nothing.

Parameters:
definition - The definition to resolve
locale - The locale to use.
alreadyResolvedDefinitions - The set of the definitions that have been already resolved.
Throws:
NoSuchDefinitionException - If an inheritance can not be solved.

overload

protected void overload(Definition parent,
                        Definition child)
Overloads a child definition with a given parent. All attributes present in child are kept. All missing attributes are copied from the parent. Special attribute 'template','role' and 'extends' are overloaded in child if not defined

Parameters:
parent - The parent definition.
child - The child that will be overloaded.


Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.