Package java.text

Examples of java.text.Collator


   */
  public int compare(WikiPage a, WikiPage b) {
    // Be aware of locale when ordering
    I18nManager mgr = I18nManager.getInstance();
    Locale userLocale = mgr.getCurrentThreadLocale();
    Collator collator = Collator.getInstance(userLocale);
    collator.setStrength(Collator.PRIMARY);

    // Undefinied order if page a or b is null
    int order = 0;
    if (a != null && b != null) {
      final String nameA = a.getPageName();
      final String nameB = b.getPageName();
      // Compare page names with the localized comparator
      order = collator.compare(nameA, nameB);
    }
    return order;
  }
View Full Code Here


      detailView.contextPut("courseNodeCss", CourseNodeFactory.getInstance().getCourseNodeConfiguration(courseNode.getType()).getIconCSSClass());

      // push infos about users groups
      List<BusinessGroup> participantGroups = course.getCourseEnvironment().getCourseGroupManager().getParticipatingLearningGroupsFromAllContexts(
          assessedIdentity);
      final Collator collator = Collator.getInstance(ureq.getLocale());
      Collections.sort(participantGroups, new Comparator<BusinessGroup>() {
        public int compare(BusinessGroup a, BusinessGroup b) {
          return collator.compare(a.getName(), b.getName());
        }
      });
      detailView.contextPut("participantGroups", participantGroups);
      detailView.contextPut("noParticipantGroups", (participantGroups.size() > 0 ? Boolean.FALSE : Boolean.TRUE));
View Full Code Here


    private void sortTable(Table t) {

        TableItem[] items = t.getItems();
        Collator collator = Collator.getInstance(Locale.getDefault());

        int index = 0;
        for (int i = 1; i < items.length; i++) {
            String value1 = items[i].getText(index);
            for (int j = 0; j < i; j++) {
                String value2 = items[j].getText(index);
                if (collator.compare(value1, value2) < 0) {
                    String[] values = { items[i].getText(0), items[i].getText(1) };
                    items[i].dispose();
                    TableItem item = new TableItem(t, SWT.NONE, j);
                    item.setText(values);
                    items = t.getItems();
View Full Code Here

   
    int comparison = 0// Will be -1, 0 or 1 depending on whether sLo is <, = or > than sHi
   
    // Strings are handled separately because we have to compare them in given locale.
    if (valueLo instanceof String && valueHi instanceof String) {
      Collator collator = Collator.getInstance(); // TODO: Must be locale-specific
      comparison = collator.compare((String)valueLo, (String)valueHi);
    }
    else if (valueLo instanceof Comparable && valueHi instanceof Comparable){    
      if (loExtendsHi)
        comparison = ((Comparable)valueLo).compareTo(valueHi);
      else
View Full Code Here

    // Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
    // RuleBasedCollator. However, the Arabic Locale seems to order the
    // Farsi
    // characters properly.
    Collator c = Collator.getInstance(new Locale("ar"));
    qp.setRangeCollator(c);

    // Unicode order would include U+0633 in [ U+062F - U+0698 ], but Farsi
    // orders the U+0698 character before the U+0633 character, so the
    // single
View Full Code Here

    if (node instanceof ParametricRangeQueryNode) {
      ParametricRangeQueryNode parametricRangeNode = (ParametricRangeQueryNode) node;
      ParametricQueryNode upper = parametricRangeNode.getUpperBound();
      ParametricQueryNode lower = parametricRangeNode.getLowerBound();
      Locale locale = Locale.getDefault();
      Collator collator = null;
      DateTools.Resolution dateRes = null;
      boolean inclusive = false;

      if (getQueryConfigHandler().hasAttribute(RangeCollatorAttribute.class)) {
View Full Code Here

        new WhitespaceAnalyzer());

    // Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
    // RuleBasedCollator. However, the Arabic Locale seems to order the Farsi
    // characters properly.
    Collator c = Collator.getInstance(new Locale("ar"));
    qp.setRangeCollator(c);

    // Unicode order would include U+0633 in [ U+062F - U+0698 ], but Farsi
    // orders the U+0698 character before the U+0633 character, so the single
    // index Term below should NOT be returned by a ConstantScoreRangeQuery
View Full Code Here

        }

    }
    public int compare( String content, String facetValue ){
        Locale    loc       = Locale.getDefault();
        Collator  collator  = Collator.getInstance( loc );
        return collator.compare( content, facetValue );
    }
View Full Code Here

        return null;
    }

    public int compare( String content, String facetValue ){
        Locale    loc       = Locale.getDefault();
        Collator  collator  = Collator.getInstance( loc );
        return collator.compare( content, facetValue );
    }
View Full Code Here

    QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "content", new WhitespaceAnalyzer());

    // Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
    // RuleBasedCollator.  However, the Arabic Locale seems to order the Farsi
    // characters properly.
    Collator c = Collator.getInstance(new Locale("ar"));
    qp.setRangeCollator(c);

    // Unicode order would include U+0633 in [ U+062F - U+0698 ], but Farsi
    // orders the U+0698 character before the U+0633 character, so the single
    // index Term below should NOT be returned by a ConstantScoreRangeQuery
View Full Code Here

TOP

Related Classes of java.text.Collator

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.