From: <st...@us...> - 2009-09-28 14:54:47
|
Revision: 7886 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=7886&view=rev Author: steve_l Date: 2009-09-28 14:53:57 +0000 (Mon, 28 Sep 2009) Log Message: ----------- SFOS-1298 Add a way to create string lists from an attribute of a CD Modified Paths: -------------- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ListUtils.java Modified: trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ListUtils.java =================================================================== --- trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ListUtils.java 2009-09-25 15:46:07 UTC (rev 7885) +++ trunk/core/smartfrog/src/org/smartfrog/sfcore/utils/ListUtils.java 2009-09-28 14:53:57 UTC (rev 7886) @@ -23,6 +23,7 @@ import org.smartfrog.sfcore.common.SmartFrogResolutionException; import org.smartfrog.sfcore.prim.Prim; import org.smartfrog.sfcore.reference.Reference; +import org.smartfrog.sfcore.componentdescription.ComponentDescription; import java.util.List; import java.util.Vector; @@ -235,6 +236,34 @@ throws SmartFrogResolutionException, RemoteException { Vector<?> vector = null; vector = component.sfResolve(ref, vector, required); + return convertToStringList(vector); + } + + /** + * Extract a string list; everything is converted to strings in the process + * + * @param cd component description to resolve against + * @param ref a reference + * @param required whether the element is required or not + * @return the list, or null if none was provided + * @throws SmartFrogResolutionException if the resolution fails. + * @throws RemoteException network problems + */ + public static Vector<String> resolveStringList(ComponentDescription cd, + Reference ref, + boolean required) + throws SmartFrogResolutionException { + Vector<?> vector = null; + vector = cd.sfResolve(ref, vector, required); + return convertToStringList(vector); + } + + /** + * Run through every element and call toString() on it, the result is a string list + * @param vector input vector + * @return string output + */ + private static Vector<String> convertToStringList(Vector<?> vector) { if (vector == null) { return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |