You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by jb...@apache.org on 2010/05/17 12:27:34 UTC

svn commit: r945066 - in /servicemix/components/bindings/servicemix-file/trunk/src: main/java/org/apache/servicemix/file/comparator/ test/java/org/apache/servicemix/file/ test/resources/

Author: jbonofre
Date: Mon May 17 10:27:34 2010
New Revision: 945066

URL: http://svn.apache.org/viewvc?rev=945066&view=rev
Log:
Add a set of default comparators.

Added:
    servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/
    servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/FileNameComparator.java   (with props)
    servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/LastModificationDateComparator.java   (with props)
    servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/SizeComparator.java   (with props)
Removed:
    servicemix/components/bindings/servicemix-file/trunk/src/test/java/org/apache/servicemix/file/NameComparator.java
Modified:
    servicemix/components/bindings/servicemix-file/trunk/src/test/resources/spring-polling.xml

Added: servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/FileNameComparator.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/FileNameComparator.java?rev=945066&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/FileNameComparator.java (added)
+++ servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/FileNameComparator.java Mon May 17 10:27:34 2010
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.servicemix.file.comparator;
+
+import java.io.File;
+import java.util.Comparator;
+
+/**
+ * <p>
+ * Simple comparator working on file name.
+ * </p>
+ * 
+ * @author jbonofre
+ */
+public class FileNameComparator implements Comparator<File> {
+    
+    /*
+     * (non-Javadoc)
+     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+     */
+    public int compare(File file1, File file2) {
+        return file1.getPath().compareTo(file2.getPath());
+    }
+
+}

Propchange: servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/FileNameComparator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/LastModificationDateComparator.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/LastModificationDateComparator.java?rev=945066&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/LastModificationDateComparator.java (added)
+++ servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/LastModificationDateComparator.java Mon May 17 10:27:34 2010
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.servicemix.file.comparator;
+
+import java.io.File;
+import java.util.Comparator;
+
+/**
+ * <p>
+ * Simple comparator working on file last modification date.
+ * </p>
+ * 
+ * @author jbonofre
+ */
+public class LastModificationDateComparator implements Comparator<File> {
+    
+    /*
+     * (non-Javadoc)
+     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+     */
+    public int compare(File file1, File file2) {
+        return ((int)file1.lastModified())-((int)file2.lastModified());
+    }
+
+}

Propchange: servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/LastModificationDateComparator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/SizeComparator.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/SizeComparator.java?rev=945066&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/SizeComparator.java (added)
+++ servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/SizeComparator.java Mon May 17 10:27:34 2010
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.servicemix.file.comparator;
+
+import java.io.File;
+import java.util.Comparator;
+
+/**
+ * <p>
+ * Simple comparator working of file size.
+ * </p>
+ * 
+ * @author jb
+ *
+ */
+public class SizeComparator implements Comparator<File> {
+    
+    /*
+     * (non-Javadoc)
+     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+     */
+    public int compare(File file1, File file2) {
+        return ((int)file1.length())-(int)file2.length();
+    }
+
+}

Propchange: servicemix/components/bindings/servicemix-file/trunk/src/main/java/org/apache/servicemix/file/comparator/SizeComparator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: servicemix/components/bindings/servicemix-file/trunk/src/test/resources/spring-polling.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-file/trunk/src/test/resources/spring-polling.xml?rev=945066&r1=945065&r2=945066&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-file/trunk/src/test/resources/spring-polling.xml (original)
+++ servicemix/components/bindings/servicemix-file/trunk/src/test/resources/spring-polling.xml Mon May 17 10:27:34 2010
@@ -61,7 +61,7 @@
                                  file="file:target/pollerFiles3/"
                                  deleteFile="true">
                         <property name="comparator">
-                            <bean class="org.apache.servicemix.file.NameComparator"/>
+                            <bean class="org.apache.servicemix.file.comparator.FileNameComparator"/>
                         </property>             
                     </file:poller>