net.sf.tomp.el.author.io
Class AuthorIO

java.lang.Object
  extended by net.sf.tomp.el.author.io.AuthorIO

public class AuthorIO
extends java.lang.Object

Author:
RNDr. Tomáš Pitner, Ph.D.

Constructor Summary
AuthorIO()
           
 
Method Summary
protected  java.lang.String[] listCourseIds(CourseTree tree)
          Browses the tree's directory and gets the IDs (= names of the courses' directories) of the courses.
protected  java.lang.String[] listLectureIds(Lectures lectures)
          Browses the lectures' directories and gets the IDs of the lectures (= names of the lectures' files).
 Course loadCourse(CourseTree tree, java.lang.String id)
          Creates a new instance of Course, adds it to the CourseTree loads the lectures of the course.
 void loadCourses(CourseTree tree)
          Loads all courses in the tree.
 CourseTree loadCourseTree(java.lang.String id)
          Creates a new instance of CourseTree and loads the courses of the CourseTree.
 Lecture loadLecture(Course course, java.lang.String id)
          Loads a lecture of the course
 void loadLectures(Course course)
          Loads lectures for a course.
 void saveCourse(Course course)
          Builds up a new XML document for Course using DOM4J factory and saves it.
 void saveCourses(CourseTree tree)
          Saves all courses in the tree.
 void saveCourseTree(CourseTree tree)
          Saves the CourseTree
 void saveLecture(Lecture lecture)
          Builds up a new XML document for lecture using DOM4J factory and saves it.
 void saveLectures(Course course)
          Saves all lectures of the course.
 void saveTask(Task t)
          Builds up a new XML document for task using DOM4J factory and saves it.
 void write(org.dom4j.Document doc, java.io.File f)
          Writes the XML document (e. g. of a lecture) to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuthorIO

public AuthorIO()
Method Detail

loadCourseTree

public CourseTree loadCourseTree(java.lang.String id)
                          throws java.net.MalformedURLException,
                                 org.dom4j.DocumentException
Creates a new instance of CourseTree and loads the courses of the CourseTree.

Parameters:
id - CourseTree ID
Returns:
Loaded CourseTree
Throws:
java.net.MalformedURLException
org.dom4j.DocumentException

saveCourseTree

public void saveCourseTree(CourseTree tree)
                    throws java.net.MalformedURLException,
                           org.dom4j.DocumentException
Saves the CourseTree

Parameters:
tree - The CourseTree to be saved.
Throws:
java.net.MalformedURLException
org.dom4j.DocumentException

loadCourses

public void loadCourses(CourseTree tree)
                 throws java.net.MalformedURLException,
                        org.dom4j.DocumentException
Loads all courses in the tree.

Parameters:
tree - Courses from this tree will be loaded.
Throws:
java.net.MalformedURLException
org.dom4j.DocumentException

saveCourses

public void saveCourses(CourseTree tree)
                 throws java.io.UnsupportedEncodingException,
                        org.dom4j.DocumentException,
                        java.io.IOException
Saves all courses in the tree.

Parameters:
tree - Courses from this tree will be saved
Throws:
java.io.UnsupportedEncodingException
org.dom4j.DocumentException
java.io.IOException

loadCourse

public Course loadCourse(CourseTree tree,
                         java.lang.String id)
                  throws java.net.MalformedURLException,
                         org.dom4j.DocumentException
Creates a new instance of Course, adds it to the CourseTree loads the lectures of the course.

Parameters:
tree - Tree where the new Course will be loaded.
id - Course ID
Returns:
Loaded Course
Throws:
java.net.MalformedURLException
org.dom4j.DocumentException

saveCourse

public void saveCourse(Course course)
                throws java.io.UnsupportedEncodingException,
                       org.dom4j.DocumentException,
                       java.io.IOException
Builds up a new XML document for Course using DOM4J factory and saves it.

Parameters:
course - This course will be saved.
Throws:
java.io.UnsupportedEncodingException
org.dom4j.DocumentException
java.io.IOException

loadLectures

public void loadLectures(Course course)
                  throws java.net.MalformedURLException,
                         org.dom4j.DocumentException
Loads lectures for a course.

Parameters:
course - Lectures from this course will be loaded.
Throws:
java.net.MalformedURLException
org.dom4j.DocumentException

saveLectures

public void saveLectures(Course course)
                  throws java.io.UnsupportedEncodingException,
                         org.dom4j.DocumentException,
                         java.io.IOException
Saves all lectures of the course.

Parameters:
course - lectures from this course will be saved.
Throws:
java.io.UnsupportedEncodingException
org.dom4j.DocumentException
java.io.IOException

loadLecture

public Lecture loadLecture(Course course,
                           java.lang.String id)
                    throws java.net.MalformedURLException,
                           org.dom4j.DocumentException
Loads a lecture of the course

Parameters:
course - Lectures from this course will be loaded.
id - Lecture ID
Returns:
Lecture
Throws:
java.net.MalformedURLException
org.dom4j.DocumentException

saveLecture

public void saveLecture(Lecture lecture)
                 throws java.io.UnsupportedEncodingException,
                        org.dom4j.DocumentException,
                        java.io.IOException
Builds up a new XML document for lecture using DOM4J factory and saves it.

Parameters:
lecture - This lecture will be saved.
Throws:
java.io.UnsupportedEncodingException
org.dom4j.DocumentException
java.io.IOException

saveTask

public void saveTask(Task t)
              throws java.io.UnsupportedEncodingException,
                     org.dom4j.DocumentException,
                     java.io.IOException
Builds up a new XML document for task using DOM4J factory and saves it.

Parameters:
t - This task will be saved.
Throws:
java.io.UnsupportedEncodingException
org.dom4j.DocumentException
java.io.IOException

listCourseIds

protected java.lang.String[] listCourseIds(CourseTree tree)
Browses the tree's directory and gets the IDs (= names of the courses' directories) of the courses.

Parameters:
tree - This tree (courses' directories) will be browsed.
Returns:
IDs of the courses

listLectureIds

protected java.lang.String[] listLectureIds(Lectures lectures)
Browses the lectures' directories and gets the IDs of the lectures (= names of the lectures' files).

Parameters:
lectures - This lectures will be browsed.
Returns:
IDs of the lectures

write

public void write(org.dom4j.Document doc,
                  java.io.File f)
           throws org.dom4j.DocumentException,
                  java.io.UnsupportedEncodingException,
                  java.io.IOException
Writes the XML document (e. g. of a lecture) to a file.

Parameters:
doc - The generated XML document which will be saved.
f - The names of the file to save do XML document to.
Throws:
org.dom4j.DocumentException
java.io.UnsupportedEncodingException
java.io.IOException