public class FilePersistenceStrategy extends AbstractFilePersistenceStrategy
SingleValueConverter
. It escapes all characters that are normally illegal in
the most common file systems. Such a character is escaped with percent escaping as it is done by URL encoding. The
XStream used to marshal the values is also requested for the key's SingleValueConverter. A
ConversionException
is thrown if no such converter is registered.AbstractFilePersistenceStrategy.ValidFilenameFilter, AbstractFilePersistenceStrategy.XmlMapEntriesIterator
Constructor and Description |
---|
FilePersistenceStrategy(java.io.File baseDirectory)
Create a new FilePersistenceStrategy.
|
FilePersistenceStrategy(java.io.File baseDirectory,
XStream xstream)
Create a new FilePersistenceStrategy with a provided XStream instance.
|
FilePersistenceStrategy(java.io.File baseDirectory,
XStream xstream,
java.lang.String encoding,
java.lang.String illegalChars)
Create a new FilePersistenceStrategy with a provided XStream instance and the characters to encode.
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
escape(java.lang.String key) |
protected java.lang.Object |
extractKey(java.lang.String name)
Given a filename, the unescape method returns the key which originated it.
|
protected java.lang.String |
getName(java.lang.Object key)
Given a key, the escape method returns the filename which shall be used.
|
protected boolean |
isValid(java.io.File dir,
java.lang.String name) |
protected java.lang.String |
unescape(java.lang.String name) |
containsKey, get, getConverterLookup, getMapper, iterator, put, remove, size
public FilePersistenceStrategy(java.io.File baseDirectory)
DomDriver
.baseDirectory
- the directory for the serialized valuespublic FilePersistenceStrategy(java.io.File baseDirectory, XStream xstream)
baseDirectory
- the directory for the serialized valuesxstream
- the XStream instance to use for (de)serializationpublic FilePersistenceStrategy(java.io.File baseDirectory, XStream xstream, java.lang.String encoding, java.lang.String illegalChars)
baseDirectory
- the directory for the serialized valuesxstream
- the XStream instance to use for (de)serializationencoding
- encoding used to write the filesillegalChars
- illegal characters for file names (should always include '%' as long as you do not overwrite
the (un)escape methods)protected boolean isValid(java.io.File dir, java.lang.String name)
isValid
in class AbstractFilePersistenceStrategy
protected java.lang.Object extractKey(java.lang.String name)
extractKey
in class AbstractFilePersistenceStrategy
name
- the filenameprotected java.lang.String unescape(java.lang.String name)
protected java.lang.String getName(java.lang.Object key)
getName
in class AbstractFilePersistenceStrategy
key
- the keyprotected java.lang.String escape(java.lang.String key)
Copyright © 2004–2022 XStream. All rights reserved.