Examples of Collator


Examples of java.text.Collator

            }
            return max;
        } else if(TypeUtil.subtypeOf(firstType, StringType.STRING)) {
            AtomicValue max = (AtomicValue) firstItem;
            final int arglen = argv.size();
            final Collator collator;
            if(arglen == 2) {
                Item sec = argv.getItem(1);
                Type secType = sec.getType();
                if(!TypeUtil.subtypeOf(secType, StringType.STRING)) {
                    throw new DynamicError("err:FORG0006", "second argument is expected to be xs:string, but was "
                            + secType);
                }
                String uri = sec.stringValue();
                collator = CollationUtils.resolve(uri, dynEnv.getStaticContext());
            } else {
                collator = Collator.getInstance(); // compare in default locale
            }
            while(argItor.hasNext()) {
                Item it = argItor.next();
                Type cmpType = it.getType();
                if(!TypeUtil.subtypeOf(cmpType, StringType.STRING)) {
                    throw new DynamicError("err:FORG0006", "imcomparable xs:string and " + cmpType);
                }
                if(collator.compare(it, firstItem) > 0) {
                    max = (AtomicValue) it;
                }
            }
            return max;
        } else {
View Full Code Here

Examples of java.text.Collator

        final int arglen = argv.size();
        assert (arglen == 2 || arglen == 3);
        if(arglen == 3) {
            Item thirdItem = argv.getItem(2);
            String collation = thirdItem.stringValue();
            Collator collator = CollationUtils.resolve(collation, dynEnv.getStaticContext());
            cmp = collator.compare(comparand1, comparand2);
        } else {
            cmp = comparand1.compareTo(comparand2);
        }
        return cmp == 0 ? XInteger.valueOf(0) : (cmp > 0 ? XInteger.valueOf(1)
                : XInteger.valueOf(-1));
View Full Code Here

Examples of java.text.Collator

                }
            }
                       
            if(sortAlpha) {
                final TreeMap<CollationKey, YMarkTag> sort = new TreeMap<CollationKey, YMarkTag>();
          final Collator collator = Collator.getInstance();
          collator.setStrength(Collator.SECONDARY);
                tit = tags.iterator();
              while(tit.hasNext() && count < top) {
                t = tit.next();
                sort.put(collator.getCollationKey(t.name()), t);
                count++;
              }
              tit = sort.values().iterator();
            } else {
              tit = tags.iterator();
View Full Code Here

Examples of java.text.Collator

  }
 
  public void assertTreeIsSorted(JTree tree) {
    TreeModel model = tree.getModel();
    Object    root  = model.getRoot();
    Collator  comparator = Collator.getInstance();
    // For each category
    for (int i = 0, n = model.getChildCount(root); i < n; i++) {
      Object rootChild = model.getChild(root, i);
      if (i < n - 1) {
        Object nextChild = model.getChild(root, i + 1);
        // Check alphatical order of categories nodes in tree
        assertTrue("Categories not sorted", comparator.compare(
            getNodeText(tree, rootChild),
            getNodeText(tree, nextChild)) <= 0);
      }
      // For each piece of furniture of a category
      for (int j = 0, m = model.getChildCount(rootChild) - 1;
           j < m; j++) {
        Object child = model.getChild(rootChild, j);
        if (j < m - 1) {
          Object nextChild = model.getChild(rootChild, j + 1);
          // Check alphatical order of furniture nodes in tree
          assertTrue("Furniture not sorted", comparator.compare(
              getNodeText(tree, child),
              getNodeText(tree, nextChild)) <= 0);
        }
        assertTrue("Piece not a leaf", model.isLeaf(child));
      }
View Full Code Here

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

Examples of java.text.Collator

      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

Examples of java.text.Collator


    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

Examples of java.text.Collator

   
    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

Examples of java.text.Collator

    // 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

Examples of java.text.Collator

    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
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.