2016-12-24 05:55:17 +01:00
|
|
|
package net.ME1312.SubServers.Bungee.Host;
|
2016-12-05 04:21:04 +01:00
|
|
|
|
2017-01-30 21:22:36 +01:00
|
|
|
import net.ME1312.SubServers.Bungee.Library.Util;
|
|
|
|
|
2016-12-05 04:21:04 +01:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Executable Variable Class
|
|
|
|
*/
|
|
|
|
@SuppressWarnings("serial")
|
|
|
|
public class Executable implements Serializable {
|
2017-04-16 19:02:14 +02:00
|
|
|
private boolean isFile;
|
2016-12-05 04:21:04 +01:00
|
|
|
private File File;
|
|
|
|
private String Str;
|
|
|
|
/**
|
|
|
|
* New Executable
|
|
|
|
*
|
|
|
|
* @param exe Executable String or File Path
|
|
|
|
*/
|
|
|
|
public Executable(String exe) {
|
2017-01-30 21:22:36 +01:00
|
|
|
if (Util.isNull(exe)) throw new NullPointerException();
|
2016-12-05 04:21:04 +01:00
|
|
|
if (new File(exe).exists()) {
|
|
|
|
isFile = true;
|
|
|
|
File = new File(exe);
|
|
|
|
Str = exe;
|
|
|
|
} else {
|
|
|
|
isFile = false;
|
|
|
|
File = null;
|
|
|
|
Str = exe;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* New Executable
|
|
|
|
*
|
2017-01-30 21:22:36 +01:00
|
|
|
* @param path File Path
|
2016-12-05 04:21:04 +01:00
|
|
|
*/
|
2017-01-30 21:22:36 +01:00
|
|
|
public Executable(File path) {
|
|
|
|
if (Util.isNull(path)) throw new NullPointerException();
|
2016-12-05 04:21:04 +01:00
|
|
|
isFile = true;
|
2017-01-30 21:22:36 +01:00
|
|
|
File = path;
|
|
|
|
Str = path.toString();
|
2016-12-05 04:21:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
String String;
|
|
|
|
if (isFile) {
|
|
|
|
String = File.toString();
|
|
|
|
} else {
|
|
|
|
String = Str;
|
|
|
|
}
|
|
|
|
return String;
|
|
|
|
}
|
|
|
|
|
2017-04-16 19:02:14 +02:00
|
|
|
/**
|
|
|
|
* Check if the Executable String is a file
|
|
|
|
*
|
|
|
|
* @return File Status
|
|
|
|
*/
|
|
|
|
public boolean isFile() {
|
|
|
|
return isFile;
|
|
|
|
}
|
|
|
|
|
2016-12-05 04:21:04 +01:00
|
|
|
/**
|
|
|
|
* Get Executable File
|
|
|
|
*
|
|
|
|
* @return File or Null if Executable isn't a file
|
|
|
|
*/
|
|
|
|
public File toFile() {
|
|
|
|
return File;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|