Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Protected Ctors](https://developer.android.com/reference/javax/net/ssl/SNIServerName#proctors) \| [Methods](https://developer.android.com/reference/javax/net/ssl/SNIServerName#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/javax/net/ssl/SNIServerName#inhmethods)

# SNIServerName


`
public


abstract
class
SNIServerName
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | javax.net.ssl.SNIServerName |

|---|
| Known direct subclasses [SNIHostName](https://developer.android.com/reference/javax/net/ssl/SNIHostName) |---|---| | [SNIHostName](https://developer.android.com/reference/javax/net/ssl/SNIHostName) | Instances of this class represent a server name of type `https://developer.android.com/reference/javax/net/ssl/StandardConstants#SNI_HOST_NAME` in a Server Name Indication (SNI) extension. | |

<br />

*** ** * ** ***

Instances of this class represent a server name in a Server Name
Indication (SNI) extension.


The SNI extension is a feature that extends the SSL/TLS protocols to
indicate what server name the client is attempting to connect to during
handshaking. See section 3, "Server Name Indication", of [TLS Extensions (RFC 6066)](http://www.ietf.org/rfc/rfc6066.txt).


`SNIServerName` objects are immutable. Subclasses should not provide
methods that can change the state of an instance once it has been created.
**See also:**

- `https://developer.android.com/reference/javax/net/ssl/SSLParameters#getServerNames()`
- `https://developer.android.com/reference/javax/net/ssl/SSLParameters#setServerNames(java.util.List<javax.net.ssl.SNIServerName>)`

## Summary

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/javax/net/ssl/SNIServerName#SNIServerName(int,%20byte[])(int type, byte[] encoded) ` Creates an `SNIServerName` using the specified name type and encoded value. |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/javax/net/ssl/SNIServerName#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object other) ` Indicates whether some other object is "equal to" this server name. |
| ` final byte[]` | ` https://developer.android.com/reference/javax/net/ssl/SNIServerName#getEncoded()() ` Returns a copy of the encoded server name value of this server name. |
| ` final int` | ` https://developer.android.com/reference/javax/net/ssl/SNIServerName#getType()() ` Returns the name type of this server name. |
| ` int` | ` https://developer.android.com/reference/javax/net/ssl/SNIServerName#hashCode()() ` Returns a hash code value for this server name. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/javax/net/ssl/SNIServerName#toString()() ` Returns a string representation of this server name, including the server name type and the encoded server name value in this `SNIServerName` object. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Protected constructors

### SNIServerName

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected SNIServerName (int type, 
                byte[] encoded)
```

Creates an `SNIServerName` using the specified name type and
encoded value.


Note that the `encoded` byte array is cloned to protect against
subsequent modification.

<br />

| Parameters ||
|---|---|
| `type` | `int`: the type of the server name <br /> |
| `encoded` | `byte`: the encoded value of the server name <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `type` is not in the range of 0 to 255, inclusive. |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `encoded` is null |

## Public methods

### equals

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object other)
```

Indicates whether some other object is "equal to" this server name.

<br />

| Parameters ||
|---|---|
| `other` | `Object`: the reference object with which to compare. <br /> |

| Returns ||
|---|---|
| `boolean` | true if, and only if, `other` is of the same class of this object, and has the same name type and encoded value as this server name. <br /> |

### getEncoded

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final byte[] getEncoded ()
```

Returns a copy of the encoded server name value of this server name.

<br />

| Returns ||
|---|---|
| `byte[]` | a copy of the encoded server name value of this server name <br /> |

### getType

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public final int getType ()
```

Returns the name type of this server name.

<br />

| Returns ||
|---|---|
| `int` | the name type of this server name <br /> |

### hashCode

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int hashCode ()
```

Returns a hash code value for this server name.


The hash code value is generated using the name type and encoded
value of this server name.

<br />

| Returns ||
|---|---|
| `int` | a hash code value for this server name. <br /> |

### toString

Added in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of this server name, including the server
name type and the encoded server name value in this
`SNIServerName` object.


The exact details of the representation are unspecified and subject
to change, but the following may be regarded as typical:

```
    "type=<name type>, value=<name value>"
```


In this class, the format of "\<name type\>" is
"\[LITERAL\] (INTEGER)", where the optional "LITERAL" is the literal
name, and INTEGER is the integer value of the name type. The format
of "\<name value\>" is "XX:...:XX", where "XX" is the
hexadecimal digit representation of a byte value. For example, a
returned value of an pseudo server name may look like:

```
    "type=(31), value=77:77:77:2E:65:78:61:6D:70:6C:65:2E:63:6E"
```
or

```
    "type=host_name (0), value=77:77:77:2E:65:78:61:6D:70:6C:65:2E:63:6E"
```


Please NOTE that the exact details of the representation are unspecified
and subject to change, and subclasses may override the method with
their own formats.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of this server name <br /> |