activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajdav...@apache.org
Subject svn commit: r533630 - /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java
Date Mon, 30 Apr 2007 09:01:58 GMT
Author: rajdavies
Date: Mon Apr 30 02:01:58 2007
New Revision: 533630

URL: http://svn.apache.org/viewvc?view=rev&rev=533630
Log:
added some primitive conversions

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java?view=diff&rev=533630&r1=533629&r2=533630
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/converter/NIOConverter.java
Mon Apr 30 02:01:58 2007
@@ -40,4 +40,42 @@
     public static ByteBuffer toByteBuffer(byte[] data) {
         return ByteBuffer.wrap(data);
     }
+    
+    @Converter
+    public static ByteBuffer toByteBuffer(String value) {
+        ByteBuffer buf = ByteBuffer.allocate(value.length());
+        byte[] bytes = value.getBytes();
+        buf.put(bytes);
+        return buf;
+    }
+    @Converter
+    public static ByteBuffer toByteBuffer(Short value) {
+        ByteBuffer buf = ByteBuffer.allocate(2);
+        buf.putShort(value);
+        return buf;
+    }
+    @Converter
+    public static ByteBuffer toByteBuffer(Integer value) {
+        ByteBuffer buf = ByteBuffer.allocate(4);
+        buf.putInt(value);
+        return buf;
+    }
+    @Converter
+    public static ByteBuffer toByteBuffer(Long value) {
+        ByteBuffer buf = ByteBuffer.allocate(8);
+        buf.putLong(value);
+        return buf;
+    }
+    @Converter
+    public static ByteBuffer toByteBuffer(Float value) {
+        ByteBuffer buf = ByteBuffer.allocate(4);
+        buf.putFloat(value);
+        return buf;
+    }
+    @Converter
+    public static ByteBuffer toByteBuffer(Double value) {
+        ByteBuffer buf = ByteBuffer.allocate(8);
+        buf.putDouble(value);
+        return buf;
+    }
 }



Mime
View raw message