org.apache.tiles
Class Attribute

Package class diagram package Attribute
java.lang.Object
  extended by org.apache.tiles.Attribute
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ListAttribute

public class Attribute
extends java.lang.Object
implements java.io.Serializable

Common implementation of attribute definition.

See Also:
Serialized Form

Nested Class Summary
static class Attribute.AttributeType
          Deprecated. Use setRenderer(String) and getRenderer().
 
Field Summary
protected  java.lang.String expression
          The expression to evaluate.
protected  java.util.Set<java.lang.String> roles
          The roles that can render this attribute.
protected  java.lang.Object value
          The value of the attribute.
 
Constructor Summary
Attribute()
          Constructor.
Attribute(Attribute attribute)
          Copy constructor.
Attribute(java.lang.Object value)
          Constructor.
Attribute(java.lang.Object value, java.lang.String role)
          Constructor.
Attribute(java.lang.Object value, java.lang.String role, Attribute.AttributeType type)
          Deprecated. Use Attribute(Object, String, String, String).
Attribute(java.lang.Object value, java.lang.String expression, java.lang.String role, java.lang.String rendererName)
          Constructor.
Attribute(java.lang.String name, java.lang.Object value)
          Constructor.
Attribute(java.lang.String name, java.lang.Object value, java.lang.String role, Attribute.AttributeType type)
          Deprecated. Use Attribute#Attribute(Object, String, String))).
 
Method Summary
static Attribute createTemplateAttribute(java.lang.String template)
          Creates a template attribute, starting from the name of the template.
static Attribute createTemplateAttributeWithExpression(java.lang.String templateExpression)
          Creates a template attribute, starting from the expression to evaluate to obtain the template.
 java.lang.String getExpression()
          Returns The expression to evaluate.
 java.lang.String getName()
          Deprecated. Use the getName methods in object that contain attributes.
 java.lang.String getRenderer()
          Returns the renderer name to use.
 java.lang.String getRole()
          Get role.
 java.util.Set<java.lang.String> getRoles()
          Returns the roles that can render this attribute.
 Attribute.AttributeType getType()
          Deprecated. Use getRenderer().
 java.lang.Object getValue()
          Get value.
 void inherit(Attribute attribute)
          Inherits an attribute, i.e. overwrites null properties with the ones provided by the attribute.
 void setBody(java.lang.String body)
          Sets the body of this attribute.
 void setExpression(java.lang.String expression)
          Sets The expression to evaluate.
 void setName(java.lang.String name)
          Deprecated. Use the setName methods in object that contain attributes.
 void setRenderer(java.lang.String rendererName)
          Sets the renderer name to use.
 void setRole(java.lang.String role)
          Set role.
 void setRoles(java.util.Set<java.lang.String> roles)
          Sets the roles that can render this attribute.
 void setType(Attribute.AttributeType type)
          Deprecated. Use Attribute#setRenderer(String)).
 void setValue(java.lang.Object value)
          Set value.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

roles

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

Since:
2.0.6

value

protected java.lang.Object value
The value of the attribute.


expression

protected java.lang.String expression
The expression to evaluate. Ignored if value is not null.

Since:
2.1.2
Constructor Detail

Attribute

public Attribute()
Constructor.


Attribute

public Attribute(java.lang.Object value)
Constructor.

Parameters:
value - Object to store.

Attribute

public Attribute(Attribute attribute)
Copy constructor.

Parameters:
attribute - The attribute to copy from.

Attribute

public Attribute(java.lang.String name,
                 java.lang.Object value)
Constructor.

Parameters:
name - name of the attribute
value - Object to store.

Attribute

public Attribute(java.lang.Object value,
                 java.lang.String role)
Constructor.

Parameters:
value - Object to store.
role - Asociated role.

Attribute

@Deprecated
public Attribute(java.lang.Object value,
                            java.lang.String role,
                            Attribute.AttributeType type)
Deprecated. Use Attribute(Object, String, String, String).

Constructor.

Parameters:
value - Object to store.
role - Associated role.
type - Attribute type.

Attribute

public Attribute(java.lang.Object value,
                 java.lang.String expression,
                 java.lang.String role,
                 java.lang.String rendererName)
Constructor.

Parameters:
value - Object to store. If specified, the expression parameter will be ignored.
expression - The expression to be evaluated. Ignored if the value is not null.
role - Associated role.
rendererName - The renderer name.
Since:
2.1.2

Attribute

public Attribute(java.lang.String name,
                 java.lang.Object value,
                 java.lang.String role,
                 Attribute.AttributeType type)
Deprecated. Use Attribute#Attribute(Object, String, String))).

Constructor.

Parameters:
name - name of the attribute
value - Object to store.
role - Asociated role.
type - Attribute type.
Method Detail

createTemplateAttribute

public static Attribute createTemplateAttribute(java.lang.String template)
Creates a template attribute, starting from the name of the template.

Parameters:
template - The template that will be rendered.
Returns:
The template attribute.
Since:
2.1.2

createTemplateAttributeWithExpression

public static Attribute createTemplateAttributeWithExpression(java.lang.String templateExpression)
Creates a template attribute, starting from the expression to evaluate to obtain the template.

Parameters:
templateExpression - The expression to evaluate.
Returns:
The template attribute.
Since:
2.1.2

getRole

public java.lang.String getRole()
Get role.

Returns:
the name of the required role(s)

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)
Set role.

Parameters:
role - Associated role.

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

getValue

public java.lang.Object getValue()
Get value.

Returns:
the value

setValue

public void setValue(java.lang.Object value)
Set value.

Parameters:
value - New value.

getExpression

public java.lang.String getExpression()
Returns The expression to evaluate. Ignored if value is not null.

Returns:
The expression to be evaluated.
Since:
2.1.2

setExpression

public void setExpression(java.lang.String expression)
Sets The expression to evaluate. Ignored if value is not null.

Parameters:
expression - The expression to be evaluated.
Since:
2.1.2

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

getType

public Attribute.AttributeType getType()
Deprecated. Use getRenderer().

Returns the type of this attribute.

Returns:
The attribute type. It can be string, template, definition, object.

setType

public void setType(Attribute.AttributeType type)
Deprecated. Use Attribute#setRenderer(String)).

Sets the type of this attribute.

Parameters:
type - The attribute type.

getRenderer

public java.lang.String getRenderer()
Returns the renderer name to use.

Returns:
The renderer name.
Since:
2.1.0

setRenderer

public void setRenderer(java.lang.String rendererName)
Sets the renderer name to use.

Parameters:
rendererName - The renderer.
Since:
2.1.0

getName

@Deprecated
public java.lang.String getName()
Deprecated. Use the getName methods in object that contain attributes.

Returns the name of the attribute.

Returns:
The name of the attribute. It can be null, but in this case it should be used as an element of ListAttribute

setName

@Deprecated
public void setName(java.lang.String name)
Deprecated. Use the setName methods in object that contain attributes.

Sets the name of the attribute.

Parameters:
name - The name of the attribute. It can be null, but in this case it should be used as an element of ListAttribute

setBody

public void setBody(java.lang.String body)
Sets the body of this attribute.

Parameters:
body - The attribute body.

inherit

public void inherit(Attribute attribute)
Inherits an attribute, i.e. overwrites null properties with the ones provided by the attribute.

Parameters:
attribute - The attribute to inherit.
Since:
2.1.2