net.sourceforge.java.feednread.backend.importer
Class OPMLImport

java.lang.Object
  extended bynet.sourceforge.java.feednread.backend.importer.OPMLImport
Direct Known Subclasses:
NewsFeedFavoritesTreeOPMLImport

public class OPMLImport
extends Object

Imports a valid OPML 1.0 or 1.1 File into an arbitrary Category. The OPML version is automatically detected in order to adjust parsing towards version specific guidelines.

Author:
Sebastian Machhausen
See Also:
NewsFeedFavoritesTreeOPMLExport

Field Summary
private  String creationDate
           The creation date of the parsed OPML Document
private static String OPML_VERSION_1_0
           The OPML 1.0 import version
private static String OPML_VERSION_1_1
           The OPML 1.1 import version
private  Category targetCategory
           The Category to import into
private  String title
           The title of the parsed OPML Document
 
Constructor Summary
OPMLImport(Category targetCategory)
           Creates a new OPMLImport bound to the specified Category.
 
Method Summary
 void doImport(String fileName)
           Imports the OPML Document from the File with the specified fileName.
 String getCreationDate()
           Gets the creation date of the imported OPML Document as defined in the OPML head section.
 String getTitle()
           Gets the title of the imported OPML Document as defined in the OPML head section.
protected  void importCategory(Element outline, Category parent)
           Recursively imports the specified outline Element into the the specified Category.
protected  void importFavorite(Element outline, Category parent)
           Imports the specified outline Element as Favorite into the specified parent Category.
protected  boolean isCategory(Element outline)
           Verifies if the specified outline Element represents a Category.
private  void parseBody(Element root)
           Parses the OPML body section.
protected  void parseDocument(Document doc)
           Parses the OPML Document.
private  void parseHead(Element root)
           Parses the OPML head section.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPML_VERSION_1_0

private static final String OPML_VERSION_1_0

The OPML 1.0 import version

See Also:
Constant Field Values

OPML_VERSION_1_1

private static final String OPML_VERSION_1_1

The OPML 1.1 import version

See Also:
Constant Field Values

targetCategory

private Category targetCategory

The Category to import into


title

private String title

The title of the parsed OPML Document


creationDate

private String creationDate

The creation date of the parsed OPML Document

Constructor Detail

OPMLImport

public OPMLImport(Category targetCategory)

Creates a new OPMLImport bound to the specified Category.

Parameters:
targetCategory - the Category to import into
Method Detail

doImport

public void doImport(String fileName)
              throws JDOMException,
                     IOException

Imports the OPML Document from the File with the specified fileName.

Parameters:
fileName - the name of the file to import from
Throws:
IOException - if the import failed due to an IO error
JDOMException

getTitle

public String getTitle()

Gets the title of the imported OPML Document as defined in the OPML head section.

Returns:
the title of the imported OPML Document as defined in the OPML head section; null if no title was set or found

getCreationDate

public String getCreationDate()

Gets the creation date of the imported OPML Document as defined in the OPML head section.

Returns:
the creation date of the imported OPML Document as defined in the OPML head section; null if not set or found

isCategory

protected boolean isCategory(Element outline)

Verifies if the specified outline Element represents a Category.

Parameters:
outline - the outline Element to verify
Returns:
true if the specified outline Element represents a Category; false otherwise

parseDocument

protected void parseDocument(Document doc)
                      throws JDOMException

Parses the OPML Document.

Parameters:
doc - the OPML Document to parse
Throws:
JDOMException

parseHead

private void parseHead(Element root)
                throws JDOMException

Parses the OPML head section.

Parameters:
root - the root of the OPML Document
Throws:
JDOMException

parseBody

private void parseBody(Element root)
                throws JDOMException

Parses the OPML body section.

Parameters:
root - the root of the OPML Document
Throws:
JDOMException

importCategory

protected void importCategory(Element outline,
                              Category parent)

Recursively imports the specified outline Element into the the specified Category.

Parameters:
outline - the outline Element to import
parent - the Category to import into

importFavorite

protected void importFavorite(Element outline,
                              Category parent)

Imports the specified outline Element as Favorite into the specified parent Category.

Parameters:
outline - the outline Element to import
parent - the Category to import into