|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.mucommander.bookmark.BookmarkManager
public class BookmarkManager
This class manages the boomark list and its parsing and storage as an XML file.
It monitors any changes made to the bookmarks and when changes are made, fires change events to registered listeners.
| Method Summary | |
|---|---|
static void |
addBookmark(Bookmark b)
Convenience method that adds a bookmark to the bookmark list. |
static void |
addBookmarkListener(BookmarkListener listener)
Adds the specified BookmarkListener to the list of registered listeners. |
static void |
buildBookmarks(BookmarkBuilder builder)
Passes messages about all known bookmarks to the specified builder. |
void |
elementChanged(int index)
This method is called when an element has been changed in the AlteredVector. |
void |
elementsAdded(int startIndex,
int nbAdded)
This method is called when one or more elements has been added to the AlteredVector. |
void |
elementsRemoved(int startIndex,
int nbRemoved)
This method is called when one or more elements has been removed from the AlteredVector. |
static void |
fireBookmarksChanged()
Notifies all the registered bookmark listeners of a bookmark change. |
static Bookmark |
getBookmark(java.lang.String name)
Convenience method that looks for a Bookmark with the given name (case ignored) and returns it, or null if none was found. |
static AlteredVector |
getBookmarks()
Returns an AlteredVector that contains all bookmarks. |
static AbstractFile |
getBookmarksFile()
Returns the path to the bookmark file. |
static BookmarkBuilder |
getBookmarkWriter(java.io.OutputStream out)
Returns a BookmarkBuilder that will write all building messages as XML to the specified output stream. |
static void |
loadBookmarks()
Loads all available bookmarks. |
static void |
readBookmarks(java.io.InputStream in)
Reads bookmarks from the specified InputStream. |
static void |
readBookmarks(java.io.InputStream in,
BookmarkBuilder builder)
Reads bookmarks from the specified InputStream and passes messages to the specified BookmarkBuilder. |
static void |
removeBookmark(Bookmark bookmark)
Deletes the specified bookmark. |
static void |
removeBookmarkListener(BookmarkListener listener)
Removes the specified BookmarkListener from the list of registered listeners. |
static void |
setBookmarksFile(AbstractFile file)
Sets the path to the bookmarks file. |
static void |
setBookmarksFile(java.io.File file)
Sets the path to the bookmarks file. |
static void |
setBookmarksFile(java.lang.String path)
Sets the path to the bookmarks file. |
static void |
setFireEvents(boolean b)
Specifies whether bookmark events should be fired when a change in the bookmarks is detected. |
static void |
writeBookmarks(boolean forceWrite)
Writes all known bookmarks to the bookmark file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void buildBookmarks(BookmarkBuilder builder)
throws BookmarkException
builder - where to send bookmark building messages.
BookmarkException - if an error occurs.
public static AbstractFile getBookmarksFile()
throws java.io.IOException
If it hasn't been changed through a call to setBookmarksFile(String),
this method will return the default, system dependant bookmarks file.
java.io.IOException - if there was a problem locating the default bookmarks file.setBookmarksFile(String)
public static void setBookmarksFile(java.lang.String path)
throws java.io.FileNotFoundException
This is a convenience method and is strictly equivalent to calling setBookmarksFile(FileFactory.getFile(file)).
path - path to the bookmarks file
java.io.FileNotFoundException - if path is not accessible.getBookmarksFile()
public static void setBookmarksFile(java.io.File file)
throws java.io.FileNotFoundException
This is a convenience method and is strictly equivalent to calling setBookmarksFile(FileFactory.getFile(file.getAbsolutePath())).
file - path to the bookmarks file
java.io.FileNotFoundException - if path is not accessible.getBookmarksFile()
public static void setBookmarksFile(AbstractFile file)
throws java.io.FileNotFoundException
file - path to the bookmarks file
java.io.FileNotFoundException - if path is not accessible.getBookmarksFile()
public static void loadBookmarks()
throws java.lang.Exception
java.lang.Exception - if an error occurs.
public static void readBookmarks(java.io.InputStream in)
throws java.lang.Exception
InputStream.
in - where to read bookmarks from.
java.lang.Exception - if an error occurs.
public static void readBookmarks(java.io.InputStream in,
BookmarkBuilder builder)
throws java.lang.Exception
InputStream and passes messages to the specified BookmarkBuilder.
in - where to read bookmarks from.builder - where to send builing messages to.
java.lang.Exception - if an error occurs.
public static BookmarkBuilder getBookmarkWriter(java.io.OutputStream out)
throws java.io.IOException
BookmarkBuilder that will write all building messages as XML to the specified output stream.
out - where to write the bookmarks' XML content.
BookmarkBuilder that will write all building messages as XML to the specified output stream.
java.io.IOException - if an IO related error occurs.
public static void writeBookmarks(boolean forceWrite)
throws java.io.IOException,
BookmarkException
file.
forceWrite - if false, the bookmarks file will be written only if changes were made to bookmarks since
last write, if true the file will always be written
java.io.IOException - if an I/O error occurs.
BookmarkException - if an error occurs.public static AlteredVector getBookmarks()
AlteredVector that contains all bookmarks.
Important: the returned Vector should not directly be used to add or remove bookmarks, doing so won't trigger any event to registered bookmark listeners. However, it is safe to modify bookmarks individually, events will be properly fired.
AlteredVector that contains all bookmarks.public static void removeBookmark(Bookmark bookmark)
bookmark - bookmark to delete from the list.public static Bookmark getBookmark(java.lang.String name)
name - the bookmark's name
public static void addBookmark(Bookmark b)
b - the Bookmark instance to add to the bookmark list.public static void addBookmarkListener(BookmarkListener listener)
Listeners are stored as weak references so removeBookmarkListener(BookmarkListener)
doesn't need to be called for listeners to be garbage collected when they're not used anymore.
listener - the BookmarkListener to add to the list of registered listeners.removeBookmarkListener(BookmarkListener)public static void removeBookmarkListener(BookmarkListener listener)
listener - the BookmarkListener to remove from the list of registered listeners.addBookmarkListener(BookmarkListener)public static void fireBookmarksChanged()
public static void setFireEvents(boolean b)
If true is speicified, any subsequent calls to fireBookmarksChanged will be ignored, until this method is called again with false.
b - whether to fire events.
public void elementsAdded(int startIndex,
int nbAdded)
VectorChangeListener
elementsAdded in interface VectorChangeListenerstartIndex - index at which the first element has been addednbAdded - number of elements added
public void elementsRemoved(int startIndex,
int nbRemoved)
VectorChangeListener
elementsRemoved in interface VectorChangeListenerstartIndex - index at which the first element has been removednbRemoved - number of elements removedpublic void elementChanged(int index)
VectorChangeListener
elementChanged in interface VectorChangeListenerindex - index of the element that has been changed
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard