org.mmbase.bridge.jsp.taglib.util
Class Attribute

java.lang.Object
  extended byorg.mmbase.bridge.jsp.taglib.util.Attribute

public class Attribute
extends Object

MMBase Taglib attributes can contain $-variables. Parsing of these $-variables is cached. Evaluation of these vars must be postponed until doStartTag because servlet containers can decide not to call the set-function of the attribute (in case of tag-instance-reuse).

Since:
MMBase-1.7
Version:
$Id: Attribute.java,v 1.28 2005/08/25 08:25:40 michiel Exp $
Author:
Michiel Meeuwissen

Field Summary
static Attribute NULL
           
 
Constructor Summary
protected Attribute()
           
protected Attribute(Object at)
          The constructor is protected, construction is done by the cache.
 
Method Summary
 void appendValue(ContextReferrerTag tag, StringBuffer buffer)
          Appends the evaluated Attribute to StringBuffer
static Attribute getAttribute(Object at)
          This is the function for public use.
 boolean getBoolean(ContextReferrerTag tag, boolean def)
          Returns the evaluated Attribute as a boolen (depending on if getValue returns one of the strings 'true' or 'false' (case insensitve)).
 int getInt(ContextReferrerTag tag, int def)
          Returns the evaluated Attribute as a int
 List getList(ContextReferrerTag tag)
          Returns the evaluated Attribute as a List (evalatued to comma-seperated String, which is 'split').
 long getLong(ContextReferrerTag tag, long def)
           
 String getString(ContextReferrerTag tag)
          Returns the evaluated Attribute as a String.
 Object getValue(ContextReferrerTag tag)
          Returns the evaluated Attribute as an Object.
protected  void parse()
          Parses this attribute into list of 'attributeparts'.
 String toString()
          String representation of this Attribute object (for debugging)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NULL

public static final Attribute NULL
Constructor Detail

Attribute

protected Attribute(Object at)
             throws JspTagException
The constructor is protected, construction is done by the cache.


Attribute

protected Attribute()
Method Detail

getAttribute

public static final Attribute getAttribute(Object at)
                                    throws JspTagException
This is the function for public use. It takes the string and returns an Attribute, creating a new one if it is not in the Attribute cache.

Throws:
JspTagException

appendValue

public void appendValue(ContextReferrerTag tag,
                        StringBuffer buffer)
                 throws JspTagException
Appends the evaluated Attribute to StringBuffer

Parameters:
tag - The tag relative to which the variable evalutations must be done (normally 'this' in a Tag implementation)
Throws:
JspTagException

getValue

public Object getValue(ContextReferrerTag tag)
                throws JspTagException
Returns the evaluated Attribute as an Object. Can also be null.

Throws:
JspTagException

getString

public String getString(ContextReferrerTag tag)
                 throws JspTagException
Returns the evaluated Attribute as a String. This is never null (empty string in that case)..

Throws:
JspTagException

getInt

public int getInt(ContextReferrerTag tag,
                  int def)
           throws JspTagException
Returns the evaluated Attribute as a int

Throws:
JspTagException

getLong

public long getLong(ContextReferrerTag tag,
                    long def)
             throws JspTagException
Throws:
JspTagException

getList

public List getList(ContextReferrerTag tag)
             throws JspTagException
Returns the evaluated Attribute as a List (evalatued to comma-seperated String, which is 'split'). The List is empty if getValue would give empty String or null.

Throws:
JspTagException

getBoolean

public boolean getBoolean(ContextReferrerTag tag,
                          boolean def)
                   throws JspTagException
Returns the evaluated Attribute as a boolen (depending on if getValue returns one of the strings 'true' or 'false' (case insensitve)).

Parameters:
def - If the string is not "true" or "false', then this value is returned.
Returns:
true or false
Throws:
JspTagException

toString

public String toString()
String representation of this Attribute object (for debugging)


parse

protected void parse()
              throws JspTagException
Parses this attribute into list of 'attributeparts'. This is the heart of the Attribute class. The method getValue(org.mmbase.bridge.jsp.taglib.ContextReferrerTag) will concatenate them together again (after evaluation).

Throws:
JspTagException


MMBase build 1.8.1.20060716