org.apache.tools.ant.types.selectors.modifiedselector

Class PropertiesfileCache

public class PropertiesfileCache extends Object implements Cache

Use java.util.Properties for storing the values. The use of this Cache-implementation requires the use of the parameter for defining, where to store the properties file. The ModifiedSelector sets the cachefile to the default value cache.properties. Supported s are:
namevaluesdescriptionrequired
cache.cachefile path to file the name of the properties file yes

Since: Ant 1.6

Version: 2003-09-13

Constructor Summary
PropertiesfileCache()
Bean-Constructor.
PropertiesfileCache(File cachefile)
Constructor.
Method Summary
voiddelete()
Deletes the cache and its underlying file.
Objectget(Object key)
Returns a value for a given key from the cache.
FilegetCachefile()
Getter.
booleanisValid()
This cache is valid if the cachefile is set.
Iteratoriterator()
Returns an iterator over the keys in the cache.
voidload()
Load the cache from underlying properties file.
voidput(Object key, Object value)
Saves a key-value-pair in the cache.
voidsave()
Saves modification of the cache.
voidsetCachefile(File file)
Setter.
StringtoString()
Override Object.toString().

Constructor Detail

PropertiesfileCache

public PropertiesfileCache()
Bean-Constructor.

PropertiesfileCache

public PropertiesfileCache(File cachefile)
Constructor.

Parameters: cachefile set the cachefile

Method Detail

delete

public void delete()
Deletes the cache and its underlying file.

get

public Object get(Object key)
Returns a value for a given key from the cache.

Parameters: key the key

Returns: the stored value

getCachefile

public File getCachefile()
Getter.

Returns: the cachefile

isValid

public boolean isValid()
This cache is valid if the cachefile is set.

Returns: true if all is ok false otherwise

iterator

public Iterator iterator()
Returns an iterator over the keys in the cache.

Returns: An iterator over the keys.

load

public void load()
Load the cache from underlying properties file.

put

public void put(Object key, Object value)
Saves a key-value-pair in the cache.

Parameters: key the key value the value

save

public void save()
Saves modification of the cache. Cache is only saved if there is one ore more entries. Because entries can not be deleted by this API, this Cache implementation checks the existence of entries before creating the file for performance optimisation.

setCachefile

public void setCachefile(File file)
Setter.

Parameters: file new value

toString

public String toString()
Override Object.toString().

Returns: information about this cache