public abstract class PersistorToFile extends AbstractRuntimeDataPersistor
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
filename
The name of file to hold the information of a Persistable object.
|
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
ignoredFieldsForUnpickle
Holding the fields which are ignored for each class.
|
protected java.io.File |
persistFile
The file holds the information of a Persistable object.
|
protected java.io.Reader |
reader
The Reader object of the project file.
|
protected java.io.Writer |
writer
The Writer object of the test file.
|
runtime| Modifier | Constructor and Description |
|---|---|
protected |
PersistorToFile(RuntimeDataInterface runtime,
java.lang.String filename) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
beforeUnpickle() |
protected Persistable |
doUnpickle() |
boolean |
equals(java.lang.Object o)
If they have the same filename, then we consider them equivalent
|
protected java.lang.String |
escape(java.lang.String value)
When writing a string to a file, some special characters MUST be escaped, such as
new line "\n", "\r", "\r\n", or double quote ", or <?XML>...</XML> etc.
What characters to escape and how to escape, these depend on the format of the persistence file, and the parser of the file. |
java.lang.String |
getPersistenceName()
The name of the persistence material holding the content of an Object.
It can be a file name or a variable name etc. It could be useful when deleting the persistence. |
PersistenceType |
getType()
The persistence Type.
|
protected boolean |
isIgnoredFiled(java.lang.String className,
java.lang.String field)
Check if the filed is being ignored at the moment for un-pickle.
|
void |
persist(Persistable persistable)
Persist a Persistable object.
|
protected boolean |
stringNeedQuoted()
If the string value needs to be quoted before writing into a kind of persistence.
JSON file requires that for string value. In JSON file, For example: "key" : "stringValue" is good "key" : stringValue is bad |
void |
unpersist()
Try to delete a persistence file in the test/bench folder.
|
Persistable |
unpickle(java.util.Map<java.lang.String,java.util.List<java.lang.String>> ignoredFields)
Provided default implementation, simply throw out a SAFSException.
|
protected abstract void |
write(Persistable persistable)
Write the Persistable object into a persistent material.
writeHeader(Persistable) is called beforewriteTailer(Persistable) is called after |
protected void |
writeHeader(Persistable persistable)
This is called before
write(Persistable). |
protected void |
writeTailer(Persistable persistable)
This is called after
write(Persistable). |
validateprotected java.lang.String filename
protected java.io.File persistFile
protected java.io.Writer writer
protected java.io.Reader reader
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> ignoredFieldsForUnpickle
#isIgnoredFiled(String)protected PersistorToFile(RuntimeDataInterface runtime, java.lang.String filename)
public void persist(Persistable persistable) throws SAFSException
Persistorpersist in interface Persistorpersist in class AbstractRuntimeDataPersistorpersistable - Persistable, the object to persistSAFSException - when persistence fails or something wrong happens.protected void writeHeader(Persistable persistable) throws SAFSException, java.io.IOException
write(Persistable).SAFSExceptionjava.io.IOExceptionprotected abstract void write(Persistable persistable) throws SAFSException, java.io.IOException
writeHeader(Persistable) is called beforewriteTailer(Persistable) is called afterSAFSExceptionjava.io.IOExceptionprotected void writeTailer(Persistable persistable) throws SAFSException, java.io.IOException
write(Persistable).SAFSExceptionjava.io.IOExceptionprotected boolean stringNeedQuoted()
protected java.lang.String escape(java.lang.String value)
stringNeedQuoted() returns true.value - String, the value to escape.stringNeedQuoted()public void unpersist()
throws SAFSException
SAFSException - when failing to delete the persistence or something wrong happens.public Persistable unpickle(java.util.Map<java.lang.String,java.util.List<java.lang.String>> ignoredFields) throws SAFSException
AbstractRuntimeDataPersistorunpickle in interface Persistorunpickle in class AbstractRuntimeDataPersistorignoredFields - Map<String, List<String>>, a Map containing the fields of each class to be ignored when un-pickling.SAFSExceptionprotected void beforeUnpickle()
throws SAFSException,
java.io.IOException
SAFSExceptionjava.io.IOExceptionprotected Persistable doUnpickle() throws SAFSException, java.io.IOException
SAFSExceptionjava.io.IOExceptionprotected boolean isIgnoredFiled(java.lang.String className,
java.lang.String field)
className - String, the className to checkfield - String, the field to checkignoredFieldsForUnpicklepublic PersistenceType getType()
Persistorpublic java.lang.String getPersistenceName()
PersistorPersistor.unpersist()public boolean equals(java.lang.Object o)
equals in class java.lang.ObjectCopyright © SAS Institute. All Rights Reserved.