Skip to content

Commit

Permalink
Renamed SystemUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
igr committed Aug 18, 2015
1 parent b1d8726 commit da30445
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion jodd-core/src/main/java/jodd/util/ClassLoaderUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public static Class findClass(String className, URL[] classPath, ClassLoader par
* Finds <b>tools.jar</b>. Returns <code>null</code> if does not exist.
*/
public static File findToolsJar() {
String tools = new File(SystemUtil.getJavaHome()).getAbsolutePath() + File.separatorChar + "lib" + File.separatorChar + "tools.jar";
String tools = new File(SystemUtil.javaHome()).getAbsolutePath() + File.separatorChar + "lib" + File.separatorChar + "tools.jar";
File toolsFile = new File(tools);
if (toolsFile.exists()) {
return toolsFile;
Expand Down
1 change: 1 addition & 0 deletions jodd-core/src/main/java/jodd/util/StringPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public interface StringPool {
String SINGLE_QUOTE = "'";
String BACKTICK = "`";
String SPACE = " ";
String TILDA = "~";
String LEFT_SQ_BRACKET = "[";
String RIGHT_SQ_BRACKET = "]";
String TRUE = "true";
Expand Down
46 changes: 23 additions & 23 deletions jodd-core/src/main/java/jodd/util/SystemUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class SystemUtil {
/**
* Returns list of packages, build into runtime jars.
*/
public static String[] getJrePackages() {
public static String[] jrePackages() {
if (jrePackages == null) {
buildJrePackages();
}
Expand Down Expand Up @@ -174,44 +174,44 @@ private static void buildJrePackages() {
/**
* Returns current working folder.
*/
public static String getUserDir() {
public static String userDir() {
return System.getProperty(USER_DIR);
}

/**
* Returns current user.
*/
public static String getUserName() {
public static String userName() {
return System.getProperty(USER_NAME);
}

/**
* Returns user home folder.
*/
public static String getUserHome() {
public static String userHome() {
return System.getProperty(USER_HOME);
}

/**
* Returns current working folder.
* This is <b>NOT</b> a user folder.
*/
public static String getWorkingFolder() {
public static String workingFolder() {
return WORKING_FOLDER;
}

/**
* Returns JRE home.
*/
public static String getJavaJreHome() {
public static String javaJreHome() {
return System.getProperty(JAVA_HOME);
}

/**
* Returns JAVA_HOME which is not equals to "java.home" property
* since it points to JAVA_HOME/jre folder.
*/
public static String getJavaHome() {
public static String javaHome() {
String home = System.getProperty(JAVA_HOME);
if (home == null) {
return null;
Expand All @@ -227,37 +227,37 @@ public static String getJavaHome() {
/**
* Returns system temp dir.
*/
public static String getTempDir() {
public static String tempDir() {
return System.getProperty(TEMP_DIR);
}

/**
* Returns OS name.
*/
public static String getOsName() {
public static String osName() {
return System.getProperty(OS_NAME);
}

/**
* Returns OS version.
*/
public static String getOsVersion() {
public static String osVersion() {
return System.getProperty(OS_VERSION);
}

/**
* Returns Java version string, as specified in system property.
* Returned string contain major version, minor version and revision.
* @see #getJavaSpecificationVersion()
* @see #javaSpecificationVersion()
*/
public static String getJavaVersion() {
public static String javaVersion() {
return System.getProperty(JAVA_VERSION);
}

/**
* Retrieves the version of the currently running JVM.
*/
public static String getJavaSpecificationVersion() {
public static String javaSpecificationVersion() {
return System.getProperty(JAVA_SPECIFICATION_VERSION);
}

Expand All @@ -266,14 +266,14 @@ public static String getJavaSpecificationVersion() {
* a number 10x the <code>major.minor</code>, e.g.
* Java1.5 returns <code>15</code>.
*/
public static int getJavaVersionNumber() {
public static int javaVersionNumber() {
return javaVersionNumber;
}

/**
* Returns Java vendor.
*/
public static String getJavaVendor() {
public static String javaVendor() {
return System.getProperty(JAVA_VENDOR);
}

Expand All @@ -297,36 +297,36 @@ public static boolean isJavaVersion(int version) {
/**
* Returns system class path.
*/
public static String getClassPath() {
public static String systemClassPath() {
return System.getProperty(JAVA_CLASSPATH);
}

/**
* Returns path separator.
*/
public static String getPathSeparator() {
public static String pathSeparator() {
return System.getProperty(PATH_SEPARATOR);
}

/**
* Returns file encoding.
*/
public static String getFileEncoding() {
public static String fileEncoding() {
return System.getProperty(FILE_ENCODING);
}

/**
* Returns <code>true</code> if host is Windows.
*/
public static boolean isHostWindows() {
return getOsName().toUpperCase().startsWith("WINDOWS");
return osName().toUpperCase().startsWith("WINDOWS");
}

/**
* Returns <code>true</code> if host is Linux.
*/
public static boolean isHostLinux() {
return getOsName().toUpperCase().startsWith("LINUX");
return osName().toUpperCase().startsWith("LINUX");
}

/**
Expand All @@ -342,21 +342,21 @@ public static boolean isHostUnix() {
* Returns <code>true</code> if host is Mac.
*/
public static boolean isHostMac() {
return getOsName().toUpperCase().startsWith("MAC OS X");
return osName().toUpperCase().startsWith("MAC OS X");
}

/**
* Returns <code>true</code> if host is Solaris.
*/
public static boolean isHostSolaris() {
return getOsName().toUpperCase().startsWith("SUNOS");
return osName().toUpperCase().startsWith("SUNOS");
}

/**
* Returns <code>true</code> if host is AIX.
*/
public static boolean isHostAix() {
return getOsName().toUpperCase().equals("AIX");
return osName().toUpperCase().equals("AIX");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
* <b>parent</b> group rules will be checked first.
* <p>
* By default, the list of <b>parent-only</b> group is populated with
* {@link jodd.util.SystemUtil#getJrePackages() JRE packages}.
* {@link jodd.util.SystemUtil#jrePackages() JRE packages}.
* <p>
* When <b>parent-last</b> strategy is used, be aware how you use
* {@link jodd.util.ClassLoaderUtil} as it is designed to follow <b>parent-first</b>
Expand Down Expand Up @@ -96,7 +96,7 @@ public ExtendedURLClassLoader(
loaderOnlyRules = new String[0];

if (excludeJrePackagesFromLoader) {
String[] corePackages = SystemUtil.getJrePackages();
String[] corePackages = SystemUtil.jrePackages();

for (String corePackage : corePackages) {
if (corePackage.equals("javax")) {
Expand Down
2 changes: 1 addition & 1 deletion jodd-core/src/test/java/jodd/cache/FileLFUCacheTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

public class FileLFUCacheTest {

private File tempFolder = new File(SystemUtil.getTempDir());
private File tempFolder = new File(SystemUtil.tempDir());

private File file(String fileName, int size) throws IOException {
byte[] bytes = new byte[size];
Expand Down
2 changes: 1 addition & 1 deletion jodd-joy/src/main/java/jodd/joy/core/DefaultAppCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ protected void resolveAppDir(String classPathFileName) {
int ndx = appDir.indexOf("WEB-INF");
isWebApplication = (ndx != -1);

appDir = isWebApplication ? appDir.substring(0, ndx) : SystemUtil.getWorkingFolder();
appDir = isWebApplication ? appDir.substring(0, ndx) : SystemUtil.workingFolder();
}

// ---------------------------------------------------------------- ready
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public HtmlStaplerBundlesManager(String contextPath, String webRoot, Strategy st
this.contextPath = contextPath;
this.webRoot = webRoot;
this.strategy = strategy;
this.bundleFolder = SystemUtil.getTempDir();
this.bundleFolder = SystemUtil.tempDir();

if (strategy == Strategy.ACTION_MANAGED) {
actionBundles = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class DiskFileUploadFactory implements FileUploadFactory {
protected int maxFileSize = 102400;

public DiskFileUploadFactory() throws IOException {
this(SystemUtil.getTempDir());
this(SystemUtil.tempDir());
}

public DiskFileUploadFactory(String destFolder) throws IOException {
Expand All @@ -59,7 +59,7 @@ public DiskFileUploadFactory(String destFolder, int maxFileSize) throws IOExcept

public DiskFileUploadFactory setUploadDir(String destFolder) throws IOException {
if (destFolder == null) {
destFolder = SystemUtil.getTempDir();
destFolder = SystemUtil.tempDir();
}
File destination = new File(destFolder);
if (destination.exists() == false) {
Expand Down

0 comments on commit da30445

Please sign in to comment.