Example usage for java.util Locale toString

List of usage examples for java.util Locale toString

Introduction

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

Prototype

@Override
public final String toString() 

Source Link

Document

Returns a string representation of this Locale object, consisting of language, country, variant, script, and extensions as below:
language + "_" + country + "_" + (variant + "_#" | "#") + script + "_" + extensions
Language is always lower case, country is always upper case, script is always title case, and extensions are always lower case.

Usage

From source file:com.vmware.identity.MetadataController.java

/**
 * Handle request sent with a wrong binding
 *//*from  w  w  w .j a  v  a  2s.c  o m*/
@RequestMapping(value = "/SAML2/Metadata/{tenant:.*}")
public void metadataError(Locale locale, @PathVariable(value = "tenant") String tenant,
        HttpServletResponse response) throws IOException {
    logger.info("Metadata binding error! The client locale is {}, tenant is {}", locale.toString(), tenant);

    metadataDefaultTenantBindingError(locale, response);
}

From source file:com.vmware.identity.WebssoMetadataController.java

/**
 * Handle request sent with a wrong binding
 *//*from  w  ww.  j a v  a 2  s  . co  m*/
@RequestMapping(value = "/websso/SAML2/Metadata/{tenant:.*}")
public void metadataError(Locale locale, @PathVariable(value = "tenant") String tenant,
        HttpServletResponse response) throws IOException {
    logger.info("Metadata binding error! The client locale is {}, tenant is {}", locale.toString(), tenant);

    metadataDefaultTenantBindingError(locale, response);
}

From source file:org.hyperic.hq.ui.taglib.display.LocalizedColumnTag.java

/** i18n the title */
public String getTitle() {
    if (isLocalizedTitle) {
        Locale userLocale = RequestUtils.getUserLocale((HttpServletRequest) pageContext.getRequest(), null);
        try {/*from  w w  w  .ja v a  2  s  . c  o  m*/
            return TagUtils.getInstance().message(pageContext, null, userLocale.toString(), super.getTitle());
        } catch (JspException e) {
            log.debug(e);
            // Do not localize then
        }
    }
    return super.getTitle();
}

From source file:org.overlord.dtgov.client.DtgovApiClient.java

/**
 * Creates the client executor that will be used by RESTEasy when
 * making the request.//  ww  w.  j  a  v a2s  . com
 */
private ClientExecutor createClientExecutor() {
    // TODO I think the http client is thread safe - so let's try to create just one of these
    DefaultHttpClient httpClient = new DefaultHttpClient();
    httpClient.addRequestInterceptor(new HttpRequestInterceptor() {
        @Override
        public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
            Locale l = getLocale();
            if (l == null) {
                l = Locale.getDefault();
            }
            request.addHeader("Accept-Language", l.toString()); //$NON-NLS-1$
        }
    });
    if (this.authProvider != null) {
        httpClient.addRequestInterceptor(new HttpRequestInterceptor() {
            @Override
            public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
                authProvider.provideAuthentication(request);
            }
        });
    }
    return new ApacheHttpClient4Executor(httpClient);
}

From source file:org.jboss.dashboard.i18n.XmlToBundleConverter.java

public void write(Map<Locale, Properties> bundles) throws Exception {
    if (bundleDir == null || !bundleDir.isDirectory()) {
        throw new IllegalArgumentException("It's not a directory: " + bundleDir);
    }/* w w  w. j  a va  2 s .  c  om*/
    for (Locale locale : bundles.keySet()) {
        Properties bundle = bundles.get(locale);
        File outputFile = new File(bundleDir, bundleName + "_" + locale.toString() + ".properties");
        bundle.store(new FileWriter(outputFile), null);
    }
}

From source file:com.wisemapping.webmvc.MindmapController.java

@RequestMapping(value = "maps/{id}/embed")
public ModelAndView showEmbeddedPage(@PathVariable int id, @RequestParam(required = false) Float zoom)
        throws MapCouldNotFoundException {
    ModelAndView view;//from   w w  w  .  j ava  2  s  . c  om
    final MindMapBean mindmap = findMindmapBean(id);
    view = new ModelAndView("mindmapEmbedded", "mindmap", mindmap);
    view.addObject("zoom", zoom == null ? 1 : zoom);
    final Locale locale = LocaleContextHolder.getLocale();
    view.addObject("locale", locale.toString().toLowerCase());
    return view;
}

From source file:com.wisemapping.webmvc.MindmapController.java

@RequestMapping(value = "maps/{id}/print")
public String showPrintPage(@PathVariable int id, @NotNull Model model) throws MapCouldNotFoundException {
    final MindMapBean mindmap = findMindmapBean(id);
    model.addAttribute("principal", Utils.getUser());
    model.addAttribute("mindmap", mindmap);
    final Locale locale = LocaleContextHolder.getLocale();
    model.addAttribute("locale", locale.toString().toLowerCase());
    return "mindmapPrint";
}

From source file:com.liferay.portlet.journal.model.impl.JournalArticleImpl.java

public String[] getAvailableLocales() {
    Set<String> availableLocales = new TreeSet<String>();

    // Title/* ww  w. j av  a  2 s  .  c  om*/

    Map<Locale, String> titleMap = getTitleMap();

    for (Map.Entry<Locale, String> entry : titleMap.entrySet()) {
        Locale locale = entry.getKey();
        String value = entry.getValue();

        if (Validator.isNotNull(value)) {
            availableLocales.add(locale.toString());
        }
    }

    // Description

    Map<Locale, String> descriptionMap = getDescriptionMap();

    for (Map.Entry<Locale, String> entry : descriptionMap.entrySet()) {
        Locale locale = entry.getKey();
        String value = entry.getValue();

        if (Validator.isNotNull(value)) {
            availableLocales.add(locale.toString());
        }
    }

    // Content

    String[] availableLocalesArray = LocalizationUtil.getAvailableLocales(getContent());

    for (String availableLocale : availableLocalesArray) {
        availableLocales.add(availableLocale);
    }

    return availableLocales.toArray(new String[availableLocales.size()]);
}

From source file:org.jboss.dashboard.kpi.KPIImpl.java

public String getDescription(Locale l) {
    String result = descriptions.get(l.toString());
    if (result == null)
        result = (String) LocaleManager.lookup().localize(descriptions);
    return result;
}

From source file:com.vmware.identity.MetadataController.java

/**
 * Handle GET request for the metadata/* ww w  .j ava  2 s .co m*/
 */
@RequestMapping(value = "/SAML2/Metadata/{tenant:.*}", method = RequestMethod.GET)
public void metadata(Locale locale, @PathVariable(value = "tenant") String tenant, Model model,
        HttpServletResponse response) throws IOException {
    logger.info("Welcome to Metadata handler! " + "The client locale is " + locale.toString() + ", tenant is "
            + tenant);

    //TODO - check for correlation id in the headers PR1561606
    String correlationId = UUID.randomUUID().toString();
    DefaultIdmAccessorFactory factory = new DefaultIdmAccessorFactory(correlationId);
    try {
        IdmAccessor accessor = factory.getIdmAccessor();
        accessor.setTenant(tenant);
        String metadata = accessor.exportConfigurationAsString();
        Validate.notNull(metadata);
        response.setHeader("Content-Disposition", "attachment; filename=" + SAML_METADATA_FILENAME);
        Shared.sendResponse(response, Shared.METADATA_CONTENT_TYPE, metadata);
    } catch (Exception e) {
        logger.error("Caught exception", e);
        ValidationResult vr = new ValidationResult(HttpServletResponse.SC_BAD_REQUEST, "BadRequest", null);
        String message = vr.getMessage(messageSource, locale);
        response.sendError(vr.getResponseCode(), message);
        logger.info("Responded with ERROR " + vr.getResponseCode() + ", message " + message);
    }

    model.addAttribute("tenant", tenant);
}