public class Bookmarks extends Object
For the time being, this is a hack, there needs to be a more generic API to this to allow adding/removing bookmarks and pulling from different sources other than just Netscape. But for this example, this is plenty good.
While a hack, this is interesting in that it shows how you can use the parser provided in the javax.swing.text.html.parser package outside of the HTML package. The netscape format is a pseudo HTML file, pseudo in that there is no head/body. All the bookmarks are presented as DT's in a DL and the name of the directory is a DT. An instance of the parser is created, a callback is registered, and as the parser parses the file, nodes of the correct type are created.
| Modifier and Type | Class and Description |
|---|---|
static class |
Bookmarks.BookmarkDirectory
BookmarkDirectory represents a directory containing other
BookmarkDirectory's as well as BookmarkEntry's.
|
static class |
Bookmarks.BookmarkEntry
BookmarkEntry represents a bookmark.
|
| Constructor and Description |
|---|
Bookmarks(String path)
Creates a new Bookmarks object, with the entries coming from
path. |
| Modifier and Type | Method and Description |
|---|---|
Bookmarks.BookmarkDirectory |
getRoot()
Returns the root of the bookmarks.
|
protected void |
parse(String path)
Adds the bookmarks in the file at
path to the current root. |
public Bookmarks(String path)
path.public Bookmarks.BookmarkDirectory getRoot()
protected void parse(String path)
path to the current root.
This creates a ParserDelegator and uses a CallbackHandler to do the
parser.Copyright © 2021. All rights reserved.