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 String
ADAMS_USERDIR
environment variable for overriding the current working dir (user.dir).static String
ADAMS_USERHOME
environment variable for overriding the user home dir (user.home).static String
ADAMS_USERNAME
environment variable for overriding the user name (user.name).protected static Integer
m_GroupID
the user's group ID.protected static String
m_UserDir
the user dir (CWD).protected static String
m_UserHome
the user home.protected static Integer
m_UserID
the user ID.protected static String
m_UserName
the user name.
-
Constructor Summary
Constructors Constructor Description User()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static String
cmdOutput(String[] cmd, String defValue)
Runs the specified command and returns the output from stdout.static String
getCWD()
Returns the user's current working directory.static int
getGroupID()
Returns the user's group ID for *nix-like systems (id -g).static String
getHomeDir()
Returns the user's home directory.static String
getName()
Returns the user name.static int
getUserID()
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_USERNAME
environment variable.- Returns:
- the name
- See Also:
ADAMS_USERHOME
-
getHomeDir
public static String getHomeDir()
Returns the user's home directory. Can be overridden withADAMS_USERHOME
environment variable.- Returns:
- the directory
- See Also:
ADAMS_USERHOME
-
getCWD
public static String getCWD()
Returns the user's current working directory. Can be overridden withADAMS_USERDIR
environment 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
-
-