001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.apache.servicemix.vfs.comparator;
017    
018    import java.util.Comparator;
019    
020    import org.apache.commons.vfs.FileObject;
021    
022    /**
023     * <p>
024     * Simple file object comparator working on the last modification date.
025     * </p>
026     * 
027     * @author jbonofre
028     */
029    public class LastModificationDateComparator implements Comparator<FileObject> {
030        
031        public int compare(FileObject file1, FileObject file2) {
032            try {
033                return (int)(file1.getContent().getLastModifiedTime()-file2.getContent().getLastModifiedTime());
034            } catch (Exception e) {
035                return 0;
036            }
037        }
038    
039    }