-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
smoothcloud-node/src/main/java/eu/smoothcloud/node/configuration/LaunchConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package eu.smoothcloud.node.configuration; | ||
|
||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
public class LaunchConfiguration { | ||
private final JSONObject jsonObject; | ||
|
||
public LaunchConfiguration() { | ||
this.jsonObject = new JSONObject("launcher.json"); | ||
} | ||
|
||
public void setLanguage(String language) { | ||
this.setValue("language", language); | ||
} | ||
|
||
public void setHost(String host) { | ||
this.setValue("host", host); | ||
} | ||
|
||
public void setPort(int port) { | ||
this.setValue("port", port); | ||
} | ||
|
||
public void setMemory(String memory) { | ||
this.setValue("memory", memory); | ||
} | ||
|
||
public String getLanguage() { | ||
return (String) this.getValue("language"); | ||
} | ||
|
||
public String getHost() { | ||
return (String) this.getValue("host"); | ||
} | ||
|
||
public int getPort() { | ||
return (int) this.getValue("port"); | ||
} | ||
|
||
public String getMemory() { | ||
return (String) this.getValue("memory"); | ||
} | ||
|
||
private boolean setValue(String key, Object value) { | ||
try { | ||
this.jsonObject.put(key, value); | ||
return true; | ||
} catch (JSONException e) { | ||
e.printStackTrace(); | ||
return false; | ||
} | ||
} | ||
|
||
private Object getValue(String key) { | ||
try { | ||
return this.jsonObject.get(key); | ||
} catch (JSONException e) { | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
} |