Example usage for java.util Locale ENGLISH

List of usage examples for java.util Locale ENGLISH

Introduction

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

Prototype

Locale ENGLISH

To view the source code for java.util Locale ENGLISH.

Click Source Link

Document

Useful constant for language.

Usage

From source file:net.sf.dynamicreports.test.jasper.chart.XyLineChartTest.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(// w w w  .jav  a2s. c o m
                    cht.xyLineChart().setXValue(column1).series(cht.xySerie(column2)).setShowShapes(false)
                            .setShowLines(false),
                    cht.xyLineChart().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.xyLineChart().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:org.smigo.user.UserSetLocaleResolver.java

@Override
public Locale resolveLocale(HttpServletRequest req) {
    final Principal userPrincipal = req.getUserPrincipal();
    if (userPrincipal != null) {
        User user = userDao.getUsersByUsername(userPrincipal.getName()).get(0);
        if (user.getLocale() != null) {
            return user.getLocale();
        }/*from w w  w  .  ja  v a 2 s  .co m*/
    }

    final String subDomain = req.getServerName().split("\\.")[0];
    for (Language language : Language.values()) {
        if (language.getLocale().getLanguage().equals(subDomain)) {
            return new Locale(subDomain);
        }
    }

    return req.getLocale() == null ? Locale.ENGLISH : req.getLocale();
}

From source file:org.vaadin.spring.samples.i18n.TranslatedUI.java

@Override
protected void initUI(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);// w w  w .j av  a 2s . c  o  m
    layout.setSpacing(true);
    setContent(layout);

    english = new Button("English", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            setLocale(Locale.ENGLISH);
        }
    });
    layout.addComponent(english);

    swedish = new Button("Svenska", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            setLocale(new Locale("sv"));
        }
    });
    layout.addComponent(swedish);

    bigDecimalTextField = new TextField();
    bigDecimalTextField.setConverter(new StringToBigDecimalConverter());
    bigDecimalTextField.setPropertyDataSource(bigDecimalObjectProperty);
    bigDecimalTextField.setImmediate(true);
    bigDecimalTextField.setNullSettingAllowed(false);
    layout.addComponent(bigDecimalTextField);

    dateField = new DateField();
    dateField.setValue(new Date());
    layout.addComponent(dateField);
}

From source file:ch.ralscha.extdirectspring.provider.PollProvider.java

@ExtDirectMethod(value = ExtDirectMethodType.POLL, event = "message2", group = "group2", entryClass = String.class)
public String handleMessage2(HttpServletResponse response, HttpServletRequest request, HttpSession session,
        Locale locale) {/*  w  w w  .  j a va 2  s .co m*/
    assertThat(response).isNotNull();
    assertThat(request).isNotNull();
    assertThat(session).isNotNull();
    assertThat(locale).isEqualTo(Locale.ENGLISH);

    Date now = new Date();
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd 'at' hh:mm:ss");
    return "Successfully polled at: " + formatter.format(now);
}

From source file:fi.helsinki.opintoni.service.CourseServiceTest.java

@Test
public void thatTeacherCourseDtosAreFetched() {
    expectTeacherCourses();//from w  w  w .  ja v  a2  s.  co m

    Set<CourseDto> courseDtos = courseService.getCourses(Optional.empty(),
            Optional.of(TestConstants.TEACHER_NUMBER), Locale.ENGLISH);

    assertThat(courseDtos).hasSize(2);
    assertThat(courseDtos, hasCourseWithRealisationId(TestConstants.TEACHER_COURSE_REALISATION_ID));
    assertThat(courseDtos, hasCourseWithRealisationId(TestConstants.EXAM_TEACHER_COURSE_REALISATION_ID));
}

From source file:ch.ralscha.extdirectspring_itest.UserServiceTest.java

@Test
public void testPostWithErrors() throws IOException {
    Locale.setDefault(Locale.ENGLISH);
    List<NameValuePair> formparams = new ArrayList<NameValuePair>();
    formparams.add(new BasicNameValuePair("extTID", "2"));
    formparams.add(new BasicNameValuePair("extAction", "userService"));
    formparams.add(new BasicNameValuePair("extMethod", "updateUser"));
    formparams.add(new BasicNameValuePair("extType", "rpc"));
    formparams.add(new BasicNameValuePair("extUpload", "false"));
    formparams.add(new BasicNameValuePair("name", "Joe"));
    formparams.add(new BasicNameValuePair("age", "30"));
    UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(formparams, "UTF-8");

    this.post.setEntity(postEntity);

    CloseableHttpResponse response = this.client.execute(this.post);
    try {//from w w  w. j  ava2 s  .com
        HttpEntity entity = response.getEntity();
        assertThat(entity).isNotNull();
        String responseString = EntityUtils.toString(entity);

        Map<String, Object> rootAsMap = this.mapper.readValue(responseString, Map.class);
        assertThat(rootAsMap).hasSize(5);
        assertThat(rootAsMap.get("method")).isEqualTo("updateUser");
        assertThat(rootAsMap.get("type")).isEqualTo("rpc");
        assertThat(rootAsMap.get("action")).isEqualTo("userService");
        assertThat(rootAsMap.get("tid")).isEqualTo(2);

        Map<String, Object> result = (Map<String, Object>) rootAsMap.get("result");
        assertThat(result).hasSize(4);
        assertThat(result.get("name")).isEqualTo("Joe");
        assertThat(result.get("age")).isEqualTo(30);
        assertThat(result.get("success")).isEqualTo(Boolean.FALSE);

        Map<String, Object> errors = (Map<String, Object>) result.get("errors");
        assertThat(errors).hasSize(1);
        assertThat((List<String>) errors.get("email")).containsOnly("may not be empty");
    } finally {
        IOUtils.closeQuietly(response);
    }
}

From source file:ru.apertum.qsystem.reports.net.NetUtil.java

public static synchronized String getUrl(HttpRequest request) {
    final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
    if (method.equals("GET")) {
        return request.getRequestLine().getUri().split("\\?")[0];
    } else {// www .j  a v a2 s  . c  om
        return request.getRequestLine().getUri();
    }
}

From source file:ch.ralscha.extdirectspring_itest.UserControllerTest.java

@Test
public void testPostWithErrors() throws IOException {
    Locale.setDefault(Locale.ENGLISH);
    List<NameValuePair> formparams = new ArrayList<NameValuePair>();
    formparams.add(new BasicNameValuePair("extTID", "2"));
    formparams.add(new BasicNameValuePair("extAction", "userController"));
    formparams.add(new BasicNameValuePair("extMethod", "updateUser"));
    formparams.add(new BasicNameValuePair("extType", "rpc"));
    formparams.add(new BasicNameValuePair("extUpload", "false"));
    formparams.add(new BasicNameValuePair("name", "Joe"));
    formparams.add(new BasicNameValuePair("age", "30"));
    UrlEncodedFormEntity postEntity = new UrlEncodedFormEntity(formparams, "UTF-8");

    this.post.setEntity(postEntity);

    CloseableHttpResponse response = this.client.execute(this.post);
    try {//  w  ww .java 2 s  .co  m
        HttpEntity entity = response.getEntity();
        assertThat(entity).isNotNull();
        String responseString = EntityUtils.toString(entity);

        Map<String, Object> rootAsMap = this.mapper.readValue(responseString, Map.class);
        assertThat(rootAsMap).hasSize(5);
        assertThat(rootAsMap.get("method")).isEqualTo("updateUser");
        assertThat(rootAsMap.get("type")).isEqualTo("rpc");
        assertThat(rootAsMap.get("action")).isEqualTo("userController");
        assertThat(rootAsMap.get("tid")).isEqualTo(2);

        Map<String, Object> result = (Map<String, Object>) rootAsMap.get("result");
        assertThat(result).hasSize(4);
        assertThat(result.get("name")).isEqualTo("Joe");
        assertThat(result.get("age")).isEqualTo(30);
        assertThat(result.get("success")).isEqualTo(Boolean.FALSE);

        Map<String, Object> errors = (Map<String, Object>) result.get("errors");
        assertThat(errors).hasSize(1);
        assertThat((List<String>) errors.get("email")).containsOnly("may not be empty");
    } finally {
        IOUtils.closeQuietly(response);
    }
}

From source file:com.limegroup.gnutella.gui.LanguageUtils.java

/**
 * Returns an array of supported language as a LanguageInfo[], always having
 * the English language as the first element.
 * //from w  w  w.java2 s . c om
 * This will only include languages that can be displayed using the given
 * font. If the font is null, all languages are returned.
 */
public static Locale[] getLocales(Font font) {
    final List<Locale> locales = new LinkedList<Locale>();

    File jar = FileUtils.getJarFromClasspath(LanguageUtils.class.getClassLoader(), BUNDLE_MARKER);
    if (jar != null) {
        addLocalesFromJar(locales, jar);
    } else {
        LOG.warn("Could not find bundle jar to determine locales");
    }

    Collections.sort(locales, new Comparator<Locale>() {
        public int compare(Locale o1, Locale o2) {
            return o1.getDisplayName(o1).compareToIgnoreCase(o2.getDisplayName(o2));
        }
    });

    locales.remove(Locale.ENGLISH);
    locales.add(0, Locale.ENGLISH);

    // remove languages that cannot be displayed using this font
    if (font != null && !OSUtils.isMacOSX()) {
        for (Iterator<Locale> it = locales.iterator(); it.hasNext();) {
            Locale locale = it.next();
            if (!GUIUtils.canDisplay(font, locale.getDisplayName(locale))) {
                it.remove();
            }
        }
    }

    return locales.toArray(new Locale[0]);
}

From source file:ru.apertum.qsystem.reports.net.HttpQSystemReportsHandler.java

@Override
public void handle(HttpRequest request, HttpResponse response, HttpContext context)
        throws HttpException, IOException {
    final String method = request.getRequestLine().getMethod().toUpperCase(Locale.ENGLISH);
    if (!method.equals("GET") && !method.equals("HEAD") && !method.equals("POST")) {
        throw new MethodNotSupportedException(method + " method not supported");
    }/*from  ww  w .  j a v  a  2s . c om*/
    // ?? ? 
    Response result = QReportsList.getInstance().generate(request);
    // ?   
    if (result == null) {

        String subject = NetUtil.getUrl(request);
        if ("/".equals(subject)) {
            subject = "/login.html";
        }
        int dot = subject.lastIndexOf(".");
        final String ext = subject.substring(dot + 1);
        String contentType = "; charset=UTF-8";
        if ("htm".equals(ext) || "html".equals(ext)) {
            contentType = "text/" + ext + contentType;
        } else {
            if ("pdf".equals(ext) || "rtf".equals(ext) || "doc".equals(ext) || "xlsx".equals(ext)) {
                contentType = "application/" + ext + contentType;
            } else {
                if ("gif".equals(ext) || "jpeg".equals(ext) || "jpg".equals(ext) || "ico".equals(ext)
                        || "xpm".equals(ext)) {
                    contentType = "image/" + ext + contentType;
                }
            }
        }

        //  ??  "/ru/apertum/qsystem/reports/web/"
        final InputStream inStream = getClass()
                .getResourceAsStream("/ru/apertum/qsystem/reports/web" + subject);
        if (inStream == null) {
            QLog.l().logRep()
                    .warn("??  : \"/ru/apertum/qsystem/reports/web" + subject + "\"");
            //   ??,   
            //   
            subject = subject.substring(1);
            File anyFile = new File(subject);
            if (anyFile.exists()) {
                QLog.l().logRep().info(" : \"" + subject + "\"");
                FileInputStream fInStream = null;
                try {
                    fInStream = new FileInputStream(anyFile);
                } catch (FileNotFoundException ex) {
                    final String err = "    \"" + subject + "\" ";
                    QLog.l().logRep().error("err " + ex);
                    result = new Response((err + ex).getBytes(), contentType);
                    response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
                }
                try {
                    result = new Response(Uses.readInputStream(fInStream), contentType);
                    response.setStatusCode(HttpStatus.SC_OK);
                } catch (IOException ex) {
                    final String err = "      \""
                            + subject + "\" ";
                    QLog.l().logRep().error("err " + ex);
                    result = new Response((err + ex).getBytes(), contentType);
                    response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
                }
            } else {
                //   
                anyFile = new File(
                        Uses.TEMP_FOLDER + File.separator + "temphtml.html_files" + File.separator + subject);
                if (anyFile.exists()) {
                    QLog.l().logRep().info("  : \"" + Uses.TEMP_FOLDER
                            + File.separator + "temphtml.html_files" + File.separator + subject + "\"");
                    FileInputStream fInStream = null;
                    try {
                        fInStream = new FileInputStream(anyFile);
                    } catch (FileNotFoundException ex) {
                        final String err = "    \"" + Uses.TEMP_FOLDER
                                + File.separator + "temphtml.html_files" + File.separator + subject + "\" ";
                        QLog.l().logRep().error("err " + ex);
                        result = new Response((err + ex).getBytes(), contentType);
                        response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
                    }
                    try {
                        result = new Response(Uses.readInputStream(fInStream), contentType);
                        response.setStatusCode(HttpStatus.SC_OK);
                    } catch (IOException ex) {
                        final String err = "      \""
                                + Uses.TEMP_FOLDER + File.separator + "temphtml.html_files" + File.separator
                                + subject + "\" ";
                        QLog.l().logRep().error("err " + ex);
                        result = new Response((err + ex).getBytes(), contentType);
                        response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
                    }
                    anyFile.delete();
                } else {
                    //   .   ?  ?? ( ???)
                    QLog.l().logRep()
                            .error("??     : \""
                                    + Uses.TEMP_FOLDER + File.separator + "temphtml.html_files" + File.separator
                                    + subject + "\"");
                    final String s = "<html><head><meta http-equiv = \"Content-Type\" content = \"text/html; charset=utf-8\" ></head><p align=center>??  .</p></html>";
                    result = new Response(s.getBytes());
                }
            }

        } else {
            QLog.l().logRep().info(" ??: \"" + subject + "\"");
            try {
                result = new Response(Uses.readInputStream(inStream));
                if ("/login.html".equals(subject)) {
                    result.setData(
                            RepResBundle.getInstance().prepareString(new String(result.getData(), "UTF-8"))
                                    .replaceFirst(Uses.ANCHOR_USERS_FOR_REPORT,
                                            QReportsList.getInstance().getHtmlUsersList())
                                    .replaceFirst(Uses.ANCHOR_PROJECT_NAME_FOR_REPORT,
                                            Uses.getLocaleMessage("project.name" + FAbout.getCMRC_SUFF()))
                                    .getBytes("UTF-8")); //"Cp1251"
                }
            } catch (IOException ex) {
                QLog.l().logRep().error(" ? ??. " + ex);
                result = new Response((" ? ??. " + ex).getBytes());
                response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
            }
            response.setStatusCode(HttpStatus.SC_OK);
        }
    }

    //  :
    QLog.l().logRep().trace("  " + result.getData().length
            + "   ? \"" + request.getRequestLine().getUri() + "\".");

    final byte[] result2 = result.getData();
    final EntityTemplate body = new EntityTemplate((final OutputStream outstream) -> {
        outstream.write(result2);
        outstream.flush();
    });

    body.setContentType(result.getContentType());
    response.setEntity(body);
    NetUtil.freeEntityContent(request);
}