|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectimageorg.ImageOrganizer
public abstract class ImageOrganizer
ImageOrganizer
is the main interface to the image organization
library. It is used to obtain and manipulate FileElement
s that
represent disk-based folders and images. ImageOrganizer
is
an abstract class that declares various abstract methods that
a concrete implementation should provide. You should subclass
ImageOrganizer
and provide your own implementation for the
abstract methods. IMPORTANT: There is one method that you need to provide an
implementation for in this class. The static factory method create() should
return an object which is your concrete subclass of ImageOrganizer
.
This is the only case where you will have to directly change code in the
imageorg
package.
ImageOrganizer
provides a single protected
constant
REPOSITORY_HOME
defining the on disk root (or home) directory that will
contain all images and folders maintained by the ImageOrganizer
library. The getHome()
method will return a concrete implementation
of the Folder
interface that encapsulates the home directory.
Users of the ImageOrganizer library will maniplulate images and folders using
methods defined in the FileElement
, Folder
and
Image
interfaces.
Field Summary | |
---|---|
protected static java.io.File |
REPOSITORY_HOME
Constant that defines the platform independent on disk path to the ImageOrganizer home directory. |
Constructor Summary | |
---|---|
ImageOrganizer()
|
Method Summary | |
---|---|
static ImageOrganizer |
create()
Factory method that returns a concrete subclass of ImageOrganizer . |
abstract Annotation |
createAnnotation(java.lang.String annotationKey)
This method is a factory method that will return a concrete implementation of the Annotation interface. |
abstract Folder |
getHome()
Returns a concrete implementation of the Folder interface that
encapsulates the home (or root) directory of the ImageOrganizer file hierarchy. |
abstract boolean |
importFrom(java.io.File source,
Folder destination)
Imports image(s) from the supplied source File to the supplied
destination Folder . |
abstract void |
save()
Save any internal data structures to disk. |
abstract java.util.Collection<FileElement> |
search(java.lang.String searchText,
Folder root)
Searches for occurrences of the substring searchText in
FileElement s contained in the Folder root (
including root itself). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.io.File REPOSITORY_HOME
Constructor Detail |
---|
public ImageOrganizer()
Method Detail |
---|
public static ImageOrganizer create()
ImageOrganizer
.
Fill in code here to return an object that provides implementations
of the abstract methods in this class.return new implementation.MyFunkyImageOrganizer();
ImageOrganizer
public abstract Folder getHome() throws java.lang.Exception
Folder
interface that
encapsulates the home (or root) directory of the ImageOrganizer file hierarchy.
The on disk home directory is defined by the constant REPOSITORY_HOME
above.
This method must be robust. That is, if the home directory does not exist the
method should create it on disk and then return a Folder
encapsulating
it.
Folder
representing the root of the ImageOrganizer file
hierarchy.
java.lang.Exception
- if the home Folder
can't be obtained.public abstract boolean importFrom(java.io.File source, Folder destination) throws java.lang.Exception
File
to the supplied
destination Folder
. source images are copied to
the destination. If the source File
is a directory, then the
contents of the directory are to be copied to the destination Folder
preserving the original hierarchical structure.
E.g. If the source looks like:
/home/mhall/marksImages/ | |-- landscape1.jpg |-- beach.gif |-- Cars/ | |-- astonMartin.gif
Then a call toimportFrom
wheresource = /home/mhall/marksImages
anddestination = getHome()
would result in:
/home/mhall/image_org_home/ | |-- marksImages/ | |-- landscape.jpg |-- beach.gif |-- Cars/ | |-- astonMartin.gif
IMPORTANT: This method should not import anything that is not an image (gif or
jpeg) or folder. You can make use of a static utility function called
loadImage()
in the imageviewer.ImageViewer
class
to load images. This method returns null if a file can't
be decoded as an image (gif or jpeg).
(Postcondition: contents of source are copied to destination)
source
- the file or directory to import.
destination
- the Folder
to import to.
java.lang.Exception
- if an error occurs during the import.public abstract java.util.Collection<FileElement> search(java.lang.String searchText, Folder root)
searchText
in
FileElement
s contained in the Folder root
(
including root
itself). FileElements that are sub-folders should
have their contents searched in a recursive fashion. Names (as returned by a call to
getName()
on a FileElement
) as well as
any Annotation
s (annotation keys and values) are to be
checked for occurrences of the searchText
. A Collection
of FileElement
s that match are to be returned. The returned
Collection
must be non-null and can be empty (i.e. size 0) to
indicate that no matches were found.
(Postcondition: a non-null (but possibly empty) Collection
of
matching FileElements
is returned)
searchText
- the substring to search for.
root
- the Folder
at which to begin searching (this folder itself
is also checked to see if it is a match).
Collection
of FileElements that match the search criteriapublic abstract void save() throws java.lang.Exception
REPOSITORY_HOME
),
instead they should be saved to a single file called
.imageorg
in the User's "home" directory. A call to
System.getProperties().getProperty("user.home")
can be used to obtain the path to the User's "home" directory in a
platform independent manner.
Maintaining an internal representation of the on disk folder hierarchy is
necessary for associating Annotation
s with individual
FileElement
s. Since the ImageOrganizer's on disk folder hierarchy
should contain only directories and images, you shouldn't save annotation data
to separate individual files in the on-disk folder hierarchy.
You can assume that clients will call this save()
method after they
are finished using the ImageOrganizer library.
java.lang.Exception
- if an error occurs during saving.public abstract Annotation createAnnotation(java.lang.String annotationKey)
Annotation
interface. Its operation is similar to
that of the create()
method above. The primary difference is that
this method is non-static, which means that the implementation
will go in your concrete sub-class of ImageOrganizer
.
annotationKey
- the key value to use when creating a new
Annotation
(see docs for the Annotation
interface.
Annotation
interface.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |