Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.revolsys.ui.html.serializer.key;
 
 
Serialize a percent with the % sign.

Author(s):
Paul Austin
public class PercentKeySerializer implements KeySerializer {
  
The scale to display the percent as.
  private int scale = . - 2;

  
Construct a new PercentKeySerializer.
  public PercentKeySerializer() {
  }

  
Construct a new PercentKeySerializer.

Parameters:
displayScale The scale to display the percent as.
  public PercentKeySerializer(final int displayScale) {
    this. = displayScale;
  }

  
Serialize the value to the XML writer using the settings from the Locale.

Parameters:
out The XML writer to serialize to.
object The object to get the value from.
key The key of the property on the object to serialize.
locale The locale.
  public void serialize(final XmlWriter outfinal Object object,
    final String keyfinal Locale locale) {
    BigDecimal value = JavaBeanUtil.getProperty(objectkey);
    if (value != null) {
      out.text(MathUtil.percentToString(value));
    } else {
      out.text("-");
    }
  }
New to GrepCode? Check out our FAQ X