mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-07 00:16:04 +00:00
added javadoc to settings classes
This commit is contained in:
@@ -9,8 +9,14 @@ import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Manages the settings files
|
||||
* @author Diego Waxemberg
|
||||
*/
|
||||
public class SettingsManager {
|
||||
|
||||
/**
|
||||
* Directory to which settings will be saved
|
||||
*/
|
||||
public static String SETTINGS_DIR = System.getProperty("user.home") + File.separator + "Limelight";
|
||||
|
||||
//directory to hold limelight settings
|
||||
@@ -21,12 +27,19 @@ public class SettingsManager {
|
||||
|
||||
private static SettingsManager manager;
|
||||
|
||||
/*
|
||||
* Constructs a manager that initializes the settings files
|
||||
*/
|
||||
private SettingsManager() {
|
||||
settingsFile = new File(SETTINGS_DIR + File.separator + "settings.lime");
|
||||
gamepadFile = new File(SETTINGS_DIR + File.separator + "gamepad.lime");
|
||||
settingsDir = new File(SETTINGS_DIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an instance of the manager, this is a singleton
|
||||
* @return the instance of the manager
|
||||
*/
|
||||
public static SettingsManager getInstance() {
|
||||
if (manager == null) {
|
||||
manager = new SettingsManager();
|
||||
@@ -34,6 +47,10 @@ public class SettingsManager {
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gamepad preference file, if the file does not exist, it is created first
|
||||
* @return the gamepad preference file
|
||||
*/
|
||||
public File getGamepadFile() {
|
||||
if (!settingsDir.exists()) {
|
||||
settingsFile.mkdirs();
|
||||
@@ -51,6 +68,10 @@ public class SettingsManager {
|
||||
return gamepadFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the settings file (user preferences), if the file does not exist, it is created first
|
||||
* @return the settings file
|
||||
*/
|
||||
public File getSettingsFile() {
|
||||
if (!settingsDir.exists()) {
|
||||
settingsFile.mkdirs();
|
||||
@@ -68,6 +89,12 @@ public class SettingsManager {
|
||||
return settingsFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the specified file as a settings file and returns the result.
|
||||
* <br>A settings file must be a java serialized object
|
||||
* @param file the file to read in
|
||||
* @return the settings represented in this file
|
||||
*/
|
||||
public static Object readSettings(File file) {
|
||||
ObjectInputStream ois = null;
|
||||
Object settings = null;
|
||||
@@ -100,6 +127,11 @@ public class SettingsManager {
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the specified settings to the desired file
|
||||
* @param file the file to write the settings to
|
||||
* @param settings the settings to be written out
|
||||
*/
|
||||
public static void writeSettings(File file, Serializable settings) {
|
||||
ObjectOutputStream ous = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user