org.apache.tiles
Class Definition

java.lang.Object
  extended by org.apache.tiles.Definition

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


name

protected java.lang.String name
Definition name.


template

protected java.lang.String template
Template path.


attributes

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


roles

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

Since:
2.0.6

preparer

protected java.lang.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(java.lang.String name,
                  java.lang.String template,
                  java.util.Map<java.lang.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 java.lang.String getName()
Access method for the name property.

Returns:
the current value of the name property

setName

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

Parameters:
aName - the new value of the name property

getTemplate

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

Returns:
the current value of the template property

setTemplate

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

Parameters:
template - the new value of the path property

getRole

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

Returns:
the current value of the role property

getRoles

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

Returns:
The enabled roles.
Since:
2.0.6

setRole

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

Parameters:
role - the new value of the role property

setRoles

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

Parameters:
roles - The enabled roles.
Since:
2.0.6

getAttributes

public java.util.Map<java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.String name,
                java.lang.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(java.lang.String name,
                java.lang.Object content,
                java.lang.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(java.lang.String name,
                java.lang.Object content,
                Attribute.AttributeType type,
                java.lang.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 java.lang.String getPreparer()
Get associated preparerInstance.

Returns:
The preparer name.

setPreparer

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

Parameters:
url - Url called locally

setExtends

public void setExtends(java.lang.String name)
Set extends.

Parameters:
name - Name of the extended definition.

getExtends

public java.lang.String getExtends()
Get extends.

Returns:
Name of the extended definition.

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

isExtending

public boolean isExtending()
Get extends flag.

Returns:
true if this definition extends another.

toString

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

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