Package java.util

Examples of java.util.Comparator


      pkgs.addAll(ctPkgs);
    }

    log("  Provided imported packages: "+pkgs, Project.MSG_VERBOSE);

    final Comparator cmp = new ProvidesEntrySetComparator();
    Collections.sort(depsApi, cmp);
    Collections.sort(depsNonApi, cmp);

    selectProviders(res, pkgs, depsApi);
    selectProviders(res, pkgs, depsNonApi);
View Full Code Here


   * <p>
   * @param sortingCriteria
   * @return a Comparator for the input sortingCriteria
   */
  protected Comparator getComparator(final SortingCriteria sortingCriteria) {
    return new Comparator(){     
      public int compare(final Object o1, final Object o2) {
        BookmarkImpl bookmark1 = (BookmarkImpl)o1;
        BookmarkImpl bookmark2 = (BookmarkImpl)o2;   
        int comparisonResult = 0;
        if(sortingCriteria.getSortingTerm()==SortingCriteria.ALPHABETICAL_SORTING) {         
View Full Code Here

                }
              }
              int count = obr.getBundleRecordCount();

              // String (category) -> Set (BundleRecord)
              Map categories = new TreeMap(new Comparator() {
                  public int compare(Object o1, Object o2) {
                    return o1.toString().compareToIgnoreCase(o2.toString());
                  }
                });
View Full Code Here

            ClassLoaderResolver clr = ec.getClassLoaderResolver();
            this.backingStore = (SetStore)
            ((BackedSCOStoreManager)ec.getStoreManager()).getBackingStoreForField(clr,fmd,java.util.TreeSet.class);
        }
        // Set up our delegate, using a suitable comparator
        Comparator comparator = SCOUtils.getComparator(fmd, ownerSM.getExecutionContext().getClassLoaderResolver());
        if (comparator != null)
        {
            this.delegate = new java.util.TreeSet(comparator);
        }
        else
View Full Code Here

            this.backingStore = (MapStore)
            ((BackedSCOStoreManager)ec.getStoreManager()).getBackingStoreForField(clr, fmd, java.util.TreeMap.class);
        }

        // Set up our delegate, using a comparator
        Comparator comparator = SCOUtils.getComparator(fmd, ownerSM.getExecutionContext().getClassLoaderResolver());
        if (comparator != null)
        {
            this.delegate = new java.util.TreeMap(comparator);
        }
        else
View Full Code Here

            this.backingStore = (ListStore)
            ((BackedSCOStoreManager)ec.getStoreManager()).getBackingStoreForField(clr,fmd,java.util.PriorityQueue.class);
        }

        // Set up our delegate, using suitable comparator (DN extension to JDO)
        Comparator comparator = null;
        String comparatorName = null;
        if (fmd.getCollection().hasExtension("comparatorName"))
        {
            comparatorName = fmd.getCollection().getValueForExtension("comparatorName");
            Class comparatorCls = null;
View Full Code Here

     * Convenience method to set up the delegate respecting any comparator specified in MetaData.
     */
    protected void initialiseDelegate()
    {
        AbstractMemberMetaData fmd = ownerSM.getClassMetaData().getMetaDataForMember(fieldName);
        Comparator comparator = SCOUtils.getComparator(fmd, ownerSM.getExecutionContext().getClassLoaderResolver());
        if (comparator != null)
        {
            this.delegate = new java.util.TreeMap(comparator);
        }
        else
View Full Code Here

    private List sortByGrouping(List set)
    {
        Object[] o = set.toArray();
        final Expression[] grouping = compilation.getExprGrouping();
        Arrays.sort(o, new Comparator()
        {
            public int compare(Object arg0, Object arg1)
            {
                for (int i=0; i<grouping.length; i++)
                {
View Full Code Here

        // Save the result set
        state.put(RESULTS_SET, set);

        Object[] o = set.toArray();
        Arrays.sort(o, new Comparator()
        {
            public int compare(Object arg0, Object arg1)
            {
                for (int i=0; i<ordering.length; i++)
                {
View Full Code Here

     * @return A list with aggregated elements
     */
    private List handleAggregates(List resultSet)
    {
        final Expression[] grouping = compilation.getExprGrouping();
        Comparator c = new Comparator()
        {
            public int compare(Object arg0, Object arg1)
            {
                for (int i=0; i<grouping.length; i++)
                {
                    state.put(candidateAlias, arg0);
                    Object a = grouping[i].evaluate(evaluator);
                    state.put(candidateAlias, arg1);
                    Object b = grouping[i].evaluate(evaluator);
                    int result = ((Comparable)a).compareTo(b);
                    if (result != 0)
                    {
                        return result;
                    }
                }
                return 0;
            }
        };
   
        List groups = new ArrayList();
        List group = new ArrayList();
        groups.add(group);
        for (int i=0; i<resultSet.size(); i++)
        {
            if (i > 0)
            {
                if (c.compare(resultSet.get(i-1),resultSet.get(i)) != 0)
                {
                    group = new ArrayList();
                    groups.add(group);
                }
            }
View Full Code Here

TOP

Related Classes of java.util.Comparator

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.