1 /*
2 ~ Copyright 2006-2007 Nicolas De Loof.
3 ~
4 ~ Licensed under the Apache License, Version 2.0 (the "License");
5 ~ you may not use this file except in compliance with the License.
6 ~ You may obtain a copy of the License at
7 ~
8 ~ http://www.apache.org/licenses/LICENSE-2.0
9 ~
10 ~ Unless required by applicable law or agreed to in writing, software
11 ~ distributed under the License is distributed on an "AS IS" BASIS,
12 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ~ See the License for the specific language governing permissions and
14 ~ limitations under the License.
15 */
16 package org.jmonit.reporting;
17
18 import java.io.PrintWriter;
19 import java.text.DecimalFormat;
20 import java.text.DecimalFormatSymbols;
21 import java.text.NumberFormat;
22 import java.util.Locale;
23
24 /**
25 * @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
26 */
27 public abstract class AbstractRenderer
28 implements Renderer
29 {
30 protected PrintWriter writer;
31
32 protected NumberFormat number =
33 new DecimalFormat( "#.##", new DecimalFormatSymbols( Locale.US ) );
34 {
35 number.setGroupingUsed( false );
36 }
37
38 public AbstractRenderer( PrintWriter writer )
39 {
40 super();
41 this.writer = writer;
42 }
43
44 protected abstract String getPrefix( String string );
45
46 protected abstract String getSuffix( boolean last );
47
48 /**
49 * {@inheritDoc}
50 *
51 * @see org.jmonit.reporting.Renderer#setLocale(java.util.Locale)
52 */
53 public void setLocale( Locale locale )
54 {
55 number = DecimalFormat.getNumberInstance( locale );
56 }
57 }