org.encog.persist
Class PersistReader

java.lang.Object
  extended by org.encog.persist.PersistReader

public class PersistReader
extends Object

Utility class for reading Encog persited object files.

Author:
jheaton

Field Summary
static String ATTRIBUTE_NAME
          The name attribute.
static String TAG_OBJECTS
          The objects tag.
 
Constructor Summary
PersistReader(PersistenceLocation location)
          Construct a persist reader.
 
Method Summary
 boolean advance(String name)
          Advance to the specified object.
 void advanceObjectsCollection()
          Advance to the objects collection.
 Set<DirectoryEntry> buildDirectory()
          Build a directory entry list for the file.
 void close()
          Close the file.
 ReadXML getXMLInput()
           
 Map<String,String> readHeader()
          Obtain the Encog header from the file.
 boolean readNextTag(String name)
          Read until the next tag of the specified name.
 String readNextText(String name)
          Read all text until the specified ending tag is found.
 EncogPersistedObject readObject(String name)
          Read the specific object, search through the objects until its found.
 String readValue(String name)
          Read the value in a period delimited string.
 void saveModified(WriteXML out, String targetName, String newName, String newDesc)
          Modify the properties of this object.
 void saveTo(WriteXML out, String skip)
          Save all objects to the specified steam, skip the one specified by the skip parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_NAME

public static final String ATTRIBUTE_NAME
The name attribute.

See Also:
Constant Field Values

TAG_OBJECTS

public static final String TAG_OBJECTS
The objects tag.

See Also:
Constant Field Values
Constructor Detail

PersistReader

public PersistReader(PersistenceLocation location)
Construct a persist reader.

Parameters:
location - The location to use.
Method Detail

advance

public boolean advance(String name)
Advance to the specified object.

Parameters:
name - The name of the object looking for.
Returns:
The beginning element of the object found.

advanceObjectsCollection

public void advanceObjectsCollection()
Advance to the objects collection.


buildDirectory

public Set<DirectoryEntry> buildDirectory()
Build a directory entry list for the file.

Returns:
A list of objects in the file.

close

public void close()
Close the file.


getXMLInput

public ReadXML getXMLInput()
Returns:
The ReadXML object being used by this object.

readHeader

public Map<String,String> readHeader()
Obtain the Encog header from the file.

Returns:
Name value pair map of the header attributes.

readNextTag

public boolean readNextTag(String name)
Read until the next tag of the specified name.

Parameters:
name - The name searched for.
Returns:
True if the tag was found.

readNextText

public String readNextText(String name)
Read all text until the specified ending tag is found.

Parameters:
name - The tag.
Returns:
The text found.

readObject

public EncogPersistedObject readObject(String name)
Read the specific object, search through the objects until its found.

Parameters:
name - The name of the object you are looking for.
Returns:
The object found, null if not found.

readValue

public String readValue(String name)
Read the value in a period delimited string. For example property.name.value.

Parameters:
name - The property to read.
Returns:
The value found at the specified property.

saveModified

public void saveModified(WriteXML out,
                         String targetName,
                         String newName,
                         String newDesc)
Modify the properties of this object.

Parameters:
out - The XML writer.
targetName - The name of the object to change.
newName - The new name of this object.
newDesc - The new description of this object.

saveTo

public void saveTo(WriteXML out,
                   String skip)
Save all objects to the specified steam, skip the one specified by the skip parameter. Do not attempt to understand the structure, just copy.

Parameters:
out - The XML writer to save the objects to.
skip - The object to skip.


Copyright © 2011. All Rights Reserved.