org.apache.cocoon.transformation.pagination
Class Pagesheet

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by org.apache.cocoon.transformation.pagination.Pagesheet
All Implemented Interfaces:
Cloneable, Modifiable, ContentHandler, DTDHandler, EntityResolver, ErrorHandler

public class Pagesheet
extends DefaultHandler
implements Cloneable, Modifiable

Interprets the pagesheet rules to perform pagination.

 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
             SAX well-formness. I currently don't have the time to make
             it any better (along with implementing the char-based rule
             that is mostly useful for text documents) but if you want
             to blast the code and rewrite it better, you'll make me happy :)
 

Version:
CVS $Id: Pagesheet.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Stefano Mazzocchi, Boon Hian Tek

Constructor Summary
Pagesheet()
           
 
Method Summary
 Object clone()
           
 void endDocument()
           
 void endElement(String uri, String loc, String raw)
           
 String getItemGroupName(String elementURI, String elementName)
           
 int getPageForItem(int item, String itemGroup)
           
 PageRules getPageRules(int page)
           
 int getTotalItems(String itemGroup)
           
 int getTotalPages()
           
 boolean isInPage(int page, int item, String itemGroup)
           
 int itemCount(String elementURI, String elementName)
           
 boolean modifiedSince(long date)
          Queries the class to estimate its ergodic period termination.
 void processCharacters(char[] ch, int index, int len)
           
 void processEndElement(String uri, String name)
           
 void processStartElement(String uri, String name)
           
 void setLastModified(long lastModified)
           
 void startElement(String uri, String loc, String raw, Attributes a)
           
 void startPrefixMapping(String prefix, String uri)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pagesheet

public Pagesheet()
Method Detail

startPrefixMapping

public void startPrefixMapping(String prefix,
                               String uri)
                        throws SAXException
Specified by:
startPrefixMapping in interface ContentHandler
Overrides:
startPrefixMapping in class DefaultHandler
Throws:
SAXException

startElement

public void startElement(String uri,
                         String loc,
                         String raw,
                         Attributes a)
                  throws SAXException
Specified by:
startElement in interface ContentHandler
Overrides:
startElement in class DefaultHandler
Throws:
SAXException

endElement

public void endElement(String uri,
                       String loc,
                       String raw)
                throws SAXException
Specified by:
endElement in interface ContentHandler
Overrides:
endElement in class DefaultHandler
Throws:
SAXException

endDocument

public void endDocument()
                 throws SAXException
Specified by:
endDocument in interface ContentHandler
Overrides:
endDocument in class DefaultHandler
Throws:
SAXException

processStartElement

public void processStartElement(String uri,
                                String name)

processEndElement

public void processEndElement(String uri,
                              String name)

processCharacters

public void processCharacters(char[] ch,
                              int index,
                              int len)

isInPage

public boolean isInPage(int page,
                        int item,
                        String itemGroup)

getTotalPages

public int getTotalPages()

getTotalItems

public int getTotalItems(String itemGroup)

getPageForItem

public int getPageForItem(int item,
                          String itemGroup)

itemCount

public int itemCount(String elementURI,
                     String elementName)

getItemGroupName

public String getItemGroupName(String elementURI,
                               String elementName)

getPageRules

public PageRules getPageRules(int page)

setLastModified

public void setLastModified(long lastModified)

modifiedSince

public boolean modifiedSince(long date)
Description copied from interface: Modifiable
Queries the class to estimate its ergodic period termination.
This method is called to ensure the validity of a cached product. It is the class responsibility to provide the fastest possible implementation of this method or, whether this is not possible and the costs of the change evaluation is comparable to the production costs, to return true directly with no further delay, thus reducing the evaluation overhead to a minimum.

Specified by:
modifiedSince in interface Modifiable
Returns:
true if the class ergodic period is over and the class would behave differently if processed again, false if the resource is still ergodic so that it doesn't require reprocessing.

clone

public Object clone()
Overrides:
clone in class Object


Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.