Package com.ibm.icu.util

Examples of com.ibm.icu.util.ULocale


  /*
   * Create a locale from localeID.
   * Then return the appropriate collator for the locale.
   */
  private Collator createFromLocale(String localeID) {
    return Collator.getInstance(new ULocale(localeID));
  }
View Full Code Here


   *
   * The default is DIN 5007-1, this shows how to tailor a collator to get DIN 5007-2 behavior.
   *  http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4423383
   */
  public void testCustomRules() throws Exception {
    RuleBasedCollator baseCollator = (RuleBasedCollator) Collator.getInstance(new ULocale("de_DE"));

    String DIN5007_2_tailorings =
      "& ae , a\u0308 & AE , A\u0308"+
      "& oe , o\u0308 & OE , O\u0308"+
      "& ue , u\u0308 & UE , u\u0308";
View Full Code Here

      if (msgParts.size() > 0) {
        SoyMsgPart firstPart = msgParts.get(0);

        if (firstPart instanceof SoyMsgPluralPart) {
          new PlrselMsgPartsVisitor(node, new ULocale(soyMsg.getLocaleString()))
              .visitPart((SoyMsgPluralPart) firstPart);

        } else if (firstPart instanceof SoyMsgSelectPart) {
          new PlrselMsgPartsVisitor(node, new ULocale(soyMsg.getLocaleString()))
              .visitPart((SoyMsgSelectPart) firstPart);

        } else {
          for (SoyMsgPart msgPart : msgParts) {
View Full Code Here

   
    ArrayList<ULocale> ulocales = new ArrayList<ULocale>();
    for (String locale:locales){
      if (locale != null){
        try {
          ULocale ulocale = ULocale.forLanguageTag(locale);
          if (!ulocale.getLanguage().equals(""))
            ulocales.add(ulocale);
        } catch (Exception e) {
          // There can be intermittent problems with the internal
          // functioning of the ULocale class with some
          // language tags; best to just log these and continue
View Full Code Here

   * @return true if a valid language tag, otherwise false
   */
  public static boolean isValidLanguageTag(String tag){
    try {
      if (tag.equals("x-w3c-test")) return true; // hack for testing :(
      ULocale locale = ULocale.forLanguageTag(tag);
      if (locale.toLanguageTag() == null) return false;
      // We don't accept "x" extensions (private use tags)
      if(locale.getExtension("x".charAt(0))!=null) return false;
      if (!locale.toLanguageTag().equalsIgnoreCase(tag)) return false;
      return true;
    } catch (Exception e) {
      return false;
    }
  }
View Full Code Here

   * @throws InvalidQueryException Thrown if the column is invalid.
   */
  @Override
  public void validateColumn(DataTable dataTable) throws InvalidQueryException {
    ValueType valueType = dataTable.getColumnDescription(aggregatedColumn.getId()).getType();
    ULocale userLocale = dataTable.getLocaleForUserMessages();
    switch (aggregationType) {
      case COUNT: case MAX: case MIN: break;
      case AVG: case SUM:
      if (valueType != ValueType.NUMBER) {
        throw new InvalidQueryException(MessagesEnum.AVG_SUM_ONLY_NUMERIC.getMessage(userLocale));
View Full Code Here

      EasyMock.verify(req);
    } catch (DataSourceException e) {
      caught = true;
    }
    assertFalse(caught);
    assertEquals(new ULocale("fr"), dataSourceRequest.getUserLocale());
    assertTrue(dataSourceRequest.isSameOrigin());
    assertEquals(OutputType.CSV, dataSourceRequest.getDataSourceParameters().getOutputType());

    // Test with hl == it, not same-domain.
    dataSourceRequest = null;
    caught = false;
    try {
      HttpServletRequest req = EasyMock.createMock(HttpServletRequest.class);
      EasyMock.expect(req.getParameter("hl")).andReturn("it");
      EasyMock.expect(req.getHeader("X-DataSource-Auth")).andReturn(null);
      EasyMock.expect(req.getParameter("tqx")).andReturn(null);
      EasyMock.expect(req.getParameter("tq")).andReturn(null);
      EasyMock.replay(req);
      dataSourceRequest = new DataSourceRequest(req);
      EasyMock.verify(req);
    } catch (DataSourceException e) {
      caught = true;
    }
    assertFalse(caught);
    assertEquals(new ULocale("it"), dataSourceRequest.getUserLocale());
    assertFalse(dataSourceRequest.isSameOrigin());
    assertEquals(OutputType.JSONP, dataSourceRequest.getDataSourceParameters().getOutputType());
  }
View Full Code Here

    EasyMock.expect(req.getParameter("tqx")).andReturn("out:csv;");
    EasyMock.expect(req.getParameter("tq")).andReturn(null);
    EasyMock.replay(req);
    dataSourceRequest = DataSourceRequest.getDefaultDataSourceRequest(req);
    EasyMock.verify(req);
    assertEquals(new ULocale("fr"), dataSourceRequest.getUserLocale());
    assertTrue(dataSourceRequest.isSameOrigin());
    assertEquals(OutputType.CSV, dataSourceRequest.getDataSourceParameters().getOutputType());

    // Test with empty request (only locale).
    dataSourceRequest = null;
    req = EasyMock.createMock(HttpServletRequest.class);
    EasyMock.expect(req.getParameter("hl")).andReturn(null);
    EasyMock.expect(req.getLocale()).andReturn(new Locale("qq"));
    EasyMock.expect(req.getHeader("X-DataSource-Auth")).andReturn(null);
    EasyMock.expect(req.getParameter("tqx")).andReturn(null);
    EasyMock.expect(req.getParameter("tq")).andReturn(null);
    EasyMock.replay(req);
    dataSourceRequest = DataSourceRequest.getDefaultDataSourceRequest(req);
    EasyMock.verify(req);
    assertEquals(new ULocale("qq"), dataSourceRequest.getUserLocale());
    assertFalse(dataSourceRequest.isSameOrigin());
    assertEquals(OutputType.JSONP, dataSourceRequest.getDataSourceParameters().getOutputType());

    // Test with hl == it, not same-domain.
    dataSourceRequest = null;
    req = EasyMock.createMock(HttpServletRequest.class);
    EasyMock.expect(req.getParameter("hl")).andReturn("it");
    EasyMock.expect(req.getHeader("X-DataSource-Auth")).andReturn(null);
    EasyMock.expect(req.getParameter("tqx")).andReturn(null);
    EasyMock.expect(req.getParameter("tq")).andReturn(null);
    EasyMock.replay(req);
    dataSourceRequest = DataSourceRequest.getDefaultDataSourceRequest(req);
    EasyMock.verify(req);
    assertEquals(new ULocale("it"), dataSourceRequest.getUserLocale());
    assertFalse(dataSourceRequest.isSameOrigin());
    assertEquals(OutputType.JSONP, dataSourceRequest.getDataSourceParameters().getOutputType());
  }
View Full Code Here

    assertNotNull(ValueFormatter.createDefault(ValueType.DATE, null));
    assertNotNull(ValueFormatter.createDefault(ValueType.DATETIME, null));
    assertNotNull(ValueFormatter.createDefault(ValueType.TIMEOFDAY, null));
    assertNotNull(ValueFormatter.createDefault(ValueType.TEXT, null));

    ULocale ulocale = ULocale.ENGLISH;
    ULocale ulocale1 = ULocale.CANADA_FRENCH;

    assertEquals(ulocale,
        ValueFormatter.createFromPattern(ValueType.NUMBER, "", ulocale).getLocale());
    assertEquals(ulocale1,
        ValueFormatter.createDefault(ValueType.NUMBER, ulocale1).getLocale());
View Full Code Here

    assertEquals(ulocale1,
        ValueFormatter.createDefault(ValueType.NUMBER, ulocale1).getLocale());
  }

  public void testAFewMoreCases() {
    ULocale ulocale = ULocale.ENGLISH;

    // Create a ValueFormatter for each type
    ValueFormatter booleanFormatter = ValueFormatter.createFromPattern(
        ValueType.BOOLEAN, null, ulocale);
    assertNotNull(booleanFormatter);
View Full Code Here

TOP

Related Classes of com.ibm.icu.util.ULocale

Copyright © 2018 www.massapicom. 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.