use of com.thoughtworks.xstream.XStreamException in project GDSC-SMLM by aherbert.
the class SettingsManager method unsafeLoadSettings.
/**
* Load the settings from the input stream. The stream will be closed.
* <p>
* If this fails then an error message is written to the ImageJ log
*
* @param inputStream
* the input stream
* @param silent
* Set to true to suppress writing an error message to the ImageJ log
* @return The settings (or null)
*/
public static GlobalSettings unsafeLoadSettings(InputStream inputStream, boolean silent) {
XStream xs = createXStream();
GlobalSettings config = null;
try {
config = (GlobalSettings) xs.fromXML(inputStream);
} catch (ClassCastException ex) {
//ex.printStackTrace();
} catch (XStreamException ex) {
ex.printStackTrace();
} finally {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (config == null)
if (!silent)
IJ.log("Unable to load settings from input stream");
return config;
}
use of com.thoughtworks.xstream.XStreamException in project GDSC-SMLM by aherbert.
the class SettingsManager method saveSettings.
/**
* Save the settings to file.
* <p>
* If this fails then an error message is written to the ImageJ log
*
* @param settings
* the settings
* @param filename
* the filename
* @param silent
* Set to true to suppress writing an error message to the ImageJ log
* @return True if saved
*/
public static boolean saveSettings(GlobalSettings settings, String filename, boolean silent) {
XStream xs = createXStream();
FileOutputStream fs = null;
try {
fs = new FileOutputStream(filename);
xs.toXML(settings, fs);
return true;
} catch (FileNotFoundException ex) {
//ex.printStackTrace();
} catch (XStreamException ex) {
ex.printStackTrace();
} finally {
if (fs != null) {
try {
fs.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
if (!silent)
IJ.log("Unable to save settings to: " + filename);
return false;
}
use of com.thoughtworks.xstream.XStreamException in project GDSC-SMLM by aherbert.
the class SettingsManager method unsafeLoadSettings.
/**
* Load the settings within the specified file
* <p>
* If this fails then an error message is written to the ImageJ log
*
* @param filename
* @param silent
* Set to true to suppress writing an error message to the ImageJ log
* @return The settings (or null)
*/
public static GlobalSettings unsafeLoadSettings(String filename, boolean silent) {
XStream xs = createXStream();
GlobalSettings config = null;
FileInputStream fs = null;
try {
fs = new FileInputStream(filename);
config = (GlobalSettings) xs.fromXML(fs);
} catch (ClassCastException ex) {
//ex.printStackTrace();
} catch (FileNotFoundException ex) {
//ex.printStackTrace();
} catch (XStreamException ex) {
ex.printStackTrace();
} finally {
if (fs != null) {
try {
fs.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
if (config == null)
if (!silent)
IJ.log("Unable to load settings from: " + filename);
return config;
}
use of com.thoughtworks.xstream.XStreamException in project GDSC-SMLM by aherbert.
the class SettingsManager method saveFitEngineConfiguration.
/**
* Save the configuration to file
*
* @param config
* @param filename
* @return True if saved
*/
public static boolean saveFitEngineConfiguration(FitEngineConfiguration config, String filename) {
XStream xs = createXStream();
FileOutputStream fs = null;
try {
fs = new FileOutputStream(filename);
xs.toXML(config, fs);
return true;
} catch (FileNotFoundException ex) {
//ex.printStackTrace();
} catch (XStreamException ex) {
ex.printStackTrace();
} finally {
if (fs != null) {
try {
fs.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return false;
}
use of com.thoughtworks.xstream.XStreamException in project GDSC-SMLM by aherbert.
the class BatchPeakFit method loadSettings.
private BatchSettings loadSettings(String configurationFilename) {
BatchSettings settings = null;
FileInputStream fs = null;
try {
fs = new FileInputStream(configurationFilename);
settings = (BatchSettings) xs.fromXML(fs);
} catch (ClassCastException ex) {
//ex.printStackTrace();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (XStreamException ex) {
ex.printStackTrace();
} finally {
if (fs != null) {
try {
fs.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return settings;
}
Aggregations