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

org.apache.tiles
Class Definition

Package class diagram package Definition
java.lang.Object
  extended by org.apache.tiles.Definition

public class Definition
extends Object

A definition, i.e. a template with (completely or not) filled attributes. Attributes of a template can be defined with the help of this class.
It can be used as a data transfer object used for registering new definitions with the Container.

Since:
Tiles 2.0
Version:
$Rev: 619574 $ $Date: 2008-02-07 20:09:33 +0100 (Thu, 07 Feb 2008) $

Field Summary
protected  Map<String,Attribute> attributes
          Attributes defined for the definition.
protected  String inherit
          Extends attribute value.
protected  String name
          Definition name.
protected  String preparer
          Associated ViewPreparer URL or classname, if defined.
protected  Set<String> roles
          The roles that can render this definition.
protected  String template
          Template path.
 
Constructor Summary
Definition()
          Constructor.
Definition(Definition definition)
          Copy Constructor.
Definition(String name, String template, Map<String,Attribute> attributes)
          Constructor.
 
Method Summary
 void addAttribute(Attribute attribute)
          Deprecated. Use putAttribute(String, Attribute).
 Attribute getAttribute(String key)
          Returns the attribute for the given name, or null if no attribute of the given name exists.
 Map<String,Attribute> getAttributes()
          Access method for the attributes property.
 String getExtends()
          Get extends.
 String getName()
          Access method for the name property.
 String getPreparer()
          Get associated preparerInstance.
 String getRole()
          Access method for the role property.
 Set<String> getRoles()
          Returns the roles that can render this attribute.
 String getTemplate()
          Access method for the template property.
 boolean hasAttributeValue(String key)
          Checks whether the key attribute has been set.
 int hashCode()
          
 boolean isExtending()
          Get extends flag.
 void put(String name, Object content)
          Put an attribute in template definition.
 void put(String name, Object content, Attribute.AttributeType type, String role)
          Put an attribute in template definition.
 void put(String name, Object content, String role)
          Put an attribute in template definition.
 void putAttribute(String key, Attribute value)
          Put a new attribute in this definition.
 void setExtends(String name)
          Set extends.
 void setName(String aName)
          Sets the value of the name property.
 void setPreparer(String url)
          Set associated preparerInstance URL.
 void setRole(String role)
          Sets the value of the role property.
 void setRoles(Set<String> roles)
          Sets the roles that can render this attribute.
 void setTemplate(String template)
          Sets the value of the template property.
 String toString()
          Returns a description of the attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

inherit

protected String inherit
Extends attribute value.


name

protected String name
Definition name.


template

protected String template
Template path.


attributes

protected Map<String,Attribute> attributes
Attributes defined for the definition.


roles

protected Set<String> roles
The roles that can render this definition.

Since:
2.0.6

preparer

protected String preparer
Associated ViewPreparer URL or classname, if defined.

Constructor Detail

Definition

public Definition()
Constructor.


Definition

public Definition(Definition definition)
Copy Constructor. Create a new definition initialized with parent definition. Do a shallow copy : attributes are shared between copies, but not the Map containing attributes.

Parameters:
definition - The definition to copy.

Definition

public Definition(String name,
                  String template,
                  Map<String,Attribute> attributes)
Constructor.

Parameters:
name - The name of the definition.
template - The template of the definition.
attributes - The attribute map of the definition.
Method Detail

getName

public String getName()
Access method for the name property.

Returns:
the current value of the name property

setName

public void setName(String aName)
Sets the value of the name property.

Parameters:
aName - the new value of the name property

getTemplate

public String getTemplate()
Access method for the template property.

Returns:
the current value of the template property

setTemplate

public void setTemplate(String template)
Sets the value of the template property.

Parameters:
template - the new value of the path property

getRole

public String getRole()
Access method for the role property.

Returns:
the current value of the role property

getRoles

public Set<String> getRoles()
Returns the roles that can render this attribute.

Returns:
The enabled roles.
Since:
2.0.6

setRole

public void setRole(String role)
Sets the value of the role property.

Parameters:
role - the new value of the role property

setRoles

public void setRoles(Set<String> roles)
Sets the roles that can render this attribute.

Parameters:
roles - The enabled roles.
Since:
2.0.6

getAttributes

public Map<String,Attribute> getAttributes()
Access method for the attributes property. If there is no attributes, return an empty map.

Returns:
the current value of the attributes property

getAttribute

public Attribute getAttribute(String key)
Returns the attribute for the given name, or null if no attribute of the given name exists.

Parameters:
key - name of the attribute
Returns:
requested attribute or null if not found

putAttribute

public void putAttribute(String key,
                         Attribute value)
Put a new attribute in this definition.

Parameters:
key - String key for attribute
value - Attibute value.

addAttribute

@Deprecated
public void addAttribute(Attribute attribute)
Deprecated. Use putAttribute(String, Attribute).

Add an attribute to this definition.

This method is used by Digester to load definitions.

Parameters:
attribute - Attribute to add.

hasAttributeValue

public boolean hasAttributeValue(String key)
Checks whether the key attribute has been set.

Parameters:
key - The attribute key to check.
Returns:
true if the attribute has a value.

put

public void put(String name,
                Object content)
Put an attribute in template definition. Attribute can be used as content for tag get.

Parameters:
name - Attribute name
content - Attribute value

put

public void put(String name,
                Object content,
                String role)
Put an attribute in template definition. Attribute can be used as content for tag get.

Parameters:
name - Attribute name
content - Attribute value
role - Determine if content is used by get tag. If user is in role, content is used.

put

public void put(String name,
                Object content,
                Attribute.AttributeType type,
                String role)
Put an attribute in template definition. Attribute can be used as content for tag get.

Parameters:
name - Attribute name
content - Attribute value
type - attribute type: template, string, definition
role - Determine if content is used by get tag. If user is in role, content is used.

getPreparer

public String getPreparer()
Get associated preparerInstance.

Returns:
The preparer name.

setPreparer

public void setPreparer(String url)
Set associated preparerInstance URL.

Parameters:
url - Url called locally

setExtends

public void setExtends(String name)
Set extends.

Parameters:
name - Name of the extended definition.

getExtends

public String getExtends()
Get extends.

Returns:
Name of the extended definition.

hashCode

public int hashCode()

Overrides:
hashCode in class Object

isExtending

public boolean isExtending()
Get extends flag.

Returns:
true if this definition extends another.

toString

public String toString()
Returns a description of the attributes.

Overrides:
toString in class Object
Returns:
A string representation of the content of this definition.


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