|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.pavlov.library.LibraryDocument net.sourceforge.pavlov.library.Book
public final class Book
Describes a Book, which is a collection of Chapters.
Library
,
Chapter
,
Question
,
Serialized FormField Summary |
---|
Fields inherited from class net.sourceforge.pavlov.library.LibraryDocument |
---|
author, description, name |
Constructor Summary | |
---|---|
Book()
Create an unnamed, empty book. |
|
Book(String name)
|
Method Summary | |
---|---|
void |
addChapter(Chapter chapter)
Adds the named chapter, keyed on Chapter.getName(). |
int |
compareTo(Object obj)
|
Book |
deepCopy()
Uses a neat trick from "Design Patterns in Java" to make a completely independent copy of this book. |
void |
deleteChapter(String cpName)
Deletes the named chapter |
boolean |
equals(Object obj)
Returns true if this book equals the given book. |
protected String |
getBaseFileName()
Creates a cannonical filename for this book, lowercasing it and URLEncoding it. |
Chapter |
getChapter(String cpName)
Returns the named chapter, or null if it doesn't exist |
TreeMap<String,AbstractChapter> |
getChapters()
Returns a hashtable of all my chapters. |
Collection<AbstractChapter> |
getChaptersReadOnly()
Returns the book's chapters as a read-only collection. |
String |
getCover()
Returns filename of a descriptive image of this book. |
int |
getNumberOfChapters()
Returns the number of chapters I have. |
int |
getNumberOfQuestions()
Sums the number of questions of all my chapters and returns the total. |
String |
getTitle()
Deprecated. use getName() instead. |
Collection<AbstractChapter> |
getValues()
Returns the book's chapters as a collection. |
static Book |
loadFrom(File bookFile)
|
static Book |
loadFrom(String filename)
|
static Book |
makeBlankBook()
Creates an unnamed book with one unnamed chapter, which has one blank question. |
void |
populateTree(DefaultMutableTreeNode bk)
Displays chapters as a tree. |
void |
save(File directory)
Saves the book in the given directory, using the book's cannonical filename. |
void |
saveAs(File file)
Saves the book to the given file. |
void |
setCover(String n)
Sets filename of a descriptive image of this book. |
String |
toString()
Returns the book's name |
void |
toXML(Writer writer)
Dumps the Book in XML format to the given writer. |
Methods inherited from class net.sourceforge.pavlov.library.LibraryDocument |
---|
getAuthor, getDescription, getName, setAuthor, setDescription, setName |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sourceforge.pavlov.library.AbstractBook |
---|
getAuthor, getDescription, getName |
Constructor Detail |
---|
public Book()
public Book(String name)
Method Detail |
---|
public int compareTo(Object obj)
compareTo
in interface Comparable
public static Book makeBlankBook()
Book
valuepublic void setCover(String n)
n
- a String
valuepublic String getCover()
getCover
in interface AbstractBook
String
value@Deprecated public String getTitle()
getTitle
method here.
getTitle
in interface AbstractBook
String
valuepublic void addChapter(Chapter chapter)
b
- a Chapter
valuepublic void deleteChapter(String cpName)
cpName
- a String
valuepublic Chapter getChapter(String cpName)
getChapter
in interface AbstractBook
cpName
- a String
value
Chapter
valuepublic int getNumberOfQuestions()
getNumberOfQuestions
in interface AbstractBook
int
valuepublic void toXML(Writer writer) throws IOException
toXML
in interface AbstractBook
writer
- a java.io.Writer
value
IOException
- if an error occurspublic void save(File directory) throws IOException
save
in interface AbstractBook
directory
- a File
value
IOException
public void saveAs(File file) throws IOException
file
- a File
value
IOException
public static Book loadFrom(String filename)
public static Book loadFrom(File bookFile)
protected String getBaseFileName()
String
valuepublic void populateTree(DefaultMutableTreeNode bk)
populateTree
in interface AbstractBook
bk
- a DefaultMutableTreeNode
valuepublic TreeMap<String,AbstractChapter> getChapters()
Hashtable
valuepublic int getNumberOfChapters()
int
valuepublic String toString()
toString
in interface AbstractBook
toString
in class Object
String
valuepublic Collection<AbstractChapter> getValues()
getValues
in interface AbstractBook
Collection
valuepublic Collection<AbstractChapter> getChaptersReadOnly()
getChaptersReadOnly
in interface AbstractBook
Collection
valuepublic boolean equals(Object obj)
equals
in class Object
obj
- an Object
value
boolean
valuepublic Book deepCopy()
Book
value
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |