Coverage Report - net.sf.statcvs.pages.PageGroup
 
Classes in this File Line Coverage Branch Coverage Complexity
PageGroup
0%
0/59
0%
0/30
1.833
 
 1  
 package net.sf.statcvs.pages;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.Iterator;
 5  
 import java.util.List;
 6  
 
 7  
 public class PageGroup implements NavigationNode {
 8  
     private final String title;
 9  
     private final boolean connectSiblings;
 10  0
     private final List pages = new ArrayList(1);
 11  0
     private NavigationNode mainPage = null;
 12  0
     private NavigationNode parent = null;
 13  0
     private boolean showLinkToPreviousSibling = false;
 14  
 
 15  
     public PageGroup(final String title) {
 16  0
         this(title, true);
 17  0
     }
 18  
 
 19  0
     public PageGroup(final String title, final boolean connectSiblings) {
 20  0
         this.title = title;
 21  0
         this.connectSiblings = connectSiblings;
 22  0
     }
 23  
 
 24  
     public void add(final NavigationNode page) {
 25  0
         this.pages.add(page);
 26  0
         if (this.mainPage == null) {
 27  0
             this.mainPage = page;
 28  
         }
 29  0
     }
 30  
 
 31  
     public void setParent(final NavigationNode parentPage) {
 32  0
         this.parent = parentPage;
 33  0
     }
 34  
 
 35  
     public void setSiblings(final String siblingsTitle, final List siblingPages) {
 36  0
         throw new UnsupportedOperationException("Cannot set siblings for PageGroup");
 37  0
     }
 38  
 
 39  
     public void setShowLinkToPreviousSibling(final boolean showLink) {
 40  0
         this.showLinkToPreviousSibling = showLink;
 41  0
     }
 42  
 
 43  
     public String getFullTitle() {
 44  0
         return this.title;
 45  0
     }
 46  
 
 47  
     public String getShortTitle() {
 48  0
         return this.title;
 49  
     }
 50  
 
 51  
     public String getURL() {
 52  0
         if (mainPage != null) {
 53  0
             return this.mainPage.getURL();
 54  
         }
 55  
         
 56  0
         new Exception("Dummy Exception please report to bx").printStackTrace();
 57  
         
 58  0
         return "no-page-defined-yet";
 59  
     }
 60  0
 
 61  0
     public void write() {
 62  0
         final Iterator it = this.pages.iterator();
 63  0
         while (it.hasNext()) {
 64  0
             final NavigationNode page = (NavigationNode) it.next();
 65  0
             if (this.showLinkToPreviousSibling) {
 66  0
                 page.setShowLinkToPreviousSibling(this.showLinkToPreviousSibling);
 67  0
             }
 68  0
             if (this.parent != null) {
 69  0
                 page.setParent(this.parent);
 70  0
             }
 71  0
             if (this.connectSiblings) {
 72  0
                 page.setSiblings(this.title, this.pages);
 73  0
             }
 74  0
             page.write();
 75  0
         }
 76  0
         if (this.mainPage != null && !this.pages.contains(this.mainPage)) {
 77  0
             this.mainPage.write();
 78  
         }
 79  0
     }
 80  0
 
 81  0
     public String asLinkList() {
 82  0
         final StringBuffer s = new StringBuffer();
 83  0
         s.append("<ul class=\"linklist\">\n");
 84  0
         final Iterator it = this.pages.iterator();
 85  0
         while (it.hasNext()) {
 86  0
             final NavigationNode page = (NavigationNode) it.next();
 87  0
             s.append("    <li>" + HTML.getLink(page.getURL(), page.getShortTitle()) + "</li>\n");
 88  0
         }
 89  0
         s.append("</ul>");
 90  0
         return s.toString();
 91  
     }
 92  0
 
 93  
     public String asParentLink() {
 94  0
         return this.mainPage.asParentLink();
 95  
     }
 96  
 }