FileDocCategorySizeDatePackage
FormatNumberTag.javaAPI DocGlassfish v2 API9111Sat May 05 19:17:56 BST 2007org.apache.taglibs.standard.tag.el.fmt

FormatNumberTag

public class FormatNumberTag extends org.apache.taglibs.standard.tag.common.fmt.FormatNumberSupport

A handler for <formatNumber> that accepts attributes as Strings and evaluates them as expressions at runtime.

author
Jan Luehe

Fields Summary
private String
value_
private String
type_
private String
pattern_
private String
currencyCode_
private String
currencySymbol_
private String
groupingUsed_
private String
maxIntegerDigits_
private String
minIntegerDigits_
private String
maxFractionDigits_
private String
minFractionDigits_
Constructors Summary
public FormatNumberTag()
Constructs a new FormatNumberTag. As with TagSupport, subclasses should not provide other constructors and are expected to call the superclass constructor

        super();
        init();
    
Methods Summary
public intdoStartTag()


        // evaluate any expressions we were passed, once per invocation
        evaluateExpressions();

	// chain to the parent implementation
	return super.doStartTag();
    
private voidevaluateExpressions()

	Object obj = null;

        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

	// 'value' attribute
	if (value_ != null) {
	    value = ExpressionEvaluatorManager.evaluate(
	        "value", value_, Object.class, this, pageContext);
	}

	// 'type' attribute
	if (type_ != null) {
	    type = (String) ExpressionEvaluatorManager.evaluate(
	        "type", type_, String.class, this, pageContext);
	}

	// 'pattern' attribute
	if (pattern_ != null) {
	    pattern = (String) ExpressionEvaluatorManager.evaluate(
	        "pattern", pattern_, String.class, this, pageContext);
	}

	// 'currencyCode' attribute
	if (currencyCode_ != null) {
	    currencyCode = (String) ExpressionEvaluatorManager.evaluate(
	        "currencyCode", currencyCode_, String.class, this,
		pageContext);
	}

	// 'currencySymbol' attribute
	if (currencySymbol_ != null) {
	    currencySymbol = (String) ExpressionEvaluatorManager.evaluate(
	        "currencySymbol", currencySymbol_, String.class, this,
		pageContext);
	}

	// 'groupingUsed' attribute
	if (groupingUsed_ != null) {
	    obj = ExpressionEvaluatorManager.evaluate(
	        "groupingUsed", groupingUsed_, Boolean.class, this,
		pageContext);
	    if (obj != null) {
		isGroupingUsed = ((Boolean) obj).booleanValue();
	    }
	}

	// 'maxIntegerDigits' attribute
	if (maxIntegerDigits_ != null) {
	    obj = ExpressionEvaluatorManager.evaluate(
	        "maxIntegerDigits", maxIntegerDigits_, Integer.class, this,
		pageContext);
	    if (obj != null) {
		maxIntegerDigits = ((Integer) obj).intValue();
	    }
	}

	// 'minIntegerDigits' attribute	
	if (minIntegerDigits_ != null) {
	    obj = ExpressionEvaluatorManager.evaluate(
	        "minIntegerDigits", minIntegerDigits_, Integer.class, this,
		pageContext);
	    if (obj != null) {
		minIntegerDigits = ((Integer) obj).intValue();
	    }
	}

	// 'maxFractionDigits' attribute
	if (maxFractionDigits_ != null) {
	    obj = ExpressionEvaluatorManager.evaluate(
	        "maxFractionDigits", maxFractionDigits_, Integer.class, this,
		pageContext);
	    if (obj != null) {
		maxFractionDigits = ((Integer) obj).intValue();
	    }
	}

	// 'minFractionDigits' attribute
	if (minFractionDigits_ != null) {
	    obj = ExpressionEvaluatorManager.evaluate(
	        "minFractionDigits", minFractionDigits_, Integer.class, this,
		pageContext);
	    if (obj != null) {
		minFractionDigits = ((Integer) obj).intValue();
	    }
	}
    
private voidinit()

        // null implies "no expression"
	value_ = type_ = pattern_ = null;
	currencyCode_ = currencySymbol_ = null;
	groupingUsed_ = null;
	maxIntegerDigits_ = minIntegerDigits_ = null;
	maxFractionDigits_ = minFractionDigits_ = null;
    
public voidrelease()

        super.release();
        init();
    
public voidsetCurrencyCode(java.lang.String currencyCode_)

        this.currencyCode_ = currencyCode_;
    
public voidsetCurrencySymbol(java.lang.String currencySymbol_)

        this.currencySymbol_ = currencySymbol_;
    
public voidsetGroupingUsed(java.lang.String groupingUsed_)

        this.groupingUsed_ = groupingUsed_;
	this.groupingUsedSpecified = true;
    
public voidsetMaxFractionDigits(java.lang.String maxFractionDigits_)

        this.maxFractionDigits_ = maxFractionDigits_;
	this.maxFractionDigitsSpecified = true;
    
public voidsetMaxIntegerDigits(java.lang.String maxIntegerDigits_)

        this.maxIntegerDigits_ = maxIntegerDigits_;
	this.maxIntegerDigitsSpecified = true;
    
public voidsetMinFractionDigits(java.lang.String minFractionDigits_)

        this.minFractionDigits_ = minFractionDigits_;
	this.minFractionDigitsSpecified = true;
    
public voidsetMinIntegerDigits(java.lang.String minIntegerDigits_)

        this.minIntegerDigits_ = minIntegerDigits_;
	this.minIntegerDigitsSpecified = true;
    
public voidsetPattern(java.lang.String pattern_)

        this.pattern_ = pattern_;
    
public voidsetType(java.lang.String type_)

        this.type_ = type_;
    
public voidsetValue(java.lang.String value_)

        this.value_ = value_;
	this.valueSpecified = true;