Package jnr.posix.util
Class DefaultPOSIXHandler
- java.lang.Object
-
- jnr.posix.util.DefaultPOSIXHandler
-
- All Implemented Interfaces:
POSIXHandler
public class DefaultPOSIXHandler extends java.lang.Object implements POSIXHandler
A POSIXHandler with reasonable default behavior.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jnr.posix.POSIXHandler
POSIXHandler.WARNING_ID
-
-
Constructor Summary
Constructors Constructor Description DefaultPOSIXHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
error(jnr.constants.platform.Errno error, java.lang.String extraData)
void
error(jnr.constants.platform.Errno error, java.lang.String methodName, java.lang.String extraData)
java.io.File
getCurrentWorkingDirectory()
java.lang.String[]
getEnv()
java.io.PrintStream
getErrorStream()
Get your runtime's current ErrorStreamjava.io.InputStream
getInputStream()
java.io.PrintStream
getOutputStream()
int
getPID()
Get your runtime's process ID.boolean
isVerbose()
void
unimplementedError(java.lang.String methodName)
Specify that posix method is unimplemented.void
warn(POSIXHandler.WARNING_ID id, java.lang.String message, java.lang.Object... data)
-
-
-
Method Detail
-
error
public void error(jnr.constants.platform.Errno error, java.lang.String extraData)
- Specified by:
error
in interfacePOSIXHandler
-
error
public void error(jnr.constants.platform.Errno error, java.lang.String methodName, java.lang.String extraData)
- Specified by:
error
in interfacePOSIXHandler
-
unimplementedError
public void unimplementedError(java.lang.String methodName)
Description copied from interface:POSIXHandler
Specify that posix method is unimplemented. In JRuby we generate an exception with this.- Specified by:
unimplementedError
in interfacePOSIXHandler
- Parameters:
methodName
- the POSIX method that failed
-
warn
public void warn(POSIXHandler.WARNING_ID id, java.lang.String message, java.lang.Object... data)
- Specified by:
warn
in interfacePOSIXHandler
-
isVerbose
public boolean isVerbose()
- Specified by:
isVerbose
in interfacePOSIXHandler
- Returns:
- should we provide verbose output about POSIX activities
-
getCurrentWorkingDirectory
public java.io.File getCurrentWorkingDirectory()
- Specified by:
getCurrentWorkingDirectory
in interfacePOSIXHandler
- Returns:
- current working directory of your runtime.
-
getEnv
public java.lang.String[] getEnv()
- Specified by:
getEnv
in interfacePOSIXHandler
- Returns:
- current set of environment variables of your runtime.
-
getInputStream
public java.io.InputStream getInputStream()
- Specified by:
getInputStream
in interfacePOSIXHandler
- Returns:
- your runtime's current input stream
-
getOutputStream
public java.io.PrintStream getOutputStream()
- Specified by:
getOutputStream
in interfacePOSIXHandler
- Returns:
- your runtime's current output stream
-
getPID
public int getPID()
Description copied from interface:POSIXHandler
Get your runtime's process ID. This is only intended for non-native POSIX support (e.g. environments where JNA cannot load or security restricted environments). In JRuby we found a number of packages which would rather have some identity for the runtime than nothing. Note: If you do not want this to work you impl can just callPOSIXHandler.unimplementedError(String)
.- Specified by:
getPID
in interfacePOSIXHandler
- Returns:
- your runtime's process ID
-
getErrorStream
public java.io.PrintStream getErrorStream()
Description copied from interface:POSIXHandler
Get your runtime's current ErrorStream- Specified by:
getErrorStream
in interfacePOSIXHandler
- Returns:
- your runtime's current error stream
-
-