//# 0 errors, 24 messages
//#
/*
    //#WeblogEntryWrapperComparator.java:1:1: class: org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator
    //#WeblogEntryWrapperComparator.java:1:1: method: org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator.org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator__static_init
* Licensed to the Apache Software Foundation (ASF) under one or more
*  contributor license agreements.  The ASF licenses this file to You
* under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.  For additional information regarding
* copyright in this work, please see the NOTICE file in the top level
* directory of this distribution.
*/

package org.apache.roller.weblogger.pojos;

import java.io.Serializable;
import java.util.Comparator;
import org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper;

/**
 * Sorts WeblogEntryData objects in reverse chronological order
 * (most recently published entries first).  If they happen to
 * have the same pubTime, then sort alphabetically by title.
 * 
 * @author lance.lavandowska
 */
public class WeblogEntryWrapperComparator implements Comparator, Serializable
    //#WeblogEntryWrapperComparator.java:32: method: void org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator.org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator()
    //#WeblogEntryWrapperComparator.java:32: end of method: void org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator.org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator()
{
    static final long serialVersionUID = -9067148992322255150L;
    
    public int compare(Object val1, Object val2)
    throws ClassCastException
    {
        WeblogEntryWrapper entry1 = (WeblogEntryWrapper)val1;
    //#WeblogEntryWrapperComparator.java:39: method: int org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator.compare(Object, Object)
    //#input(int compare(Object, Object)): val1
    //#input(int compare(Object, Object)): val2
    //#output(int compare(Object, Object)): return_value
    //#pre[1] (int compare(Object, Object)): val1 != null
    //#pre[2] (int compare(Object, Object)): val2 != null
    //#presumption(int compare(Object, Object)): org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper:getPubTime(...)@41 != null
    //#presumption(int compare(Object, Object)): org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper:getPubTime(...)@42 != null
    //#presumption(int compare(Object, Object)): org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper:getTitle(...)@55 != null
    //#post(int compare(Object, Object)): init'ed(return_value)
        WeblogEntryWrapper entry2 = (WeblogEntryWrapper)val2;
        long pubTime1 = entry1.getPubTime().getTime();
    //#WeblogEntryWrapperComparator.java:41: Warning: method not available
    //#    -- call on Timestamp org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper:getPubTime()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator
    //#    method: int compare(Object, Object)
    //#    unanalyzed callee: Timestamp org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper:getPubTime()
        long pubTime2 = entry2.getPubTime().getTime();
    //#WeblogEntryWrapperComparator.java:42: Warning: method not available
    //#    -- call on Timestamp org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper:getPubTime()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator
    //#    method: int compare(Object, Object)
    //#    unanalyzed callee: Timestamp org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper:getPubTime()

        if (pubTime1 > pubTime2)
        {
            return -1;
        }
        else if (pubTime1 < pubTime2)
        {
            return 1;
        }

        // if pubTimes are the same, return
        // results of String.compareTo() on Title
        return entry1.getTitle().compareTo(entry2.getTitle());
    //#WeblogEntryWrapperComparator.java:55: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper:getTitle()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator
    //#    method: int compare(Object, Object)
    //#    unanalyzed callee: String org.apache.roller.weblogger.pojos.wrapper.WeblogEntryWrapper:getTitle()
    //#WeblogEntryWrapperComparator.java:55: end of method: int org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator.compare(Object, Object)
    }
}
    //#output(org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator__static_init): __Descendant_Table[org/apache/roller/weblogger/pojos/WeblogEntryWrapperComparator]
    //#output(org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator__static_init): __Dispatch_Table.compare(Ljava/lang/Object;Ljava/lang/Object;)I
    //#post(org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator__static_init): __Descendant_Table[org/apache/roller/weblogger/pojos/WeblogEntryWrapperComparator] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator__static_init): __Dispatch_Table.compare(Ljava/lang/Object;Ljava/lang/Object;)I == &compare
    //#WeblogEntryWrapperComparator.java:: end of method: org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator.org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator__static_init
    //#WeblogEntryWrapperComparator.java:: end of class: org.apache.roller.weblogger.pojos.WeblogEntryWrapperComparator
