Examples of LocaleProvider


Examples of com.opensymphony.xwork2.LocaleProvider

    private TextProvider getTextProvider(Object action) {
        TextProviderFactory tpf = new TextProviderFactory();
        if (container != null) {
            container.inject(tpf);
        }
        LocaleProvider localeProvider = getLocaleProvider(action);
        return tpf.createInstance(action.getClass(), localeProvider);
    }
View Full Code Here

Examples of com.opensymphony.xwork2.LocaleProvider

        LocaleProvider localeProvider = getLocaleProvider(action);
        return tpf.createInstance(action.getClass(), localeProvider);
    }

    private LocaleProvider getLocaleProvider(Object action) {
        LocaleProvider localeProvider;
        if (action instanceof LocaleProvider) {
            localeProvider = (LocaleProvider) action;
        } else {
            localeProvider = container.getInstance(LocaleProvider.class);
        }
View Full Code Here

Examples of com.opensymphony.xwork2.LocaleProvider

        }

        String content_type = request.getContentType();
        if (content_type != null && content_type.contains("multipart/form-data")) {
            MultiPartRequest mpr = getMultiPartRequest();
            LocaleProvider provider = getContainer().getInstance(LocaleProvider.class);
            request = new MultiPartRequestWrapper(mpr, request, getSaveDir(servletContext), provider);
        } else {
            request = new StrutsRequestWrapper(request, disableRequestAttributeValueStackLookup);
        }
View Full Code Here

Examples of org.apache.clerezza.triaxrs.headerDelegate.LocaleProvider

    assertEquals(mylocale2, null);
  }

  @Test
  public void testLocaleProviderFromString() {
    LocaleProvider lp = new LocaleProvider();
    boolean illegaleArugmentOccured = false;

    assertEquals("en_UK", lp.fromString("en-uk;q = .7").toString());
    assertEquals("us__slang", lp.fromString("us-slang").toString());
    assertEquals("en_UK_cockney", lp.fromString("en-uk-cockney").toString());

    // only 2 letter language tags are allowed
    try {
      lp.fromString("abc-oaeu");
    } catch (IllegalArgumentException e) {
      illegaleArugmentOccured = true;
    }
    assertTrue(illegaleArugmentOccured);

    illegaleArugmentOccured = false;
    // the first sub-tag must not be longer than 8 chars
    try {
      lp.fromString("ab-abcdefghij");
    } catch (IllegalArgumentException e) {
      illegaleArugmentOccured = true;
    }
    assertTrue(illegaleArugmentOccured);

    illegaleArugmentOccured = false;
    // the first sub-tag must not be shorter than 2 chars
    try {
      lp.fromString("ab-a");
    } catch (IllegalArgumentException e) {
      illegaleArugmentOccured = true;
    }
    assertTrue(illegaleArugmentOccured);
  }
View Full Code Here

Examples of org.apache.clerezza.triaxrs.headerDelegate.LocaleProvider

    assertTrue(illegaleArugmentOccured);
  }

  @Test
  public void testLocaleProviderToString() {
    LocaleProvider lp = new LocaleProvider();
    Locale locale1 = new Locale("en", "uk", "cockney");
    Locale locale2 = new Locale("en", "", "cockney");

    // toLowerCase() because RFC 1766 says:
    // All tags are to be treated as case insensitive
    assertEquals("en-uk-cockney", lp.toString(locale1).toLowerCase());
    assertEquals("en-cockney", lp.toString(locale2).toLowerCase());
  }
View Full Code Here

Examples of org.apache.clerezza.triaxrs.headerDelegate.LocaleProvider

  @Override
  public List<Locale> getAcceptableLanguages() {
    List<Locale> locales = new ArrayList<Locale>();
    List<String> languages = request.getHeaders().get(HttpHeaders.ACCEPT_LANGUAGE);
    LocaleProvider lp = new LocaleProvider();
   
    if(languages == null) {
      return null;
    }
   
    for (String language : languages) {
      try{
        locales.add(lp.fromString(language));
      } catch (IllegalArgumentException ex) {
        //log and continue
        logger.error("Exception {}", ex);
      }
    }
View Full Code Here

Examples of org.apache.clerezza.triaxrs.headerDelegate.LocaleProvider

    if (clang == null) {
      return null;
    }
   
    try{
      locale = new LocaleProvider().fromString(clang.get(0));
    } catch (IllegalArgumentException ex) {
      logger.error("Exception {}", ex);
      return null;
    }
   
View Full Code Here

Examples of org.apache.clerezza.triaxrs.headerDelegate.LocaleProvider

        new ConversionUtil.Convertor<Locale>() {

      @Override
      public Locale convert(String string) {
        try{
          return new LocaleProvider().fromString(string);
        } catch (IllegalArgumentException ex) {
          logger.error("Exception {}", ex);
          return null;
        }
      }
View Full Code Here

Examples of org.glassfish.jersey.message.internal.LocaleProvider

* @author Mark Hadley
*/
public class LocaleProviderTest {
    @Test
    public void testToString() {
        final LocaleProvider instance = new LocaleProvider();
        assertEquals("en", instance.toString(new Locale("en")));
        assertEquals("en-US", instance.toString(new Locale("en", "us")));
    }
View Full Code Here

Examples of org.glassfish.jersey.message.internal.LocaleProvider

        assertEquals("en-US", instance.toString(new Locale("en", "us")));
    }

    @Test
    public void testFromString() throws Exception {
        final LocaleProvider instance = new LocaleProvider();
        assertEquals(new Locale("en"), instance.fromString("en"));
        assertEquals(new Locale("en", "us"), instance.fromString("en-us"));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.