Package java.util

Examples of java.util.Comparator


            Panel p = (Panel) i.next();
            if ((placement == -1 || p.getPlacement() == placement) && p.isAvailable(request, response, "main")) {
                a.add(p);
            }
        }
        Collections.sort(a, new Comparator() {
            public int compare(Object arg0, Object arg1) {
                Panel p1 = (Panel) arg0;
                Panel p2 = (Panel) arg1;
                return new Integer(p1.getWeight()).compareTo(new Integer(p2.getWeight()));
            }
View Full Code Here


                {
                    //some datastores do not support backingStores
                }
            }
            // Set up our delegate, using a suitable comparator
            Comparator comparator = SCOUtils.getComparator(fmd, ownerSM.getObjectManager().getClassLoaderResolver());
            if (comparator != null)
            {
                this.delegate = new java.util.TreeSet(comparator);
            }
            else
View Full Code Here

    }

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

        {
            symtbl.addSymbol(symbol);
        }
        symbol.setValue(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

     * @param resultSet The resultSet containing al elements
     * @return A list with aggregated elements
     */
    private List handleAggregates(List resultSet)
    {
        Comparator c = new Comparator()
        {
            public int compare(Object arg0, Object arg1)
            {
                for( int i=0; i<grouping.length; i++)
                {
                    symtbl.getSymbol("this").setValue(arg0);
                    Object a = grouping[i].evaluate(evaluator);
                    symtbl.getSymbol("this").setValue(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

     * @param resultSet The resultSet containing al elements
     * @return A list with aggregated elements
     */
    private List handleResult(List resultSet)
    {
        Comparator c = new Comparator()
        {
            public int compare(Object arg0, Object arg1)
            {
                if (grouping != null)
                {
                    for (int i = 0; i < grouping.length; i++)
                    {
                        // TODO Remove HARDCODED "this". Should be alias of some name
                        symtbl.getSymbol("this").setValue(arg0);
                        Object a = grouping[i].evaluate(evaluator);
                        // TODO Remove HARDCODED "this". Should be alias of some name
                        symtbl.getSymbol("this").setValue(arg1);
                        Object b = grouping[i].evaluate(evaluator);
                        int result = ((Comparable) a).compareTo(b);
                        if (result != 0)
                        {
                            return result;
                        }
                    }
                }
                return 0;
            }
        };

        List result = new ArrayList();
        if (grouping != null)
        {
            List groups = new ArrayList();
            List group = new ArrayList();
            if (resultSet.size() > 0)
            {
                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

        if (_pathinfo.length()>1) {
          printFile(out, "..", parent);
        }
      }

      Comparator cmp = SORT_BY_NAME;

      if (context != null) {
        HttpServletRequest request = context.getRequest();
        String sortby = request.getParameter("S");
        if (sortby != null) {
View Full Code Here

  /// @param data Data passed as a fifth parameter to searching function
  /// @return this array sorted
  public static final Object[] p_sort = new Object[] { null, "comparator", "*data", UNDEFINED };
  public Any m_sort(Context context, Any comparator_, Any data)
  {
    Comparator comparator = new AnyUtils.ArrayComparator(context, comparator_, data);
    sort(comparator, true);
    return this;
  }
View Full Code Here

        ArrayList sourceColumns = new ArrayList();
      for (int i=0; i<source.getSize(); i++) {
        Column nextField = source.getField(i);
        sourceColumns.add(nextField);
      }
      Collections.sort(sourceColumns, new Comparator() {
        public int compare(Object o1, Object o2) {
          Column lhs = (Column) o1;
          Column rhs = (Column) o2;
          return lhs.getOrder()-rhs.getOrder();
        }
View Full Code Here

                    //some datastores do not support backingStores
                }
            }

            // Set up our delegate, using a comparator
            Comparator comparator = SCOUtils.getComparator(fmd, ownerSM.getObjectManager().getClassLoaderResolver());
            if (comparator != null)
            {
                this.delegate = new java.util.TreeMap(comparator);
            }
            else
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.