stefano 02/02/22 08:48:57 Modified: src/scratchpad/src/org/apache/cocoon/transformation/pagination ItemGroup.java PageRules.java Pagesheet.java Paginator.java ResizableContainer.java Log: reupdated to working state now that all files have been committed Revision Changes Path 1.3 +12 -11 xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination/ItemGroup.java Index: ItemGroup.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination/ItemGroup.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ItemGroup.java 22 Feb 2002 06:58:03 -0000 1.2 +++ ItemGroup.java 22 Feb 2002 16:48:56 -0000 1.3 @@ -3,34 +3,34 @@ ============================================================================ The Apache Software License, Version 1.1 ============================================================================ - + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. - + Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] - + 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. - + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -41,20 +41,21 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by - Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. - + */ + package org.apache.cocoon.transformation.pagination; /** * Container class for the immutable pagination rules for each page. * * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a> - * @version CVS $Revision: 1.2 $ $Date: 2002/02/22 06:58:03 $ + * @version CVS $Revision: 1.3 $ $Date: 2002/02/22 16:48:56 $ */ public class ItemGroup { 1.3 +12 -11 xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination/PageRules.java Index: PageRules.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination/PageRules.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PageRules.java 22 Feb 2002 06:58:03 -0000 1.2 +++ PageRules.java 22 Feb 2002 16:48:56 -0000 1.3 @@ -3,34 +3,34 @@ ============================================================================ The Apache Software License, Version 1.1 ============================================================================ - + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. - + Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] - + 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. - + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -41,20 +41,21 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by - Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. - + */ + package org.apache.cocoon.transformation.pagination; /** * Container class for the immutable pagination rules for each page. * * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a> - * @version CVS $Revision: 1.2 $ $Date: 2002/02/22 06:58:03 $ + * @version CVS $Revision: 1.3 $ $Date: 2002/02/22 16:48:56 $ */ public class PageRules { 1.4 +29 -30 xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination/Pagesheet.java Index: Pagesheet.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination/Pagesheet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Pagesheet.java 22 Feb 2002 06:58:03 -0000 1.3 +++ Pagesheet.java 22 Feb 2002 16:48:56 -0000 1.4 @@ -3,34 +3,34 @@ ============================================================================ The Apache Software License, Version 1.1 ============================================================================ - + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. - + Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] - + 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. - + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -41,13 +41,14 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by - Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. - + */ + package org.apache.cocoon.transformation.pagination; import java.util.Map; @@ -63,12 +64,12 @@ import org.xml.sax.helpers.DefaultHandler; import org.apache.cocoon.Modifiable; -//import org.apache.cocoon.util.ResizableContainer; +import org.apache.cocoon.util.ResizableContainer; /** * Interprets the pagesheet rules to perform pagination. - * - * FIXME (SM): this code sucks! It was done to show the concept of + * + * FIXME (SM): this code sucks! It was done to show the concept of * rule driven pagination (which I find very nice) but * it needs major refactoring in order to be sufficiently * stable to allow any input to enter without breaking @@ -78,10 +79,10 @@ * to blast the code and rewrite it better, you'll make me happy :) * * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a> - * @version CVS $Revision: 1.3 $ $Date: 2002/02/22 06:58:03 $ + * @version CVS $Revision: 1.4 $ $Date: 2002/02/22 16:48:56 $ */ - -/* + +/* This is an example pagesheet to show the power of this: @@ -104,24 +105,23 @@ which indicates that: - 1) there is one item group called "picture" and each item is given by the + 1) there is one item group called "picture" and each item is given by the element "file" of the namespace "http://apache.org/cocoon/directory/2.0". - + 2) for the first page, the pagination rules indicate that there are two unit - links (two above and two below, so linking to page -2 -1 0 +1 +2) and + links (two above and two below, so linking to page -2 -1 0 +1 +2) and range links have value 10 (so they link to page -10 and +10). - + 3) for the rest of the pages, there are three unit links (-3 -2 -1 0 +1 +2 +3) and range goes 20 (so +20 and -20). - + */ public class Pagesheet extends DefaultHandler implements Cloneable, Modifiable { - private long lastModified; -/* private int level = 0; private int pg = 0; + private long lastModified; private Pagesheet pagesheet; private PageRules rules; @@ -183,11 +183,11 @@ this.itemGroupsPerElement = itemGroupsPerElement; this.pages = new ResizableContainer(5); - + if ((this.itemGroupsPerName != null) && (this.itemGroupsPerElement != null)) { this.itemListsPerName = new HashMap(itemGroupsPerName.size()); this.itemListsPerElement = new HashMap(itemGroupsPerName.size()); - + Iterator iter = itemGroupsPerName.values().iterator(); for (int i = 0; iter.hasNext(); i++) { ItemGroup group = (ItemGroup) iter.next(); @@ -361,7 +361,7 @@ public boolean store(String elementURI, String elementName) { PageRules rules = getPageRules(currentPage); - return rules.store; + return rules.store; } public int itemCount(String elementURI, String elementName) { @@ -389,7 +389,7 @@ PageRules p = (PageRules) pageRules.get(page); return (p != null) ? p : (PageRules) pageRules.get(0); } -*/ + public void setLastModified(long lastModified) { this.lastModified = lastModified; } @@ -399,7 +399,6 @@ } public Object clone() { - return null; - //return new Pagesheet(pageRules, itemGroupsPerName, itemGroupsPerElement); + return new Pagesheet(pageRules, itemGroupsPerName, itemGroupsPerElement); } } 1.6 +46 -45 xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination/Paginator.java Index: Paginator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination/Paginator.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Paginator.java 22 Feb 2002 07:11:41 -0000 1.5 +++ Paginator.java 22 Feb 2002 16:48:56 -0000 1.6 @@ -3,34 +3,34 @@ ============================================================================ The Apache Software License, Version 1.1 ============================================================================ - + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. - + Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] - + 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. - + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -41,13 +41,14 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by - Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache + Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. - + */ + package org.apache.cocoon.transformation.pagination; import java.io.IOException; @@ -89,7 +90,7 @@ * A paginating transformer. * * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a> - * @version CVS $Revision: 1.5 $ $Date: 2002/02/22 07:11:41 $ + * @version CVS $Revision: 1.6 $ $Date: 2002/02/22 16:48:56 $ */ public class Paginator extends AbstractTransformer implements Composable, Disposable, Cacheable { @@ -102,10 +103,10 @@ private Parser parser; private Store store; private Source inputSource; - private int page; private Parameters par; private Map objectModel; private SourceResolver resolver; + private int page; private int item; private String itemGroup; private String requestURI; @@ -156,7 +157,7 @@ throw new ProcessingException("I need the paginate instructions (pagesheet) to continue. Set the 'src' attribute."); } - /* this.level = 0; + this.level = 0; this.prefixMapping = false; this.par = par; this.objectModel = objectModel; @@ -188,7 +189,7 @@ // Clone it in order to avoid concurrency collisions since the // implementation is not reentrant. - this.pagesheet = (Pagesheet) this.pagesheet.clone();*/ + this.pagesheet = (Pagesheet) this.pagesheet.clone(); } /** @@ -235,7 +236,7 @@ * @param a The attributes attached to the element. If there are no * attributes, it shall be an empty Attributes object. */ -/* public void startElement(String uri, String loc, String raw, Attributes a) + public void startElement(String uri, String loc, String raw, Attributes a) throws SAXException { if (!prefixMapping) { super.startPrefixMapping(PAGINATE_PREFIX, PAGINATE_URI); @@ -268,7 +269,7 @@ } } } -*/ + /** * Receive notification of the end of an element. * @@ -280,7 +281,7 @@ * @param raw The raw XML 1.0 name (with prefix), or the empty string if * raw names are not available. */ -/* public void endElement(String uri, String loc, String raw) + public void endElement(String uri, String loc, String raw) throws SAXException { level--; if (pagesheet.isInPage(page, item, itemGroup)) { @@ -363,7 +364,7 @@ } pagesheet.processEndElement(uri,loc); } -*/ + /** * Receive notification of character data. * @@ -371,12 +372,12 @@ * @param start The start position in the array. * @param len The number of characters to read from the array. */ -/* public void characters(char c[], int start, int len) + public void characters(char c[], int start, int len) throws SAXException { pagesheet.processCharacters(c, start, len); if (pagesheet.isInPage(page, item, itemGroup)) super.characters(c,start,len); } -*/ + /** * Receive notification of ignorable whitespace in element content. * @@ -384,11 +385,11 @@ * @param start The start position in the array. * @param len The number of characters to read from the array. */ -/* public void ignorableWhitespace(char c[], int start, int len) + public void ignorableWhitespace(char c[], int start, int len) throws SAXException { if (pagesheet.isInPage(page, item, itemGroup)) super.ignorableWhitespace(c,start,len); } -*/ + /** * Receive notification of a processing instruction. * @@ -396,22 +397,22 @@ * @param data The processing instruction data, or null if none was * supplied. */ -/* public void processingInstruction(String target, String data) + public void processingInstruction(String target, String data) throws SAXException { if (pagesheet.isInPage(page, item, itemGroup)) super.processingInstruction(target,data); } -*/ + /** * Receive notification of a skipped entity. * * @param name The name of the skipped entity. If it is a parameter * entity, the name will begin with '%'. */ -/* public void skippedEntity(String name) + public void skippedEntity(String name) throws SAXException { if (pagesheet.isInPage(page, item, itemGroup)) super.skippedEntity(name); } -*/ + /** * Report the start of DTD declarations, if any. * @@ -421,7 +422,7 @@ * @param systemId The declared system identifier for the external DTD * subset, or null if none was declared. */ -/* public void startDTD(String name, String publicId, String systemId) + public void startDTD(String name, String publicId, String systemId) throws SAXException { if (pagesheet.isInPage(page, item, itemGroup)) { super.startDTD(name,publicId,systemId); @@ -431,11 +432,11 @@ ); } } -*/ + /** * Report the end of DTD declarations. */ -/* public void endDTD() + public void endDTD() throws SAXException { if (pagesheet.isInPage(page, item, itemGroup)) { super.endDTD(); @@ -445,44 +446,44 @@ ); } } -*/ + /** * Report the beginning of an entity. * * @param name The name of the entity. If it is a parameter entity, the * name will begin with '%'. */ -/* public void startEntity(String name) + public void startEntity(String name) throws SAXException { if (pagesheet.isInPage(page, item, itemGroup)) super.startEntity(name); } -*/ + /** * Report the end of an entity. * * @param name The name of the entity that is ending. */ - /* public void endEntity(String name) + public void endEntity(String name) throws SAXException { if (pagesheet.isInPage(page, item, itemGroup)) super.endEntity(name); } -*/ + /** * Report the start of a CDATA section. */ -/* public void startCDATA() + public void startCDATA() throws SAXException { if (pagesheet.isInPage(page, item, itemGroup)) super.startCDATA(); } -*/ + /** * Report the end of a CDATA section. */ -/* public void endCDATA() + public void endCDATA() throws SAXException { if (pagesheet.isInPage(page, item, itemGroup)) super.endCDATA(); } -*/ + /** * Report an XML comment anywhere in the document. * @@ -490,16 +491,16 @@ * @param start The starting position in the array. * @param len The number of characters to use from the array. */ -/* public void comment(char ch[], int start, int len) + public void comment(char ch[], int start, int len) throws SAXException { if (pagesheet.isInPage(page, item, itemGroup)) super.comment(ch,start,len); } -*/ + /** * Removes the pagination encoding from the URI by removing the page * number and the previous and next character. */ -/* private String cleanURI(String uri, int current) { + private String cleanURI(String uri, int current) { String currentS = String.valueOf(current); int index = uri.lastIndexOf(currentS); if (index == -1) { @@ -508,7 +509,7 @@ return uri.substring(0, index - 1) + uri.substring(index + currentS.length() + 1); } } -*/ + /** * Encode the next page in the given URI. First tries to use the * existing encoding by replacing the current page number, but if @@ -516,7 +517,7 @@ * filename (before the file extention, if any) where "xx" is the * next page value. */ - /* private String encodeURI(String uri, int current, int next) { + private String encodeURI(String uri, int current, int next) { String currentS = String.valueOf(current); String nextS = String.valueOf(next); int index = uri.lastIndexOf(currentS); @@ -530,5 +531,5 @@ } else { return uri.substring(0, index) + nextS + uri.substring(index + currentS.length()); } - }*/ + } } 1.2 +0 -0 xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination/ResizableContainer.java Index: ResizableContainer.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/transformation/pagination/ResizableContainer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ResizableContainer.java 22 Feb 2002 16:47:10 -0000 1.1 +++ ResizableContainer.java 22 Feb 2002 16:48:56 -0000 1.2 @@ -56,7 +56,7 @@ * Add-only Container class. * * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a> - * @version CVS $Revision: 1.1 $ $Date: 2002/02/22 16:47:10 $ + * @version CVS $Revision: 1.2 $ $Date: 2002/02/22 16:48:56 $ */ public class ResizableContainer {
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]