org.encog.persist
Class EncogMemoryCollection

java.lang.Object
  extended by org.encog.persist.EncogMemoryCollection
All Implemented Interfaces:
EncogCollection

public class EncogMemoryCollection
extends Object
implements EncogCollection

A memory based collection of Encog objects. Does not use the more complex temp file structure like EncogPersistedCollection, but also can't handle gigantic files. This class can load and save from/to Encog EG files.


Constructor Summary
EncogMemoryCollection()
           
 
Method Summary
 void add(String name, EncogPersistedObject obj)
          Add an element to the collection.
 void buildDirectory()
          Build the directory.
 void clear()
          Clear all elements from the collection.
 void delete(DirectoryEntry object)
          Delete an object from the collection.
 void delete(String key)
          Delete a key from the collection.
 boolean exists(String key)
          Determine if the specified key exists.
 EncogPersistedObject find(DirectoryEntry entry)
          Find the object that corresponds to the specified directory entry, return null, if not found.
 EncogPersistedObject find(String key)
          Find the object that corresponds to the specified key.
 Map<String,EncogPersistedObject> getContents()
           
 List<DirectoryEntry> getDirectory()
           
 String getEncogVersion()
           
 int getFileVersion()
           
 PersistenceLocation getLocation()
           
 String getPlatform()
           
 void load(PersistenceLocation location)
          Load the contents of a location.
 void save(PersistenceLocation location)
          Save the contents of this collection to a location.
 void updateProperties(String name, String newName, String desc)
          Update the properties of an element in the collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncogMemoryCollection

public EncogMemoryCollection()
Method Detail

add

public void add(String name,
                EncogPersistedObject obj)
Add an element to the collection.

Specified by:
add in interface EncogCollection
Parameters:
name - The name of the element being added.
obj - The object to be added.

buildDirectory

public void buildDirectory()
Build the directory. This allows the contents of the collection to be listed.

Specified by:
buildDirectory in interface EncogCollection

clear

public void clear()
Clear all elements from the collection.

Specified by:
clear in interface EncogCollection

delete

public void delete(DirectoryEntry object)
Delete an object from the collection.

Specified by:
delete in interface EncogCollection
Parameters:
object - The object to be deleted.

delete

public void delete(String key)
Delete a key from the collection.

Specified by:
delete in interface EncogCollection
Parameters:
key - The key to delete.

exists

public boolean exists(String key)
Determine if the specified key exists.

Specified by:
exists in interface EncogCollection
Parameters:
key - The key.
Returns:
True, if the key exists.

find

public EncogPersistedObject find(DirectoryEntry entry)
Find the object that corresponds to the specified directory entry, return null, if not found.

Specified by:
find in interface EncogCollection
Parameters:
entry - The entry to find.
Returns:
The object that was found, or null, if no object was found.

find

public EncogPersistedObject find(String key)
Find the object that corresponds to the specified key.

Specified by:
find in interface EncogCollection
Parameters:
key - The key to search for.
Returns:
The object that corresponds to the specified key.

getContents

public Map<String,EncogPersistedObject> getContents()
Returns:
The objects that were loaded from this file.

getDirectory

public List<DirectoryEntry> getDirectory()
Specified by:
getDirectory in interface EncogCollection
Returns:
A list of all the objects in the collection, specified by DirectoryEntry objects.

getEncogVersion

public String getEncogVersion()
Specified by:
getEncogVersion in interface EncogCollection
Returns:
The version of Encog that this file was created with.

getFileVersion

public int getFileVersion()
Specified by:
getFileVersion in interface EncogCollection
Returns:
The Encog file version.

getPlatform

public String getPlatform()
Specified by:
getPlatform in interface EncogCollection
Returns:
The platform that this file was created on.

load

public void load(PersistenceLocation location)
Load the contents of a location.

Parameters:
location - The location to load from.

save

public void save(PersistenceLocation location)
Save the contents of this collection to a location.

Parameters:
location - The location to save to.

updateProperties

public void updateProperties(String name,
                             String newName,
                             String desc)
Update the properties of an element in the collection. This allows the element to be renamed, if needed.

Specified by:
updateProperties in interface EncogCollection
Parameters:
name - The name of the object that is being updated.
newName - The new name, can be the same as the old name, if the description is to be updated only.
desc - The new description.

getLocation

public PersistenceLocation getLocation()
Specified by:
getLocation in interface EncogCollection
Returns:
The location.


Copyright © 2011. All Rights Reserved.