public class Serializer extends Object
Constructor and Description |
---|
Serializer() |
Modifier and Type | Method and Description |
---|---|
protected InputStream |
getInputStream(String file)
Create an input stream.
|
protected OutputStream |
getOutputStream(String file)
Create an output stream.
|
boolean |
isUsingCompression() |
boolean |
isUsingXML() |
Object |
load(String file)
Loads object from file.
|
Object |
loadFromBinary(String file)
Load object from a binary file.
|
Object |
loadFromXML(String file)
Load object from XML file.
|
ProjectionModel |
loadProjection(String absolutePath,
IP3MDatabase database)
Loads a projection into the database.
|
void |
save(ProjectionModel pm,
String file)
Save object to file.
|
void |
saveToBinary(Object object,
String file)
Save object to binary file.
|
void |
saveToXML(Object object,
String file)
Save object to XML file.
|
void |
setUsingCompression(boolean usingCompression) |
void |
setUsingXML(boolean usingXML) |
public Object load(String file) throws IOException, ClassNotFoundException
file
- path to file with the object to be loadedIOException
- if file was not found, file input failed, etc.ClassNotFoundException
- if class of persistent object could not be foundpublic Object loadFromBinary(String file) throws IOException, ClassNotFoundException
file
- path and file nameIOException
- if file was not found, etc.ClassNotFoundException
- if class of persistent object could not be foundpublic Object loadFromXML(String file) throws IOException
file
- path and file nameIOException
- if file was not found, a read error occurred, etc.protected InputStream getInputStream(String file) throws IOException
file
- source fileIOException
- if stream creation failsprotected OutputStream getOutputStream(String file) throws IOException
file
- target fileIOException
- if stream creation failspublic void save(ProjectionModel pm, String file) throws IOException
object
- the object to be saved in the filefile
- the fileIOException
- if outputting went wrongpublic void saveToBinary(Object object, String file) throws IOException
object
- the object to be writtenfile
- the target fileIOException
- if writing failspublic void saveToXML(Object object, String file) throws IOException
object
- the object to be writtenfile
- the target fileIOException
- if writing failspublic boolean isUsingXML()
public void setUsingXML(boolean usingXML)
public boolean isUsingCompression()
public void setUsingCompression(boolean usingCompression)
public ProjectionModel loadProjection(String absolutePath, IP3MDatabase database) throws ClassNotFoundException, IOException, LoadedProjectionFormatException
copyProjection(ProjectionModel)
, as it
makes sure that the newly loaded projection model is properly managed by
hibernate. The easiest way to do so is by storing it as a new projection.absolutePath
- the absolute pathdatabase
- the databaseClassNotFoundException
- the class not found exceptionIOException
- Signals that an I/O exception has occurred.LoadedProjectionFormatException
Copyright © 2012. All Rights Reserved.