camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r773908 - in /camel/branches/camel-1.x/camel-core/src: main/java/org/apache/camel/language/simple/FileExpressionBuilder.java main/java/org/apache/camel/language/simple/FileLanguage.java test/java/org/apache/camel/language/FileLanguageTest.java
Date Tue, 12 May 2009 14:18:04 GMT
Author: davsclaus
Date: Tue May 12 14:18:03 2009
New Revision: 773908

URL: http://svn.apache.org/viewvc?rev=773908&view=rev
Log:
CAMEL-1607: Added missing name:ext to FileLanguage in Camel 1.x

Modified:
    camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/language/simple/FileExpressionBuilder.java
    camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/language/simple/FileLanguage.java
    camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java

Modified: camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/language/simple/FileExpressionBuilder.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/language/simple/FileExpressionBuilder.java?rev=773908&r1=773907&r2=773908&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/language/simple/FileExpressionBuilder.java
(original)
+++ camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/language/simple/FileExpressionBuilder.java
Tue May 12 14:18:03 2009
@@ -72,6 +72,24 @@
         };
     }
 
+    public static <E extends Exchange> Expression<E> fileExtensionExpression()
{
+        return new Expression<E>() {
+            public Object evaluate(E exchange) {
+                String name = exchange.getIn().getHeader("CamelFileName", String.class);
+                if (name != null) {
+                    return name.substring(name.lastIndexOf('.') + 1);
+                } else {
+                    return null;
+                }
+            }
+
+            @Override
+            public String toString() {
+                return "file:ext";
+            }
+        };
+    }
+
     public static <E extends Exchange> Expression<E> fileParentExpression() {
         return new Expression<E>() {
             public Object evaluate(E exchange) {

Modified: camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/language/simple/FileLanguage.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/language/simple/FileLanguage.java?rev=773908&r1=773907&r2=773908&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/language/simple/FileLanguage.java
(original)
+++ camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/language/simple/FileLanguage.java
Tue May 12 14:18:03 2009
@@ -59,6 +59,8 @@
                 return FileExpressionBuilder.fileNameExpression();
             } else if (ObjectHelper.equal(remainder, "name.noext")) {
                 return FileExpressionBuilder.fileNameNoExtensionExpression();
+            } else if (ObjectHelper.equal(remainder, "ext")) {
+                return FileExpressionBuilder.fileExtensionExpression();
             } else if (ObjectHelper.equal(remainder, "parent")) {
                 return FileExpressionBuilder.fileParentExpression();
             } else if (ObjectHelper.equal(remainder, "path")) {

Modified: camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java?rev=773908&r1=773907&r2=773908&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java
(original)
+++ camel/branches/camel-1.x/camel-core/src/test/java/org/apache/camel/language/FileLanguageTest.java
Tue May 12 14:18:03 2009
@@ -59,6 +59,7 @@
     public void testFile() throws Exception {
         assertExpression("${file:name}", file.getName());
         assertExpression("${file:name.noext}", "hello");
+        assertExpression("${file:ext}", "txt");
         assertExpression("${file:parent}", file.getParent());
         assertExpression("${file:path}", file.getPath());
         assertExpression("${file:absolute.path}", file.getAbsolutePath());



Mime
View raw message