Return-Path: Mailing-List: contact struts-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list struts-dev@jakarta.apache.org Received: (qmail 19368 invoked from network); 3 Jul 2000 19:35:51 -0000 Received: from mail1.noc0.hsacorp.net (208.247.171.140) by locus.apache.org with SMTP; 3 Jul 2000 19:35:51 -0000 Received: from [208.243.240.57] (HELO tri-lakesonline.net) by mail1.noc0.hsacorp.net (CommuniGate Pro SMTP 3.2.4) with ESMTP id 15180422 for struts-dev@jakarta.apache.org; Mon, 03 Jul 2000 15:35:49 -0400 Message-ID: <3960ED0B.270E42B8@tri-lakesonline.net> Date: Mon, 03 Jul 2000 13:44:12 -0600 From: David Geary X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en,fr MIME-Version: 1.0 To: struts-dev@jakarta.apache.org Subject: Re: JDK 1.1 support (was RE: Java2 Compatibility) References: <14687.63624.782905.780696@vega.sudell.org> <3960B716.DFE7A1E4@eng.sun.com> <3960CCFF.3C157524@tri-lakesonline.net> <007201bfe522$8309ce90$46fae6c1@sylvester> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N Marius Sorin Barduta wrote: > Maybe I don't get the point but the proposed IteratorAdapter doesn't compile > nor run under JDK 1.1. (because it uses Iterator which is defined in JDK > 1.2) > So, under JDK 1.1, how can I use the tag that use this Adapter? It compiles under Java2 ... see Craig's first sentence below. david > Marius > > > "Craig R. McClanahan" wrote: > > > > > Struts requires Java2 for compilation, but runs on JDK 1.1 platforms if > you avoid > > > the custom tags that utilize the collections classes. In most cases, > there are > > > substitute tags available that are JDK 1.1 compatible (enmerate instead > of > > > iterate). If you find any cases where this is not the case, I'd > certainly like to > > > have one (such as a new "options1" tag that is like "options" but uses > JDK 1.1 > > > collections instead of Java2 collections. > > > > I think we can have struts work with both types of collections without > duplicate tags; > > here's how: > > > > The tag classes would use an adapter that converts a 1.1 interface into a > Java2 > > collections interface. For example, the enumerate and iterate tags differ > in how they > > traverse their collections; enumerate uses java.util.Enumeration and > iterate uses > > java.util.Iterator. The enumerate and iterate tags could be collapsed into > one tag and > > that tag would use an IteratorAdapter. The adapter is listed below: > > > > package org.apache.struts.util; > > > > import java.util.*; > > > > public class IteratorAdapter implements Iterator { > > private Object collection; > > private Iterator iterator=null; > > private Enumeration enumeration=null; > > > > public IteratorAdapter(Object collection) { > > this.collection = collection; > > > > // extract iterator from collection with code that > > // is currently in IterateTag.doStartTag() and > > // EnumerateTag.doStartTag(), ie: > > // > > // if (collection.getClass().isArray()) > > // collection = Arrays.asList((Object[]) collection); > > // if (collection instanceof Collection) > > // iterator = ((Collection) collection).iterator(); > > // else if (collection instanceof Iterator) > > // ... > > // > > // assign EITHER iterator or enumeration, one is left null > > } > > public boolean hasNext() { > > if(iterator != null) > > return iterator.hasNext(); > > else > > return enumeration.hasMoreElements(); > > } > > public Object next() { > > if(iterator != null) > > return iterator.next(); > > else > > return enumeration.nextElement(); > > } > > public void remove() { > > throw new Error("IteratorAdapter.remove() not implemented"); > > } > > } > > > > > > david > > > >