Top Description Inners Fields Constructors Methods
com.thoughtworks.xstream.persistence

public abstract Class AbstractFilePersistenceStrategy

extends Object
implements PersistenceStrategy
Class Inheritance
All Implemented Interfaces
com.thoughtworks.xstream.persistence.PersistenceStrategy
Known Direct Subclasses
com.thoughtworks.xstream.persistence.FilePersistenceStrategy, com.thoughtworks.xstream.persistence.FileStreamStrategy
Imports
com.thoughtworks.xstream.XStream, com.thoughtworks.xstream.converters.ConverterLookup, com.thoughtworks.xstream.io.StreamException, com.thoughtworks.xstream.mapper.Mapper, java.io.File, .FileInputStream, .FileNotFoundException, .FileOutputStream, .FilenameFilter, .IOException, .InputStreamReader, .OutputStreamWriter, .Reader, .Writer, java.util.Iterator, .Map, .Map.Entry

Abstract base class for file based persistence strategies.
Authors
Guilherme Silveira, Joerg Schaible
Since
1.3.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
protected class

Field Summary

Modifier and TypeField and Description
private final File
private final String
private final FilenameFilter
private final transient XStream

Constructor Summary

AccessConstructor and Description
public
AbstractFilePersistenceStrategy(final File baseDirectory, final XStream xstream, final String encoding)

Method Summary

Modifier and TypeMethod and Description
public boolean
containsKey(final Object key)

protected abstract Object

Returns:

the original key
extractKey
(String
the filename
name
)

Given a filename, the unescape method returns the key which originated it.

public Object
protected ConverterLookup
private File
getFile(final String filename)

protected Mapper
protected abstract String

Returns:

the desired and escaped filename
getName
(Object
the key
key
)

Given a key, the escape method returns the filename which shall be used.

protected boolean
isValid(final File dir, final String name)

public Iterator<E>
public Object
private Object
readFile(final File file)

public Object
public int
private void
writeFile(final File file, final Object value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseDirectoryback to summary
private final File baseDirectory
encodingback to summary
private final String encoding
filterback to summary
private final FilenameFilter filter
xstreamback to summary
private final transient XStream xstream

Constructor Detail

AbstractFilePersistenceStrategyback to summary
public AbstractFilePersistenceStrategy(final File baseDirectory, final XStream xstream, final String encoding)

Method Detail

containsKeyback to summary
public boolean containsKey(final Object key)
extractKeyback to summary
protected abstract Object extractKey(String name)

Given a filename, the unescape method returns the key which originated it.

Parameters
name:String

the filename

Returns:Object

the original key

getback to summary
public Object get(final Object key)

Implements com.thoughtworks.xstream.persistence.PersistenceStrategy.get.

getConverterLookupback to summary
protected ConverterLookup getConverterLookup()
getFileback to summary
private File getFile(final String filename)
getMapperback to summary
protected Mapper getMapper()
getNameback to summary
protected abstract String getName(Object key)

Given a key, the escape method returns the filename which shall be used.

Parameters
key:Object

the key

Returns:String

the desired and escaped filename

isValidback to summary
protected boolean isValid(final File dir, final String name)
iteratorback to summary
public Iterator<E> iterator()

Implements com.thoughtworks.xstream.persistence.PersistenceStrategy.iterator.

putback to summary
public Object put(final Object key, final Object value)

Implements com.thoughtworks.xstream.persistence.PersistenceStrategy.put.

readFileback to summary
private Object readFile(final File file)
removeback to summary
public Object remove(final Object key)

Implements com.thoughtworks.xstream.persistence.PersistenceStrategy.remove.

sizeback to summary
public int size()

Implements com.thoughtworks.xstream.persistence.PersistenceStrategy.size.

writeFileback to summary
private void writeFile(final File file, final Object value)
com.thoughtworks.xstream.persistence back to summary

protected Class AbstractFilePersistenceStrategy.ValidFilenameFilter

extends Object
implements FilenameFilter
Class Inheritance
  • java.lang.Object
  • com.thoughtworks.xstream.persistence.AbstractFilePersistenceStrategy.ValidFilenameFilter
All Implemented Interfaces
java.io.FilenameFilter

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public boolean
accept(final File
the directory in which the file was found.
dir
,
final String
the name of the file.
name
)

Implements java.io.FilenameFilter.accept.

Tests if a specified file should be included in a file list.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ValidFilenameFilterback to summary
protected ValidFilenameFilter()

Method Detail

acceptback to summary
public boolean accept(final File dir, final String name)

Implements java.io.FilenameFilter.accept.

Doc from java.io.FilenameFilter.accept.

Tests if a specified file should be included in a file list.

Parameters
dir:File

the directory in which the file was found.

name:String

the name of the file.

Returns:boolean

true if and only if the name should be included in the file list; false otherwise.

com.thoughtworks.xstream.persistence back to summary

protected Class AbstractFilePersistenceStrategy.XmlMapEntriesIterator

extends Object
implements Iterator
Class Inheritance
  • java.lang.Object
  • com.thoughtworks.xstream.persistence.AbstractFilePersistenceStrategy.XmlMapEntriesIterator
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private File
private final File[]
private int

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public Object
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
private File current
filesback to summary
private final File[] files
positionback to summary
private int position

Constructor Detail

XmlMapEntriesIteratorback to summary
protected XmlMapEntriesIterator()

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

nextback to summary
public Object next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:Object

the next element in the iteration

removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.