1 /*** 2 * Page.java 3 * 4 * $Author: mballesteros $ 5 * $Date: 2003/11/28 19:18:03 $ 6 * $Revision: 1.1 $ 7 */ 8 package net.sf.jec; 9 10 import java.util.*; 11 12 /*** 13 * 14 * @author mballesteros 15 */ 16 public class Page { 17 18 /*** Holds value of property text. */ 19 protected String text; 20 21 /*** Holds value of property wordCount. */ 22 protected int wordCount; 23 24 /*** Holds value of property book. */ 25 protected Book book; 26 27 protected List paragraphs; 28 29 /*** Holds value of property creationDate. */ 30 protected java.util.Date creationDate; 31 32 public String toString() { 33 return getText(); 34 } 35 36 /*** Creates a new instance of Page */ 37 public Page(Book book) { 38 this.book = book; 39 this.paragraphs = new ArrayList(); 40 this.creationDate = new java.util.Date(); 41 } 42 43 /*** Getter for property text. 44 * @return Value of property text. 45 */ 46 public String getText() { 47 return this.text; 48 } 49 50 /*** Getter for property wordCount. 51 * @return Value of property wordCount. 52 */ 53 public int getWordCount() { 54 return this.wordCount; 55 } 56 57 /*** Getter for property book. 58 * @return Value of property book. 59 */ 60 public Book getBook() { 61 return this.book; 62 } 63 64 /*** Getter for property creationDate. 65 * @return Value of property creationDate. 66 */ 67 public java.util.Date getCreationDate() { 68 return this.creationDate; 69 } 70 71 /*** 72 */ 73 public Paragraph newParagraph(String text) { 74 Paragraph par = new Paragraph(this, text); 75 this.paragraphs.add(par); 76 recalculate(); 77 return par; 78 } 79 80 private void recalculate() { 81 this.wordCount = 0; 82 StringBuffer sb = new StringBuffer(); 83 Iterator it = this.paragraphs.iterator(); 84 while (it.hasNext()) { 85 Paragraph p = (Paragraph)it.next(); 86 sb.append(p.getText()).append('\n'); 87 wordCount += p.getWordCount(); 88 } 89 this.text = sb.toString(); 90 } 91 92 /*** Getter for property paragraphs. 93 * @return Value of property paragraphs. 94 */ 95 public java.util.List getParagraphs() { 96 return paragraphs; 97 } 98 99 /*** 100 * Method setBook. 101 * @param extendedBook 102 */ 103 public void setBook(Book book) { 104 this.book = book; 105 } 106 107 }

This page was automatically generated by Maven