diff m-toolbox/classes/+utils/@helper/jArrayList2CellArray.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@helper/jArrayList2CellArray.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,24 @@
+% JARRAYLIST2CELLARRAY Converts a java ArrayList into a MATLAB cell array.
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% DESCRIPTION: JARRAYLIST2CELLARRAY Converts a java ArrayList into a MATLAB
+%              cell array.
+%
+% CALL:        cellArray = jArrayList2CellArray(jArrayList)
+%
+% VERSION:     $Id: jArrayList2CellArray.m,v 1.1 2010/08/18 09:19:06 ingo Exp $
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+function c = jArrayList2CellArray(jArrayList)
+  
+  if isjava(jArrayList) && isa(jArrayList, 'java.util.ArrayList')
+    
+    c = {};
+    for ii=0:jArrayList.size()-1
+      c = [c {jArrayList.get(ii)}];
+    end
+  else
+    error('### The input is not a java ArrayList but from class %s', class(jArrayList));
+  end
+  
+end