@SuppressWarnings("unchecked") @Deprecated private static TemplateSequenceModel toSimpleSequence(TemplateModel object,ObjectWrapper objectWrapper) throws TemplateModelException {
  if (object instanceof TemplateSequenceModel) {
    return (TemplateSequenceModel)object;
  }
 else   if (object instanceof WrapperTemplateModel) {
    WrapperTemplateModel wrapperModel=(WrapperTemplateModel)object;
    Object wrappedObject=wrapperModel.getWrappedObject();
    if (wrappedObject instanceof List) {
      return DefaultListAdapter.adapt((List<Object>)wrappedObject,(RichObjectWrapper)objectWrapper);
    }
 else     if (wrappedObject instanceof Object[]) {
      return DefaultArrayAdapter.adapt((Object[])wrappedObject,(ObjectWrapperAndUnwrapper)objectWrapper);
    }
 else     if (wrappedObject instanceof Set) {
      throw new UnsupportedOperationException("Not yet implemented");
    }
 else     if (wrappedObject instanceof Collection) {
      throw new UnsupportedOperationException("Not yet implemented");
    }
 else     if (wrappedObject instanceof Iterable) {
      throw new UnsupportedOperationException("Not yet implemented");
    }
 else {
      throw new TemplateModelException("Cannot convert bean-wrapped object of type " + (object != null ? object.getClass() : "null") + " to simple sequence");
    }
  }
 else   if (object instanceof TemplateCollectionModel) {
    TemplateCollectionModel collModel=(TemplateCollectionModel)object;
    SimpleSequence res=new SimpleSequence(objectWrapper);
    TemplateModelIterator it=collModel.iterator();
    while (it.hasNext()) {
      res.add(it.next());
    }
    return res;
  }
 else {
    throw new TemplateModelException("Cannot convert object of type " + (object != null ? object.getClass() : "null") + " to simple sequence");
  }
}

@ SuppressWarnings ( "unchecked" ) @ Deprecated private static TemplateSequenceModel toSimpleSequence ( TemplateModel object , ObjectWrapper objectWrapper ) throws TemplateModelException { if ( object instanceof TemplateSequenceModel ) { return ( TemplateSequenceModel ) object ; } else if ( object instanceof WrapperTemplateModel ) { WrapperTemplateModel wrapperModel = ( WrapperTemplateModel ) object ; Object wrappedObject = wrapperModel . getWrappedObject ( ) ; if ( wrappedObject instanceof List ) { return DefaultListAdapter . adapt ( ( List < Object > ) wrappedObject , ( RichObjectWrapper ) objectWrapper ) ; } else if ( wrappedObject instanceof Object [ ] ) { return DefaultArrayAdapter . adapt ( ( Object [ ] ) wrappedObject , ( ObjectWrapperAndUnwrapper ) objectWrapper ) ; } else if ( wrappedObject instanceof Set ) { throw new UnsupportedOperationException ( "Not yet implemented" ) ; } else if ( wrappedObject instanceof Collection ) { throw new UnsupportedOperationException ( "Not yet implemented" ) ; } else if ( wrappedObject instanceof Iterable ) { throw new UnsupportedOperationException ( "Not yet implemented" ) ; } else { throw new TemplateModelException ( "Cannot convert bean-wrapped object of type " + ( object != null ? object . getClass ( ) : "null" ) + " to simple sequence" ) ; } } else if ( object instanceof TemplateCollectionModel ) { TemplateCollectionModel collModel = ( TemplateCollectionModel ) object ; SimpleSequence res = new SimpleSequence ( objectWrapper ) ; TemplateModelIterator it = collModel . iterator ( ) ; while ( it . hasNext ( ) ) { res . add ( it . next ( ) ) ; } return res ; } else { throw new TemplateModelException ( "Cannot convert object of type " + ( object != null ? object . getClass ( ) : "null" ) + " to simple sequence" ) ; } }
supposed to convert to simple sequence . < p > warn : bypasses auto - escaping for complex maps , caller must decide how to handle . ( e . g . the object wrapper used to rewrap the result ) . < p > dev note : i stopped writing / testing this when found out most of the problems w . r . t . collections are not the ftl types this time but the way they ' re used in ofbiz templates . ftl ' s collectionmodel ( subclass of templatecollectionmodel ) is supposed to cover everything and won ' t suffer from the same problems maps have .
