|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rakeshv.xml.album.PhotoAlbum
public class PhotoAlbum
Photo album implementation. This class presents a java view of the specified album xml file. This class also contains methods for creating new album entries, and for deleted existing entries.
You can use the createPhotoAlbum( String ) method to
create a new photo album specified by the fully
qualified file name specified in the method call.
© Copyright 2003 Rakesh Vidyadharan
| Field Summary | |
|---|---|
private java.util.Map |
albums
The map of Album records. |
private org.jdom.Document |
document
A reference to the album XML document. |
private java.lang.String |
fileName
The fully qualified name of the album XML file. |
private org.jdom.Namespace |
namespace
The namespace for the root element. |
private org.jdom.Element |
rootElement
The root element of the XML file. |
| Constructor Summary | |
|---|---|
protected |
PhotoAlbum()
Default constructor. |
|
PhotoAlbum(java.lang.String fileName)
Just invoke PhotoAlbum( String, String ) with a value of
null for the preferred SAX Parser to use. |
|
PhotoAlbum(java.lang.String fileName,
java.lang.String saxParser)
Load the specified album XML file using the specified SAX Parser. |
| Method Summary | |
|---|---|
void |
addAlbum(Album album)
Add the specified Album java bean to the albums
map. |
private void |
addAlbumToTree(Album album)
Add the specified Album object to the JDOM tree as a
album element. |
private void |
addImageToTree(org.jdom.Element element,
java.lang.String name,
Image image)
Add the specified Image object to the specified element
as an element with the name specified. |
private void |
addPhotoToTree(org.jdom.Element element,
Album album)
Add all the Photo beans in the Album specified
to the Element passed in. |
static PhotoAlbum |
createPhotoAlbum(java.lang.String file)
Just invokes createPhotoAlbum( String, String ) with a
null value for the default SAX Parser. |
static PhotoAlbum |
createPhotoAlbum(java.lang.String file,
java.lang.String saxParser)
Create a new album using the fully qualified file name specified, and using the specified SAX Parser to load the XML file that has been created. |
boolean |
deleteAlbum(java.lang.String name)
Remove the Album identified by the specified Album.name. |
boolean |
deleteAlbums(java.lang.String[] names)
Remove the Album's identified by the specified Album.names. |
java.util.Map |
getAlbums()
Return the value/reference of the albums. |
java.lang.String |
getFileName()
Returns fileName. |
private void |
loadAlbums(java.lang.String saxParser)
Load the album XML file ( fileName) using JDOM,
and populate the albums class field. |
void |
modifyAlbum(Album album)
Save the specified Album java bean that has been modified
to the underlying JDOM tree. |
private Album |
populateAlbum(org.jdom.Element element)
Walk through the child elements of the specified album
element, and create a corresponding Album bean. |
private void |
populateAlbums()
Walk through the JDOM tree, and populate the albums
Map of Album objects. |
private Image |
populateImage(org.jdom.Element element)
Return a Image java bean with the data from the specified
Element of type image. |
private Photo |
populatePhoto(org.jdom.Element element)
Create a Photo java bean instance with all the data
from the specified photo element. |
void |
saveAlbums()
Write the JDOM tree back to the album file. |
void |
setFileName(java.lang.String fileName)
Set fileName. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.lang.String fileName
private java.util.Map albums
map of Album records. This corresponds
to all the album elements under the
albums element in the photo album. The map is
populated using the Album.name as the key.
private org.jdom.Document document
private org.jdom.Element rootElement
root element of the XML file.
private org.jdom.Namespace namespace
namespace for the root element.
| Constructor Detail |
|---|
protected PhotoAlbum()
public PhotoAlbum(java.lang.String fileName)
throws AlbumException
PhotoAlbum( String, String ) with a value of
null for the preferred SAX Parser to use.
fileName - - The fully qualified name of the photo
album XML file.
AlbumException - - If any JDOM/IOExceptions are encountered
while processing the album XML file.
public PhotoAlbum(java.lang.String fileName,
java.lang.String saxParser)
throws AlbumException
fileName - - The fully qualified name of the photo
album XML file.saxParser - - The full class name of the preferred
SAX Parser to use.
AlbumException - - If any JDOM/IOExceptions are encountered
while processing the album XML file.loadAlbums( String )| Method Detail |
|---|
private void loadAlbums(java.lang.String saxParser)
throws AlbumException
fileName) using JDOM,
and populate the albums class field.
saxParser - - The full class name of the SAX Parser
to use. If this is null the default JAXP SAX
Parser will be used.
AlbumException - - If any JDOM/IOExceptions are encountered
while processing the album XML file.populateAlbums()private void populateAlbums()
albums
Map of Album objects. Fetches all the
children of the rootElement root
Element in the album XML file.
populateAlbum( Element )private Album populateAlbum(org.jdom.Element element)
album
element, and create a corresponding Album bean.
element - - The current album element.
populatePhoto( Element )private Photo populatePhoto(org.jdom.Element element)
Photo java bean instance with all the data
from the specified photo element.
element - - The current photo element.
populateImage( Element )private Image populateImage(org.jdom.Element element)
Image java bean with the data from the specified
Element of type image.
element - - The current image element.
public void addAlbum(Album album)
throws AlbumException
Album java bean to the albums
map. This method checks to make sure that an entry with the same
Album.name does not exist in the albums
Map. The specified Album object is added
both to the albums Map, as well as to the
JDOM tree.
Note:This method does not write the modified JDOM tree
back to the album file. To save your modifications, please
use the saveAlbums() method.
album - - The java bean with all the information
pertaining to a album entry in the photo album.
AlbumException - - If the specified Album has an
identical Album.name as an existing entry in the
albums Map.addAlbumToTree( Album )public void modifyAlbum(Album album)
Album java bean that has been modified
to the underlying JDOM tree. The easiest way to do this is to
remove the existing album element, and add the
modified Album bean as a new child element of the
albums element using addAlbumToTree( Album ).
Note:This method does not write the modified JDOM tree
back to the album file. To save your modifications, please
use the saveAlbums() method.
album - - The java bean with all the information
pertaining to a album entry in the album.addAlbumToTree( Album )private void addAlbumToTree(Album album)
Album object to the JDOM tree as a
album element.
Note:This method does not write the modified JDOM tree
back to the album file. To save your modifications, please
use the saveAlbums() method.
album - - The java bean with all the information
pertaining to a album entry in the album.
private void addPhotoToTree(org.jdom.Element element,
Album album)
Photo beans in the Album specified
to the Element passed in. Walk through the Album.photos map and add each instance to the
XML tree.
element - - The XML element to which the photos are
to be added.album - - The album instance from which the photos
are to be added.
private void addImageToTree(org.jdom.Element element,
java.lang.String name,
Image image)
Image object to the specified element
as an element with the name specified.
element - - The parent element to which the image
element is to be added.name - - The name to use for the image element that
will be added to the parent.image - - The image java bean to be used to populate
the image element children.public boolean deleteAlbums(java.lang.String[] names)
Album's identified by the specified Album.names. This method removes the Album's from
the albums Map as well as the appropriate
element from the underlying JDOM tree. This method
just iterates through the array, and invokes deleteAlbum( String ) to delete each Album specified.
names - - The names of the album that are to
be removed.
true if the name exists
in the albums Map, and false
otherwise. A return value of false indicates that
not all the specified albums could be deleted, as not all of
them were valid.public boolean deleteAlbum(java.lang.String name)
Album identified by the specified Album.name. This method removes the Album from
the albums Map as well as the appropriate
element from the underlying JDOM tree.
name - - The name of the album that is to be removed.
true if the name exists
in the albums Map, and false
otherwise.
public void saveAlbums()
throws AlbumException
AlbumException - - If any exceptions are encountered while
serialising the JDOM tree to the album file.
public static PhotoAlbum createPhotoAlbum(java.lang.String file)
throws AlbumException
createPhotoAlbum( String, String ) with a
null value for the default SAX Parser.
file - - The fully qualified name of the file ie. the
full path and name of file to use as the album.
AlbumException - - If any exceptions are encountered while
creating or writing to the specified file.
public static PhotoAlbum createPhotoAlbum(java.lang.String file,
java.lang.String saxParser)
throws AlbumException
file - - The fully qualified name of the file ie. the
full path and name of file to use as the album.saxParser - - The full class name of the preferred
SAX Parser. If this is null the default JAXP
SAX Parser will be used.
AlbumException - - If any exceptions are encountered while
creating or writing to the specified file.public final java.util.Map getAlbums()
albums.
public final java.lang.String getFileName()
fileName.
public final void setFileName(java.lang.String fileName)
fileName.
fileName - - The value to set.
|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||