diff options
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java')
-rw-r--r-- | framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java index a165be33..c75eccf9 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/ui/topo/PropertyPanel.java @@ -18,7 +18,7 @@ package org.onosproject.ui.topo; import com.google.common.collect.Sets; -import java.text.DecimalFormat; +import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -28,7 +28,7 @@ import java.util.Set; */ public class PropertyPanel { - private static final DecimalFormat DF0 = new DecimalFormat("#,###"); + private static final NumberFormat NF = NumberFormat.getInstance(); private String title; private String typeId; @@ -49,6 +49,24 @@ public class PropertyPanel { } /** + * Returns a number formatter to use for formatting integer and long + * property values. + * <p> + * This default implementation uses a formatter for the default + * locale. For example: + * <pre> + * Locale.ENGLISH : 1000 -> "1,000" + * Locale.FRENCH : 1000 -> "1 000" + * Locale.GERMAN : 1000 -> "1.000" + * </pre> + * + * @return the number formatter + */ + protected NumberFormat formatter() { + return NF; + } + + /** * Adds an ID field to the panel data, to be included in * the returned JSON data to the client. * @@ -80,7 +98,7 @@ public class PropertyPanel { * @return self, for chaining */ public PropertyPanel addProp(String key, int value) { - properties.add(new Prop(key, DF0.format(value))); + properties.add(new Prop(key, formatter().format(value))); return this; } @@ -92,7 +110,7 @@ public class PropertyPanel { * @return self, for chaining */ public PropertyPanel addProp(String key, long value) { - properties.add(new Prop(key, DF0.format(value))); + properties.add(new Prop(key, formatter().format(value))); return this; } |