Package adams.core.management
Class User
- java.lang.Object
-
- adams.core.management.User
-
public class User extends Object
Class for returning information about the current user.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description static StringADAMS_USERDIRenvironment variable for overriding the current working dir (user.dir).static StringADAMS_USERHOMEenvironment variable for overriding the user home dir (user.home).static StringADAMS_USERNAMEenvironment variable for overriding the user name (user.name).protected static Integerm_GroupIDthe user's group ID.protected static Stringm_UserDirthe user dir (CWD).protected static Stringm_UserHomethe user home.protected static Integerm_UserIDthe user ID.protected static Stringm_UserNamethe user name.
-
Constructor Summary
Constructors Constructor Description User()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static StringcmdOutput(String[] cmd, String defValue)Runs the specified command and returns the output from stdout.static StringgetCWD()Returns the user's current working directory.static intgetGroupID()Returns the user's group ID for *nix-like systems (id -g).static StringgetHomeDir()Returns the user's home directory.static StringgetName()Returns the user name.static intgetUserID()Returns the user's ID for *nix-like systems (id -u).
-
-
-
Field Detail
-
ADAMS_USERNAME
public static final String ADAMS_USERNAME
environment variable for overriding the user name (user.name).- See Also:
- Constant Field Values
-
ADAMS_USERHOME
public static final String ADAMS_USERHOME
environment variable for overriding the user home dir (user.home).- See Also:
- Constant Field Values
-
ADAMS_USERDIR
public static final String ADAMS_USERDIR
environment variable for overriding the current working dir (user.dir).- See Also:
- Constant Field Values
-
m_UserName
protected static String m_UserName
the user name.
-
m_UserHome
protected static String m_UserHome
the user home.
-
m_UserDir
protected static String m_UserDir
the user dir (CWD).
-
m_UserID
protected static Integer m_UserID
the user ID.
-
m_GroupID
protected static Integer m_GroupID
the user's group ID.
-
-
Method Detail
-
getName
public static String getName()
Returns the user name. Can be overridden withADAMS_USERNAMEenvironment variable.- Returns:
- the name
- See Also:
ADAMS_USERHOME
-
getHomeDir
public static String getHomeDir()
Returns the user's home directory. Can be overridden withADAMS_USERHOMEenvironment variable.- Returns:
- the directory
- See Also:
ADAMS_USERHOME
-
getCWD
public static String getCWD()
Returns the user's current working directory. Can be overridden withADAMS_USERDIRenvironment variable.- Returns:
- the directory
- See Also:
ADAMS_USERDIR
-
cmdOutput
protected static String cmdOutput(String[] cmd, String defValue)
Runs the specified command and returns the output from stdout.- Parameters:
cmd- the command to rundefValue- the default output- Returns:
- the generated output or default value if failed to execute
-
getUserID
public static int getUserID()
Returns the user's ID for *nix-like systems (id -u).- Returns:
- the user ID, -1 if not available
-
getGroupID
public static int getGroupID()
Returns the user's group ID for *nix-like systems (id -g).- Returns:
- the group ID, -1 if not available
-
-