Repository: struts Updated Branches: refs/heads/master 9cde17b22 -> 99bb67143
WW-4721 Enables rounding mode Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/99bb6714 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/99bb6714 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/99bb6714 Branch: refs/heads/master Commit: 99bb6714373a4b6f877a53dec1f52b1ac26b75b9 Parents: 9cde17b Author: Lukasz Lenart <lukaszlen...@apache.org> Authored: Mon Nov 28 17:03:48 2016 +0100 Committer: Lukasz Lenart <lukaszlen...@apache.org> Committed: Mon Nov 28 17:03:48 2016 +0100 ---------------------------------------------------------------------- .../org/apache/struts2/components/Number.java | 34 +++++++------------- 1 file changed, 12 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/99bb6714/core/src/main/java/org/apache/struts2/components/Number.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/components/Number.java b/core/src/main/java/org/apache/struts2/components/Number.java index a52bff2..7ca45b1 100644 --- a/core/src/main/java/org/apache/struts2/components/Number.java +++ b/core/src/main/java/org/apache/struts2/components/Number.java @@ -1,11 +1,4 @@ -/** - * - */ -package org.apache.struts2.components; - /* - * $Id$ - * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information @@ -23,6 +16,7 @@ package org.apache.struts2.components; * specific language governing permissions and limitations * under the License. */ +package org.apache.struts2.components; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.util.ValueStack; @@ -33,6 +27,7 @@ import org.apache.struts2.views.annotations.StrutsTagAttribute; import java.io.IOException; import java.io.Writer; +import java.math.RoundingMode; import java.text.NumberFormat; import java.util.Currency; @@ -154,16 +149,14 @@ public class Number extends ContextBean { setRoundingMode(format); String msg = format.format(number); - if (msg != null) { - try { - if (getVar() == null) { - writer.write(msg); - } else { - putInContext(msg); - } - } catch (IOException e) { - LOG.error("Could not write out Number tag", e); + try { + if (getVar() == null) { + writer.write(msg); + } else { + putInContext(msg); } + } catch (IOException e) { + LOG.error("Could not write out Number tag", e); } } return super.end(writer, ""); @@ -221,8 +214,6 @@ public class Number extends ContextBean { } private void setRoundingMode(NumberFormat format) { - /* - TODO lukaszlenart: enable when switched to Java 1.6 if (roundingMode != null) { roundingMode = findString(roundingMode); if ("ceiling".equals(roundingMode)) { @@ -245,7 +236,6 @@ public class Number extends ContextBean { LOG.error("Could not recognise a roundingMode of [" + roundingMode + "]"); } } - */ } private NumberFormat getNumberFormat() { @@ -275,12 +265,12 @@ public class Number extends ContextBean { return format; } - @StrutsTagAttribute(description = "Type of number formatter (currency, integer, number or percent, default is number)", rtexprvalue = false) + @StrutsTagAttribute(description = "Type of number formatter (currency, integer, number or percent, default is number)") public void setType(String type) { this.type = type; } - @StrutsTagAttribute(description = "The currency to use for a currency format", type = "String", defaultValue = "") + @StrutsTagAttribute(description = "The currency to use for a currency format") public void setCurrency(String currency) { this.currency = currency; } @@ -408,7 +398,7 @@ public class Number extends ContextBean { /** * @param roundingMode the roundingMode to set */ - @StrutsTagAttribute(description = "The rounding mode to use - not implemented yet as this required Java 1.6", type = "String") + @StrutsTagAttribute(description = "The rounding mode to use, possible values: ceiling, down, floor, half-down, half-even, half-up, unnecessary, up") public void setRoundingMode(String roundingMode) { this.roundingMode = roundingMode; }