com.fullspan.pwkeep.persist
Class PwkFileMgr

java.lang.Object
  extended by com.fullspan.pwkeep.persist.PwkFileMgr

public class PwkFileMgr
extends java.lang.Object

This class manages the persistence of the PWKeep data. It handles the following tasks:

A new instance of this class should be created for each file that you want to manage.

Version:
$Revision: 1.4 $, $Date: 2004/01/27 06:40:23 $
Author:
Mitch Stuart, $Author: mitch $

Field Summary
static java.lang.String CHARSET_ENCODING
           
static java.lang.String FILE_EXTENSION
           
static java.lang.String FILE_EXTENSION_WITH_DOT
           
static java.lang.String FILE_FORMAT_VERSION
           
static java.lang.String TAG_CATEGORIES
           
static java.lang.String TAG_CATEGORY
           
static java.lang.String TAG_COMMENTS
           
static java.lang.String TAG_CRYPTOMARKER
           
static java.lang.String TAG_ENCRYPTED
           
static java.lang.String TAG_ITEM
           
static java.lang.String TAG_ITEMS
           
static java.lang.String TAG_NAME
           
static java.lang.String TAG_PASSWORD
           
static java.lang.String TAG_PWKEEP
           
static java.lang.String TAG_SALT
           
static java.lang.String TAG_URL
           
static java.lang.String TAG_VERSION
           
 
Constructor Summary
PwkFileMgr(java.lang.String passphrase)
          Create a new file manager with the specified passphrase.
 
Method Summary
static org.jdom.output.XMLOutputter getXMLOutputter()
           
static void jdomDocToModel(org.jdom.Document jdomDoc, PwkTreeModel treeModel)
          Transforms a JDOM document to a tree model.
 boolean loadFile(java.io.File file, PwkTreeModel treeModel)
          Loads the file and decrypts it, using the passphrase associated with this file manager.
static void modelToJdomDoc(javax.swing.tree.DefaultMutableTreeNode startNode, org.jdom.Element startElem)
          Transforms a tree model (or part of a tree model) to JDOM document.
static org.jdom.Document modelToJdomDoc(PwkTreeModel treeModel)
          Transforms a tree model to a JDOM document.
static void outputXML(PwkTreeModel treeModel, java.io.Writer writer)
          Outputs the tree model in XML format to the specified writer.
 void saveFile(PwkTreeModel treeModel, java.io.File file)
          Saves and encrypts the file, using the passphrase associated with this file manager.
static void transform(PwkTreeModel treeModel, javax.xml.transform.stream.StreamSource styleSheetSource, javax.xml.transform.Result result)
          Transforms a tree model using an XSLT stylesheet.
static void transform(PwkTreeModel treeModel, javax.xml.transform.stream.StreamSource styleSheetSource, javax.xml.transform.Result result, java.util.Map extraAttribMap)
          Transforms a tree model using an XSLT stylesheet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TAG_CATEGORIES

public static final java.lang.String TAG_CATEGORIES
See Also:
Constant Field Values

TAG_CATEGORY

public static final java.lang.String TAG_CATEGORY
See Also:
Constant Field Values

TAG_COMMENTS

public static final java.lang.String TAG_COMMENTS
See Also:
Constant Field Values

TAG_CRYPTOMARKER

public static final java.lang.String TAG_CRYPTOMARKER
See Also:
Constant Field Values

TAG_ENCRYPTED

public static final java.lang.String TAG_ENCRYPTED
See Also:
Constant Field Values

TAG_ITEM

public static final java.lang.String TAG_ITEM
See Also:
Constant Field Values

TAG_ITEMS

public static final java.lang.String TAG_ITEMS
See Also:
Constant Field Values

TAG_NAME

public static final java.lang.String TAG_NAME
See Also:
Constant Field Values

TAG_PASSWORD

public static final java.lang.String TAG_PASSWORD
See Also:
Constant Field Values

TAG_PWKEEP

public static final java.lang.String TAG_PWKEEP
See Also:
Constant Field Values

TAG_SALT

public static final java.lang.String TAG_SALT
See Also:
Constant Field Values

TAG_URL

public static final java.lang.String TAG_URL
See Also:
Constant Field Values

TAG_VERSION

public static final java.lang.String TAG_VERSION
See Also:
Constant Field Values

FILE_FORMAT_VERSION

public static final java.lang.String FILE_FORMAT_VERSION
See Also:
Constant Field Values

FILE_EXTENSION

public static final java.lang.String FILE_EXTENSION

FILE_EXTENSION_WITH_DOT

public static final java.lang.String FILE_EXTENSION_WITH_DOT

CHARSET_ENCODING

public static final java.lang.String CHARSET_ENCODING
See Also:
Constant Field Values
Constructor Detail

PwkFileMgr

public PwkFileMgr(java.lang.String passphrase)
           throws PwkException
Create a new file manager with the specified passphrase.

Parameters:
passphrase - the passphrase for this file manager
Throws:
PwkException
Method Detail

jdomDocToModel

public static void jdomDocToModel(org.jdom.Document jdomDoc,
                                  PwkTreeModel treeModel)
Transforms a JDOM document to a tree model. The treeModel should be empty when this method is called.


modelToJdomDoc

public static void modelToJdomDoc(javax.swing.tree.DefaultMutableTreeNode startNode,
                                  org.jdom.Element startElem)
Transforms a tree model (or part of a tree model) to JDOM document.

Parameters:
startNode - the starting node in the tree to transform
startElem - the starting element in the JDOM document under which the new document elements should be added

modelToJdomDoc

public static org.jdom.Document modelToJdomDoc(PwkTreeModel treeModel)
Transforms a tree model to a JDOM document.


transform

public static void transform(PwkTreeModel treeModel,
                             javax.xml.transform.stream.StreamSource styleSheetSource,
                             javax.xml.transform.Result result)
                      throws PwkException
Transforms a tree model using an XSLT stylesheet. Equivalent to calling transform(treeModel, styleSheetSource, result, null).

Throws:
PwkException
See Also:
transform(PwkTreeModel, StreamSource, Result, Map)

transform

public static void transform(PwkTreeModel treeModel,
                             javax.xml.transform.stream.StreamSource styleSheetSource,
                             javax.xml.transform.Result result,
                             java.util.Map extraAttribMap)
                      throws PwkException
Transforms a tree model using an XSLT stylesheet. For example, this can be used to generate a tab-separated data stream from a tree model, for exporting to a spreadsheet program such as Microsoft Excel.

Optionally, extra attributes can be specified as String-Object pairs in the extraAttribMap. These attributes are made available to be used by XSLT param elements.

Parameters:
treeModel - the model to transform
styleSheetSource - the XSLT stylesheet
result - the result of the transform
extraAttribMap - an optional map of String-Object pairs; this parameter can be null if there are no extra attributes
Throws:
PwkException - if an error occurs

getXMLOutputter

public static org.jdom.output.XMLOutputter getXMLOutputter()

outputXML

public static void outputXML(PwkTreeModel treeModel,
                             java.io.Writer writer)
                      throws java.io.IOException
Outputs the tree model in XML format to the specified writer.

Throws:
java.io.IOException

loadFile

public boolean loadFile(java.io.File file,
                        PwkTreeModel treeModel)
                 throws PwkException
Loads the file and decrypts it, using the passphrase associated with this file manager.

Throws:
PwkException

saveFile

public void saveFile(PwkTreeModel treeModel,
                     java.io.File file)
              throws PwkException
Saves and encrypts the file, using the passphrase associated with this file manager.

Throws:
PwkException