stefano     2002/06/27 10:44:42

  Modified:    src/scratchpad/src/org/apache/cocoon/transformation/pagination
                        Pagesheet.java
  Log:
  - removing the 'store' property which isn't used anymore
  - preventing NPE when <items> are missing in the pagesheet
  
  Revision  Changes    Path
  1.6       +12 -10    
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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Pagesheet.java    29 Mar 2002 20:12:08 -0000      1.5
  +++ Pagesheet.java    27 Jun 2002 17:44:42 -0000      1.6
  @@ -92,12 +92,12 @@
       <group name="pictures" element="file" 
namespace="http://apache.org/cocoon/directory/2.0"/>
      </items>
      <rules page="1">
  -    <count type="element" name="file" 
namespace="http://apache.org/cocoon/directory/2.0"; num="16" store="yes"/>
  +    <count type="element" name="file" 
namespace="http://apache.org/cocoon/directory/2.0"; num="16"/>
        <link type="unit" num="2"/>
        <link type="range" value="10"/>
      </rules>
      <rules>
  -    <count type="element" name="file" 
namespace="http://apache.org/cocoon/directory/2.0"; num="16" store="yes"/>
  +    <count type="element" name="file" 
namespace="http://apache.org/cocoon/directory/2.0"; num="16"/>
        <link type="unit" num="5"/>
        <link type="range" value="20"/>
      </rules>
  @@ -233,6 +233,7 @@
                   } else if (loc.equals("items")) {
                       if (this.itemGroupsPerName == null) this.itemGroupsPerName = 
new HashMap(2);
                       if (this.itemGroupsPerElement == null) 
this.itemGroupsPerElement = new HashMap(2);
  +                    return;
                   }
                   break;
               case 3:
  @@ -240,7 +241,6 @@
                       if (a.getValue("type").equals("element")) {
                           rules.elementName = a.getValue("name");
                           rules.elementURI = a.getValue("namespace");
  -                        rules.store = (a.getValue("store") != null);
                           try {
                               rules.elementCount = 
Integer.parseInt(a.getValue("num"));
                           } catch (NumberFormatException e) {
  @@ -255,6 +255,7 @@
                       } else {
                           throw new SAXException("Syntax error: count type not 
supported.");
                       }
  +                    return;
                   } else if (loc.equals("link")) {
                       if (a.getValue("type").equals("unit")) {
                           try {
  @@ -271,6 +272,7 @@
                       } else {
                           throw new SAXException("Syntax error: link type not 
supported.");
                       }
  +                    return;
                   } else if (loc.equals("group")) {
                       String name = a.getValue("name");
                       String elementName = a.getValue("element");
  @@ -280,8 +282,8 @@
                       ItemGroup group = new ItemGroup(name, elementURI, elementName);
                       this.itemGroupsPerName.put(name, group);
                       this.itemGroupsPerElement.put(elementURI+elementName, group);
  +                    return;
                   }
  -                return;
           }
           throw new SAXException("Syntax error: element " + raw + " is not recognized 
or is misplaced.");
       }
  @@ -352,26 +354,25 @@
       }
   
       public int getTotalItems(String itemGroup) {
  +        if (this.itemListsPerName == null) return 0;
           ItemList list = (ItemList) this.itemListsPerName.get(itemGroup);
           return (list == null) ? 0 : list.size();
       }
   
       public int getPageForItem(int item, String itemGroup) {
  +        if (this.itemListsPerName == null) return 0;
           ItemList list = (ItemList) this.itemListsPerName.get(itemGroup);
           return (list == null) ? 0 : list.getPageForItem(item);
       }
   
  -    public boolean store(String elementURI, String elementName) {
  -        PageRules rules = getPageRules(currentPage);
  -        return rules.store;        
  -    }
  -
       public int itemCount(String elementURI, String elementName) {
  +        if (this.itemListsPerElement == null) return 0;
           ItemList list = (ItemList) 
this.itemListsPerElement.get(elementURI+elementName);
           return (list == null) ? 0 : list.size();
       }
   
       public String getItemGroupName(String elementURI, String elementName) {
  +        if (this.itemListsPerElement == null) return null;
           return ((ItemGroup) 
this.itemGroupsPerElement.get(elementURI+elementName)).getName();
       }
   
  @@ -382,6 +383,7 @@
               Page p = (Page) pages.get(page);
               return (p != null) && (p.validInPage(counter));
           } else {
  +            if (this.itemListsPerElement == null) return false;
               ItemList list = (ItemList) this.itemListsPerName.get(itemGroup);
               return (list != null) && (list.valid(item));
           }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to