Package org.jline.builtins.telnet
Class ConnectionData
java.lang.Object
org.jline.builtins.telnet.ConnectionData
An utility class that is used to store and allow retrieval
of all data associated with a connection.
- Version:
- 2.0 (16/07/2006)
- Author:
- Dieter Wimberger
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConnectionData
(Socket sock, ConnectionManager cm) Constructs a ConnectionData instance storing vital information about a connection. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activity()
Sets a new timestamp to the actual time in millis retrieved from the System.Returns the hashmap for storing and retrieving environment variables to be passed between shells.Returns the IP address of the connection.Returns the fully qualified host name for the connection's IP address.
The name is cached on creation for performance reasons.Returns the InetAddress object associated with the connection.long
Returns a timestamp of the last activity that happened on the associated connection.Returns the Locale object associated with the connection by carrying out a simple domain match.Returns the login shell name.Returns a reference to the ConnectionManager the connection is associated with.Returns the terminal type that has been negotiated between the telnet client and the telnet server, in of a String.int
getPort()
Returns the remote port to which the socket is connected.Returns a reference to the socket the Connection is associated with.int
Returns the width of the terminal in columns for convenience.int[]
Returns the terminal geometry in an array of two integers.int
Returns the height of the terminal in rows for convenience.boolean
Tests if in line mode.boolean
Returns the state of the terminal geometry changed flag, which will be true if it has been set, and false if not.boolean
isWarned()
Returns the state of the idle warning flag, which will be true if a warning has been issued, and false if not.void
setLineMode
(boolean b) Sets the line mode flag for the connection.void
Sets the login shell name.void
setNegotiatedTerminalType
(String termtype) Sets the terminal type that has been negotiated between telnet client and telnet server, in form of a String.void
setTerminalGeometry
(int width, int height) Sets the terminal geometry data.
This method should not be called explicitly by the application (i.e.void
setWarned
(boolean bool) Sets the state of the idle warning flag.
Note that this method will also update the the timestamp if the idle warning flag is removed, which means its kind of a second way to achieve the same thing as with the activity method.
-
Constructor Details
-
ConnectionData
Constructs a ConnectionData instance storing vital information about a connection.- Parameters:
sock
- Socket of the inbound connection.cm
- the connection manager
-
-
Method Details
-
getManager
Returns a reference to the ConnectionManager the connection is associated with.- Returns:
- Reference to the associated ConnectionManager.
- See Also:
-
getSocket
Returns a reference to the socket the Connection is associated with.- Returns:
- Reference to the associated Socket.
- See Also:
-
getPort
public int getPort()Returns the remote port to which the socket is connected.- Returns:
- String that contains the remote port number to which the socket is connected.
-
getHostName
Returns the fully qualified host name for the connection's IP address.
The name is cached on creation for performance reasons. Subsequent calls will not result in resolve queries.- Returns:
- String that contains the fully qualified host name for this address.
-
getHostAddress
Returns the IP address of the connection.- Returns:
- String that contains the connection's IP address.
The format "%d.%d.%d.%d" is well known, where %d goes from zero to 255.
-
getInetAddress
Returns the InetAddress object associated with the connection.- Returns:
- InetAddress associated with the connection.
-
getLocale
Returns the Locale object associated with the connection by carrying out a simple domain match.
This can either be effective, if your users are really home in the country they are connecting from, or ineffective if they are on the move getting connected from anywhere in the world.
Yet this gives the chance of capturing a default locale and starting from some point. On application context this can be by far better handled, so be aware that it makes sense to spend some thoughts on that thing when you build your application.- Returns:
- the Locale object "guessed" for the connection based on its host name.
-
getLastActivity
public long getLastActivity()Returns a timestamp of the last activity that happened on the associated connection.- Returns:
- the timestamp as a long representing the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
-
activity
public void activity()Sets a new timestamp to the actual time in millis retrieved from the System. This will remove an idle warning flag if it has been set. Note that you can use this behaviour to implement your own complex idle timespan policies within the context of your application.
The check frequency of the ConnectionManager should just be set according to the lowest time to warning and time to disconnect requirements. -
isWarned
public boolean isWarned()Returns the state of the idle warning flag, which will be true if a warning has been issued, and false if not.- Returns:
- the state of the idle warning flag.
-
setWarned
public void setWarned(boolean bool) Sets the state of the idle warning flag.
Note that this method will also update the the timestamp if the idle warning flag is removed, which means its kind of a second way to achieve the same thing as with the activity method.- Parameters:
bool
- true if a warning is to be issued, false if to be removed.- See Also:
-
setTerminalGeometry
public void setTerminalGeometry(int width, int height) Sets the terminal geometry data.
This method should not be called explicitly by the application (i.e. the its here for the io subsystem).
A call will set the terminal geometry changed flag.- Parameters:
width
- of the terminal in columns.height
- of the terminal in rows.
-
getTerminalGeometry
public int[] getTerminalGeometry()Returns the terminal geometry in an array of two integers.- index 0: Width in columns.
- index 1: Height in rows.
- Returns:
- integer array containing width and height.
-
getTerminalColumns
public int getTerminalColumns()Returns the width of the terminal in columns for convenience.- Returns:
- the number of columns.
-
getTerminalRows
public int getTerminalRows()Returns the height of the terminal in rows for convenience.- Returns:
- the number of rows.
-
isTerminalGeometryChanged
public boolean isTerminalGeometryChanged()Returns the state of the terminal geometry changed flag, which will be true if it has been set, and false if not.- Returns:
- the state of the terminal geometry changed flag.
-
getNegotiatedTerminalType
Returns the terminal type that has been negotiated between the telnet client and the telnet server, in of a String.- Returns:
- the negotiated terminal type as String.
-
setNegotiatedTerminalType
Sets the terminal type that has been negotiated between telnet client and telnet server, in form of a String.This method should not be called explicitly by the application (i.e. the its here for the io subsystem).
- Parameters:
termtype
- the negotiated terminal type as String.
-
getEnvironment
Returns the hashmap for storing and retrieving environment variables to be passed between shells.- Returns:
- a
HashMap
instance.
-
getLoginShell
Returns the login shell name.- Returns:
- the shell name as string.
-
setLoginShell
Sets the login shell name.- Parameters:
s
- the shell name as string.
-
isLineMode
public boolean isLineMode()Tests if in line mode.- Returns:
- true if in line mode, false otherwise
-
setLineMode
public void setLineMode(boolean b) Sets the line mode flag for the connection. Note that the setting will only be used at startup at the moment.- Parameters:
b
- true if to be initialized in linemode, false otherwise.
-