Example usage for java.util Locale setDefault

List of usage examples for java.util Locale setDefault

Introduction

In this page you can find the example usage for java.util Locale setDefault.

Prototype

public static synchronized void setDefault(Locale newLocale) 

Source Link

Document

Sets the default locale for this instance of the Java Virtual Machine.

Usage

From source file:ca.nines.ise.cmd.Modernize.java

/**
 * {@inheritDoc}/*from   w  ww.  java2 s.c o m*/
 */
@Override
public void execute(CommandLine cmd) throws Exception {
    PrintStream out;
    Writer renderer;
    Log log = Log.getInstance();
    Locale.setDefault(Locale.ENGLISH);
    out = new PrintStream(System.out, true, "UTF-8");
    if (cmd.hasOption("o")) {
        out = new PrintStream(new FileOutputStream(cmd.getOptionValue("o")), true, "UTF-8");
    }

    renderer = new SGMLWriter(out);
    String[] files = getArgList(cmd);
    DOM dom = new DOMBuilder(new File(files[0])).build();
    if (dom.getStatus() == DOMStatus.ERROR) {
        System.err.println("Document contains errors. Cannot continue.");
        if (log.count() > 0) {
            out.println(log);
            log.clear();
        }
        System.exit(-1);
    }

    Schema schema = Schema.defaultSchema();
    DOMValidator dv = new DOMValidator();
    NestingValidator nv = new NestingValidator(schema);

    Modernizer m = new Modernizer();
    Normalizer n = new Normalizer();
    Formatter f = new Formatter();
    dv.validate(dom, schema);
    nv.validate(dom);

    dom = m.transform(dom);
    dom = n.transform(dom);
    dom = f.transform(dom);

    renderer.render(dom);
}

From source file:ca.nines.ise.cmd.Transform.java

/**
 * {@inheritDoc}/*  w  ww.  j a  v a  2  s.  com*/
 */
@Override
public void execute(CommandLine cmd) throws Exception {
    PrintStream out;
    Locale.setDefault(Locale.ENGLISH);
    out = new PrintStream(System.out, true, "UTF-8");
    if (cmd.hasOption("o")) {
        out = new PrintStream(new FileOutputStream(cmd.getOptionValue("o")), true, "UTF-8");
    }

    Log log = Log.getInstance();
    Writer renderer = null;

    if (cmd.hasOption("text")) {
        renderer = new TextWriter(out);
    }
    if (cmd.hasOption("xml")) {
        renderer = new XMLWriter(out);
    }
    if (cmd.hasOption("rtf")) {
        renderer = new RTFWriter(out);
    }
    if (cmd.hasOption("sgml")) {
        renderer = new SGMLWriter(out);
    }
    if (cmd.hasOption("ximl")) {
        renderer = new ExpandedSGMLWriter(out);
    }

    if (renderer == null) {
        System.err.println("You must specify a transformation");
        System.exit(1);
        return;
    }

    String[] files = getArgList(cmd);
    DOM dom = new DOMBuilder(new File(files[0])).build();

    Schema schema = Schema.defaultSchema();
    DOMValidator dv = new DOMValidator();
    NestingValidator nv = new NestingValidator(schema);
    dv.validate(dom, schema);
    nv.validate(dom);

    if (dom.getStatus() != DOMStatus.ERROR) {
        if (files.length == 2) {
            Annotation ann = Annotation.builder().from(new File(files[1])).build();
            renderer.render(dom, ann);
        } else {
            renderer.render(dom);
        }
    } else {
        Message m = Message.builder("dom.errors").setSource(dom.getSource()).build();
        log.add(m);
    }
    if (log.count() > 0) {
        System.err.println(log.count() + " errors or warnings.");
        System.err.println(log);
    }
    log.clear();
}

From source file:org.apache.wicket.security.examples.springsecurity.AbstractSecureTestPage.java

/**
 * @see junit.framework.TestCase#setUp()
 *//*from w  ww .  j a  va  2 s  . co m*/
@Override
protected void setUp() throws Exception {
    Locale.setDefault(Locale.UK);

    String webAppLocation;

    File currentDir = new File(".");
    log.debug("CurrentDir:" + currentDir.getCanonicalPath());
    if (currentDir.getCanonicalPath().endsWith("examples/spring-security")) {
        webAppLocation = "src/main/webapp";
    } else {
        webAppLocation = "examples/spring-security/src/main/webapp";
    }

    log.debug("start the testapplication with location: " + webAppLocation);
    application = new SpringSecureWicketTestApplication();
    mock = new WicketTester(application, webAppLocation);
}

From source file:org.geomajas.plugin.printing.component.ComponentUtilTest.java

@Test
public void testGetResourceBundleUnknown() throws Exception {
    String locale = "xyz";
    String[] defaultLocaleArray = new String[] { "en", "nl" };
    for (String defaultLocale : defaultLocaleArray) {
        Locale.setDefault(LocaleUtils.toLocale(defaultLocale));
        ResourceBundle resourceBundle = ComponentUtil.getCurrentResourceBundle(locale);
        Assert.assertEquals(defaultLocale.toLowerCase(), resourceBundle.getLocale().toString().toLowerCase());
    }//w ww  .  j av  a  2 s. c om
}

From source file:net.sf.dynamicreports.test.jasper.chart.BubbleChartTest.java

@Override
protected void configureReport(JasperReportBuilder rb) {
    TextColumnBuilder<Integer> column1;
    TextColumnBuilder<Integer> column2;
    TextColumnBuilder<Double> column3;

    Locale.setDefault(Locale.ENGLISH);

    rb.columns(column1 = col.column("Column1", "field1", Integer.class),
            column2 = col.column("Column2", "field2", Integer.class),
            column3 = col.column("Column3", "field3", Double.class))
            .summary(//from   ww w  .  j  a v a 2 s  .c o m
                    cht.bubbleChart().setXValue(column1)
                            .series(cht.xyzSerie().setYValue(column2).setZValue(column3)
                                    .setSeries(exp.text("a")),
                                    cht.xyzSerie().setXValue(column2).setYValue(column1).setZValue(column3))
                            .setScaleType(ScaleType.ON_BOTH_AXES),
                    cht.bubbleChart().setXValue(column1)
                            .series(cht.xyzSerie().setYValue(column2).setZValue(column3))
                            .setXAxisFormat(cht.axisFormat().setLabel("category").setLabelColor(Color.BLUE)
                                    .setLabelFont(stl.fontArialBold())
                                    .setTickLabelFont(stl.fontArial().setItalic(true))
                                    .setTickLabelColor(Color.CYAN).setLineColor(Color.LIGHT_GRAY)),
                    cht.bubbleChart().setXValue(column1)
                            .series(cht.xyzSerie().setYValue(column2).setZValue(column3))
                            .setYAxisFormat(cht.axisFormat().setLabel("value").setLabelColor(Color.BLUE)
                                    .setLabelFont(stl.fontArialBold())
                                    .setTickLabelFont(stl.fontArial().setItalic(true))
                                    .setTickLabelColor(Color.CYAN).setTickLabelMask("#,##0.00")
                                    .setLineColor(Color.LIGHT_GRAY)));
}

From source file:net.sf.dynamicreports.test.jasper.chart.ScatterChartTest.java

@Override
protected void configureReport(JasperReportBuilder rb) {
    TextColumnBuilder<Integer> column1;
    TextColumnBuilder<Integer> column2;

    Locale.setDefault(Locale.ENGLISH);

    rb.columns(column1 = col.column("Column1", "field1", Integer.class),
            column2 = col.column("Column2", "field2", Integer.class))
            .summary(//from   ww w .j a va2  s  .  c o  m
                    cht.scatterChart().setXValue(column1)
                            .series(cht.xySerie(column2), cht.xySerie(column1).setXValue(column2))
                            .setShowShapes(false).setShowLines(false),
                    cht.scatterChart().setXValue(column1).series(cht.xySerie(column2))
                            .setXAxisFormat(cht.axisFormat().setLabel("category").setLabelColor(Color.BLUE)
                                    .setLabelFont(stl.fontArialBold())
                                    .setTickLabelFont(stl.fontArial().setItalic(true))
                                    .setTickLabelColor(Color.CYAN).setLineColor(Color.LIGHT_GRAY)),
                    cht.scatterChart().setXValue(column1).series(cht.xySerie(column2))
                            .setYAxisFormat(cht.axisFormat().setLabel("value").setLabelColor(Color.BLUE)
                                    .setLabelFont(stl.fontArialBold())
                                    .setTickLabelFont(stl.fontArial().setItalic(true))
                                    .setTickLabelColor(Color.CYAN).setTickLabelMask("#,##0.00")
                                    .setLineColor(Color.LIGHT_GRAY)));
}

From source file:net.sf.dynamicreports.test.jasper.chart.XyAreaChartTest.java

@Override
protected void configureReport(JasperReportBuilder rb) {
    TextColumnBuilder<Integer> column1;
    TextColumnBuilder<Integer> column2;

    Locale.setDefault(Locale.ENGLISH);

    rb.columns(column1 = col.column("Column1", "field1", Integer.class),
            column2 = col.column("Column2", "field2", Integer.class))
            .summary(cht.xyAreaChart().setXValue(column1).series(cht.xySerie(column2))
                    .setXAxisFormat(cht.axisFormat().setLabel("category").setLabelColor(Color.BLUE)
                            .setLabelFont(stl.fontArialBold()).setTickLabelFont(stl.fontArial().setItalic(true))
                            .setTickLabelColor(Color.CYAN).setLineColor(Color.LIGHT_GRAY)),
                    cht.xyAreaChart().setXValue(column1).series(cht.xySerie(column2))
                            .setYAxisFormat(cht.axisFormat().setLabel("value").setLabelColor(Color.BLUE)
                                    .setLabelFont(stl.fontArialBold())
                                    .setTickLabelFont(stl.fontArial().setItalic(true))
                                    .setTickLabelColor(Color.CYAN).setTickLabelMask("#,##0.00")
                                    .setLineColor(Color.LIGHT_GRAY).setRangeMinValueExpression(1)
                                    .setRangeMaxValueExpression(15)));
}

From source file:net.sf.dynamicreports.test.jasper.chart.XyBarChartTest.java

@Override
protected void configureReport(JasperReportBuilder rb) {
    TextColumnBuilder<Integer> column1;
    TextColumnBuilder<Integer> column2;

    Locale.setDefault(Locale.ENGLISH);

    rb.columns(column1 = col.column("Column1", "field1", Integer.class),
            column2 = col.column("Column2", "field2", Integer.class))
            .summary(cht.xyBarChart().setXValue(column1).series(cht.xySerie(column2)).setShowLabels(true)
    /*.setShowTickLabels(false)
    .setShowTickMarks(false)*/, cht.xyBarChart().setXValue(column1).series(cht.xySerie(column2))
            .setXAxisFormat(cht.axisFormat().setLabel("category").setLabelColor(Color.BLUE)
                    .setLabelFont(stl.fontArialBold()).setTickLabelFont(stl.fontArial().setItalic(true))
                    .setTickLabelColor(Color.CYAN).setLineColor(Color.LIGHT_GRAY)),
                    cht.xyBarChart().setXValue(column1).series(cht.xySerie(column2))
                            .setYAxisFormat(cht.axisFormat().setLabel("value").setLabelColor(Color.BLUE)
                                    .setLabelFont(stl.fontArialBold())
                                    .setTickLabelFont(stl.fontArial().setItalic(true))
                                    .setTickLabelColor(Color.CYAN).setTickLabelMask("#,##0.00")
                                    .setLineColor(Color.LIGHT_GRAY).setRangeMinValueExpression(1)
                                    .setRangeMaxValueExpression(15)));
}

From source file:net.sf.dynamicreports.test.jasper.chart.XyStepChartTest.java

@Override
protected void configureReport(JasperReportBuilder rb) {
    TextColumnBuilder<Integer> column1;
    TextColumnBuilder<Integer> column2;

    Locale.setDefault(Locale.ENGLISH);

    rb.columns(column1 = col.column("Column1", "field1", Integer.class),
            column2 = col.column("Column2", "field2", Integer.class))
            .summary(cht.xyStepChart().setXValue(column1).series(cht.xySerie(column2)).setStepPoint(0.5d), cht
                    .xyStepChart().setXValue(column1).series(cht.xySerie(column2))
                    .setXAxisFormat(cht.axisFormat().setLabel("category").setLabelColor(Color.BLUE)
                            .setLabelFont(stl.fontArialBold()).setTickLabelFont(stl.fontArial().setItalic(true))
                            .setTickLabelColor(Color.CYAN).setLineColor(Color.LIGHT_GRAY)),
                    cht.xyStepChart().setXValue(column1).series(cht.xySerie(column2))
                            .setYAxisFormat(cht.axisFormat().setLabel("value").setLabelColor(Color.BLUE)
                                    .setLabelFont(stl.fontArialBold())
                                    .setTickLabelFont(stl.fontArial().setItalic(true))
                                    .setTickLabelColor(Color.CYAN).setTickLabelMask("#,##0.00")
                                    .setLineColor(Color.LIGHT_GRAY).setRangeMinValueExpression(1)
                                    .setRangeMaxValueExpression(15)));
}