public class BookmarkStore extends Object
Bookmark
s.
This implementation uses a DefaultOutline
to store the bookmarks. It uses the outline
type Outlines.TYPE_CUSTOM_OUTLINE
.
Note
Another possible way of implementing such a store is to extend Outline
directly.
Constructor and Description |
---|
BookmarkStore() |
Modifier and Type | Method and Description |
---|---|
void |
addBookmark(Bookmark bookmark)
Adds the given
Bookmark to this store. |
void |
addBookmarkStoreListener(BookmarkStoreListener listener) |
Bookmark |
createBookmark(Document document,
Page page,
String description,
PageView pageView)
Creates a new
Bookmark for the given parameters. |
List<Bookmark> |
getBookmarks()
Returns a list of all
Bookmark s this store is holding. |
List<Bookmark> |
getBookmarks(Document doc)
Returns an unmodifiable list of the
Bookmark s for this document. |
List<Bookmark> |
getBookmarks(Page p)
Returns an unmodifiable list of the bookmarks for the given
Page . |
boolean |
hasBookmark(Document doc)
|
boolean |
hasBookmark(Page p)
|
boolean |
isBookmarksModified()
Returns the "bookmarks modified" flag.
|
void |
removeBookmark(Bookmark bookmark)
Removes the given
Bookmark from this store. |
void |
removeBookmarkStoreListener(BookmarkStoreListener listener) |
void |
setBookmarksModified(boolean modified)
Sets the modified flag to the given value.
|
public boolean isBookmarksModified()
Note
This demo will set the modified flag when adding/removing bookmarks. The flag will not be reset
at any point, so a bookmark store can be assumed to have the flag set to true if it contains
bookmarks. Other implementations might sync the state of the store to some external data source
and reset the flag accordingly.
public void setBookmarksModified(boolean modified)
modified
- the flagpublic void addBookmark(Bookmark bookmark)
Bookmark
to this store.bookmark
- the bookmark to addpublic void removeBookmark(Bookmark bookmark)
Bookmark
from this store.bookmark
- the bookmark to removepublic List<Bookmark> getBookmarks()
Bookmark
s this store is holding.public List<Bookmark> getBookmarks(Page p)
Page
.
Note
This method is not optimized for performance and will traverse the complete outline to retrieve
all bookmarks which correspond to the given page. Other implementations might use an other way
to find the bookmarks or use some type of caching to speed up finding the bookmarks.
p
- the pagepublic boolean hasBookmark(Document doc)
Document
has a Bookmark
on it.
Implementation note: The check is not optimized for performance. This method will simply check
if getBookmarks(Document)
has a size > 0.
doc
- the documentpublic boolean hasBookmark(Page p)
Page
has a Bookmark
on it.
Implementation note: The check is not optimized for performance. This method will simply check
if getBookmarks(Page)
has a size > 0.
p
- the pagepublic List<Bookmark> getBookmarks(Document doc)
Bookmark
s for this document.
To add/remove bookmarks, use the appropriate methods (addBookmark(Bookmark)
/
removeBookmark(Bookmark)
).
Note
This method is not optimized for performance and will traverse the complete outline to find
bookmarks matching the given document. Other implementations might use an other way to find the
bookmarks or use some type of caching to speed up finding the bookmarks.
doc
- the documentpublic void addBookmarkStoreListener(BookmarkStoreListener listener)
public void removeBookmarkStoreListener(BookmarkStoreListener listener)
public Bookmark createBookmark(Document document, Page page, String description, PageView pageView)
Bookmark
for the given parameters.
Note
The created Bookmark will not be added to this store automatically. Use
addBookmark(Bookmark)
to add the bookmark to this store.
document
- the document the bookmark is belonging topage
- the corresponding pagedescription
- the description of the bookmarkpageView
- the pageViewCopyright © 2024 levigo holding gmbh. All rights reserved.