CVS: TapestryBook/bannerads/src/bannerads/app Stats.java,NONE,1.1

Howard Lewis Ship <[email protected]> Sun, 25 May 2003 14:28:04 -0700
Newsgroups gmane.comp.java.tapestry.cvs
Message-ID <[email protected]>
Update of /cvsroot/tapestry/TapestryBook/bannerads/src/bannerads/app
In directory sc8-pr-cvs1:/tmp/cvs-serv25806/bannerads/src/bannerads/app

Added Files:
	Stats.java 
Log Message:
Update docs based on lengthy revisions.

--- NEW FILE: Stats.java ---
package bannerads.app;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.tapestry.html.BasePage;
import org.apache.tapestry.spec.IApplicationSpecification;

import bannerads.IBanner;
import bannerads.IBannerSource;

public class Stats extends BasePage
{
    /**
     * Returns the banners, sorted by id.
     */
    public List getSortedBanners()
    {
        IApplicationSpecification spec = getEngine().getSpecification();
        IBannerSource source =
            (IBannerSource) spec.getExtension(
                IBannerSource.BANNER_SOURCE_EXTENSION_NAME,
                IBannerSource.class);

        source.initialize(getRequestCycle());

        List ids = source.getBannerIds();

        Collections.sort(ids);

        int count = ids.size();
        List result = new ArrayList(count);

        for (int i = 0; i < count; i++)
        {
            String id = (String) ids.get(i);
            IBanner banner = source.getBanner(id);
            result.add(banner);
        }

        return result;
    }
}



-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge