[stringtemplate-interest] handling of arrays (John Snyders)
Terence Parr
parrt at cs.usfca.edu
Tue Jan 30 13:13:24 PST 2007
Ok, i made an array wrapper and iterator. had to do both so a list
is not purely an iterator, which has sideeffects.
/** Do a standard conversion of array attributes to a List. Wrap the
* array instead of copying like old version. Make an
* ArrayWrappedInList that knows to create an ArrayIterator.
*/
public static Object convertArrayToList(Object value) {
if ( value==null ) {
return null;
}
if ( value.getClass().isArray() ) {
return new ArrayWrappedInList(value);
}
return value;
}
ArrayWrappedInList creates ArrayIterator. These are two new classes.
Pushed to depot.
Ter
On Jan 30, 2007, at 9:13 AM, Harry Karadimas wrote:
> Hi, I don't know if that relates to the previous post, but java
> *does* have something
> to encapsulate an array into a list, and that is the "asList"
> method of the java.util.Arrays
> class.
>
> Object[] myArray = ...
> List myList = Arrays.asList(myArray);
>
> Harry Karadimas ____
More information about the stringtemplate-interest
mailing list