Package java.util

Examples of java.util.Comparator


          } catch (IllegalAccessException iaex) {
          }
        }
      }
    }
    Collections.sort(result, new Comparator() {
      public int compare(Object o1, Object o2) {
        return o1.getClass().getSimpleName()
            .compareTo(o2.getClass().getSimpleName());
      }
    });
View Full Code Here


  private boolean buildTree(TreeNode tParent, VFSContainer parentContainer, String parentPath) {
    List children = parentContainer.getItems(fileFilter);
    if (children.size() == 0) return false;

    // sort the children
    Collections.sort(children, new Comparator(){
      final Collator c = collator;
      public int compare(final Object o1, final Object o2) {
        return c.compare(((VFSItem)o1).getName(), ((VFSItem)o2).getName());
      }});
View Full Code Here

   */
  public static int invalidateOldestSessions(int nbrSessions) {
    int invalidateCounter = 0;
    // 1. Copy authUserSessions in sorted TreeMap
    // This is the Comparator that will be used to sort the TreeSet:
    Comparator sessionComparator = new Comparator() {
      public int compare(Object o1, Object o2) {
        Long long1 = new Long(((UserSession) o1).getSessionInfo().getLastClickTime());
        Long long2 = new Long(((UserSession) o2).getSessionInfo().getLastClickTime());
        return long1.compareTo(long2);
      }
View Full Code Here

   * @param sortingCriteria
   * @param itemComparator
   * @return
   */
  protected List getSortedList(List itemList, SortingCriteria sortingCriteria) {
    Comparator itemComparator = getComparator(sortingCriteria);
    Collections.sort(itemList, itemComparator);
    // check here is asscending or descending and return the first max entries
    int maxEntries = sortingCriteria.getMaxEntries();
    List returnList = itemList.subList(0, Math.min(itemList.size(), maxEntries));
    return returnList;
View Full Code Here

   * choosen manually order (available in the sortedItems map).
   * @param sortedItems
   * @return
   */
  protected Comparator getPortletEntryComparator(final Map<Long,Integer> sortedItems) {
    return new Comparator(){     
      public int compare(final Object o1, final Object o2) {
        PortletEntry portletEntry1= (PortletEntry)o1;
        PortletEntry portletEntry2 = (PortletEntry)o2;   
        int comparisonResult = 0;
        Integer portletEntry1Index = sortedItems.get(portletEntry1.getKey());
View Full Code Here

  }

 
  protected static Comparator createOrderComparator(Comparator comparator, SortOrderEnum order)
  {
    Comparator orderComparator;
    switch (order)
    {
      case DESCENDING:
      {
        if (comparator == null)
View Full Code Here

      {
         list.add(new Integer(unsorted[i]));
      }
     
      Collections.sort(list,
            new Comparator()
            {
             public boolean equals(Object obj)
             {
                return false;
             }
View Full Code Here

    System.out.println(sb.toString());

    if (item instanceof VFSContainer) {
      VFSContainer cont = (VFSContainer) item;
      List items = cont.getItems();
      Collections.sort(items, new Comparator() {
        public int compare(Object a, Object b) {
          VFSItem va = (VFSItem)a;
          VFSItem vb = (VFSItem)b;
          boolean ac = (va instanceof VFSContainer);
          boolean bc = (vb instanceof VFSContainer);
View Full Code Here

        ArrayList color_groups = new ArrayList();
        ColorGroup root = new ColorGroup(new ArrayList(color_map.values()));
        {
            color_groups.add(root);

            final Comparator comparator = new Comparator()
            {
                public int compare(Object o1, Object o2)
                {
                    ColorGroup cg1 = (ColorGroup) o1;
                    ColorGroup cg2 = (ColorGroup) o2;
View Full Code Here

            ColorCount color_count = (ColorCount) color_group.color_counts
                    .get(i);
            count_total += color_count.count;
        }

        Comparator comparator = new Comparator()
        {
            public int compare(Object o1, Object o2)
            {
                ColorCount c1 = (ColorCount) o1;
                ColorCount c2 = (ColorCount) o2;
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.