# Record Class ServletConnectionImpl

java.lang.Object
java.lang.Record
org.apache.tomcat.util.net.ServletConnectionImpl

All Implemented Interfaces:
  `ServletConnection`

public record ServletConnectionImpl(String connectionId, String protocol, String protocolConnectionId, boolean secure) extends Record implements ServletConnection

## Constructor Summary

Constructors
Constructor
Description
`ServletConnectionImpl(String connectionId, String protocol, String protocolConnectionId, boolean secure)`
Creates an instance of a `ServletConnectionImpl` record class.

## Method Summary

Modifier and Type
Method
Description
`String`
`connectionId()`
Returns the value of the `connectionId` record component.
`final boolean`
`equals(Object o)`
Indicates whether some other object is "equal to" this one.
`String`
`getConnectionId()`
Obtain a unique (within the lifetime of the JVM) identifier string for the network connection to the JVM that is being used for the `ServletRequest` from which this `ServletConnection` was obtained.
`String`
`getProtocol()`
Obtain the name of the protocol as presented to the server after the removal, if present, of any TLS or similar encryption.
`String`
`getProtocolConnectionId()`
Obtain the connection identifier for the network connection to the server that is being used for the `ServletRequest` from which this `ServletConnection` was obtained as defined by the protocol in use.
`final int`
`hashCode()`
Returns a hash code value for this object.
`boolean`
`isSecure()`
Determine whether the incoming network connection to the server used encryption or not.
`String`
`protocol()`
Returns the value of the `protocol` record component.
`String`
`protocolConnectionId()`
Returns the value of the `protocolConnectionId` record component.
`boolean`
`secure()`
Returns the value of the `secure` record component.
`final String`
`toString()`
Returns a string representation of this record class.

### Methods inherited from class Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### ServletConnectionImpl

public ServletConnectionImpl(String connectionId, String protocol, String protocolConnectionId, boolean secure)
Creates an instance of a `ServletConnectionImpl` record class.

Parameters:
  `connectionId` - the value for the `connectionId` record component
  `protocol` - the value for the `protocol` record component
  `protocolConnectionId` - the value for the `protocolConnectionId` record component
  `secure` - the value for the `secure` record component

## Method Details

### getConnectionId

public String getConnectionId()
Description copied from interface: `jakarta.servlet.ServletConnection`
Obtain a unique (within the lifetime of the JVM) identifier string for the network connection to the JVM that is being used for the `ServletRequest` from which this `ServletConnection` was obtained.

There is no defined format for this string. The format is implementation dependent.

Specified by:
  `getConnectionId` in interface `ServletConnection`
Returns:
  A unique identifier for the network connection

### getProtocol

public String getProtocol()
Description copied from interface: `jakarta.servlet.ServletConnection`
Obtain the name of the protocol as presented to the server after the removal, if present, of any TLS or similar encryption. This may not be the same as the protocol seen by the application. For example, a reverse proxy may present AJP whereas the application will see HTTP 1.1.

If the protocol has an entry in the IANA registry for ALPN names then the identification sequence, in string form, must be returned. Registered identification sequences MUST only be used for the associated protocol. Return values for other protocols are implementation dependent. Unknown protocols should return the string "unknown".

Specified by:
  `getProtocol` in interface `ServletConnection`
Returns:
  The name of the protocol presented to the server after decryption of TLS, or similar encryption, if any.

### getProtocolConnectionId

public String getProtocolConnectionId()
Description copied from interface: `jakarta.servlet.ServletConnection`
Obtain the connection identifier for the network connection to the server that is being used for the `ServletRequest` from which this `ServletConnection` was obtained as defined by the protocol in use. Note that some protocols do not define such an identifier.

Examples of protocol provided connection identifiers include:

HTTP 1.x
  None, so the empty string should be returned
HTTP 2
  None, so the empty string should be returned
HTTP 3
  The QUIC connection ID
AJP
  None, so the empty string should be returned

Specified by:
  `getProtocolConnectionId` in interface `ServletConnection`
Returns:
  The connection identifier if one is defined, otherwise an empty string

### isSecure

public boolean isSecure()
Description copied from interface: `jakarta.servlet.ServletConnection`
Determine whether the incoming network connection to the server used encryption or not. Note that where a reverse proxy is used, the application may have a different view as to whether encryption is being used due to the use of headers like `X-Forwarded-Proto`.

Specified by:
  `isSecure` in interface `ServletConnection`
Returns:
  `true` if the incoming network connection used encryption, otherwise `false`

### toString

public final String toString()
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.

Specified by:
  `toString` in class `Record`
Returns:
  a string representation of this object

### hashCode

public final int hashCode()
Returns a hash code value for this object. The value is derived from the hash code of each of the record components.

Specified by:
  `hashCode` in class `Record`
Returns:
  a hash code value for this object

### equals

public final boolean equals(Object o)
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with `Objects::equals(Object,Object)`; primitive components are compared with the `compare` method from their corresponding wrapper classes.

Specified by:
  `equals` in class `Record`
Parameters:
  `o` - the object with which to compare
Returns:
  `true` if this object is the same as the `o` argument; `false` otherwise.

### connectionId

public String connectionId()
Returns the value of the `connectionId` record component.

Returns:
  the value of the `connectionId` record component

### protocol

public String protocol()
Returns the value of the `protocol` record component.

Returns:
  the value of the `protocol` record component

### protocolConnectionId

public String protocolConnectionId()
Returns the value of the `protocolConnectionId` record component.

Returns:
  the value of the `protocolConnectionId` record component

### secure

public boolean secure()
Returns the value of the `secure` record component.

Returns:
  the value of the `secure` record component