com.thoughtworks.xstream.persistence
Class FileStreamStrategy
java.lang.Object
com.thoughtworks.xstream.persistence.FileStreamStrategy
- All Implemented Interfaces:
- StreamStrategy
public class FileStreamStrategy
- extends java.lang.Object
- implements StreamStrategy
The default naming strategy is based on the key's toString method and escapes
non digit, non a-z, A-Z characters. In order to change the
escaping/unescaping algorithm, simply extend this class and rewrite its
getName/extractKey methods.
- Author:
- Guilherme Silveira
Method Summary |
boolean |
containsKey(java.lang.Object key)
|
protected java.lang.String |
escape(java.lang.String key)
|
protected java.lang.String |
extractKey(java.lang.String name)
Given a filename, the unescape method returns the key which originated
it. |
java.lang.Object |
get(java.lang.Object key)
|
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)
|
java.util.Iterator |
iterator()
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
|
java.lang.Object |
remove(java.lang.Object key)
|
int |
size()
|
protected java.lang.String |
unescape(java.lang.String name)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileStreamStrategy
public FileStreamStrategy(java.io.File baseDirectory)
FileStreamStrategy
public FileStreamStrategy(java.io.File baseDirectory,
XStream xstream)
isValid
protected boolean isValid(java.io.File dir,
java.lang.String name)
extractKey
protected java.lang.String extractKey(java.lang.String name)
- Given a filename, the unescape method returns the key which originated
it.
- Parameters:
name
- the filename
- Returns:
- the original key
unescape
protected java.lang.String unescape(java.lang.String name)
getName
protected java.lang.String getName(java.lang.Object key)
- Given a key, the escape method returns the filename which shall be used.
- Parameters:
key
- the key
- Returns:
- the desired and escaped filename
escape
protected java.lang.String escape(java.lang.String key)
put
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
- Specified by:
put
in interface StreamStrategy
iterator
public java.util.Iterator iterator()
- Specified by:
iterator
in interface StreamStrategy
size
public int size()
- Specified by:
size
in interface StreamStrategy
containsKey
public boolean containsKey(java.lang.Object key)
get
public java.lang.Object get(java.lang.Object key)
- Specified by:
get
in interface StreamStrategy
remove
public java.lang.Object remove(java.lang.Object key)
- Specified by:
remove
in interface StreamStrategy
Joe Walnes, http://xstream.codehaus.org/