Enum Scheme

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Scheme>

    public enum Scheme
    extends java.lang.Enum<Scheme>
    The Scheme represents a scheme used for a URI. Here only schemes that directly relate to HTTP are provided, which includes HTTP/1.1 schemes and WebSocket 1.0 schemes.
    Author:
    Niall Gallagher
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      HTTP
      This represents the scheme for a plaintext HTTP connection.
      HTTPS
      This represents the scheme for a HTTP over TLS connection.
      WS
      This represents the scheme for a plaintext WebSocket connection.
      WSS
      This represents the scheme for WebSocket over TLS connection.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.lang.String scheme
      This is the actual scheme token that is to be used in the URI.
      boolean secure
      This is used to determine if the connection is secure or not.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getScheme()
      This is used to acquire the scheme token for this.
      boolean isSecure()
      This is used to determine if the scheme is secure or not.
      static Scheme resolveScheme​(java.lang.String token)
      This is used to resolve the scheme given a token.
      static Scheme resolveScheme​(java.net.URI target)
      This is used to resolve the scheme given a URI.
      static Scheme valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static Scheme[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • HTTP

        public static final Scheme HTTP
        This represents the scheme for a plaintext HTTP connection.
      • HTTPS

        public static final Scheme HTTPS
        This represents the scheme for a HTTP over TLS connection.
      • WS

        public static final Scheme WS
        This represents the scheme for a plaintext WebSocket connection.
      • WSS

        public static final Scheme WSS
        This represents the scheme for WebSocket over TLS connection.
    • Field Detail

      • scheme

        public final java.lang.String scheme
        This is the actual scheme token that is to be used in the URI.
      • secure

        public final boolean secure
        This is used to determine if the connection is secure or not.
    • Method Detail

      • values

        public static Scheme[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Scheme c : Scheme.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Scheme valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • isSecure

        public boolean isSecure()
        This is used to determine if the scheme is secure or not. In general a secure scheme is one sent over a SSL/TLS connection.
        Returns:
        this returns true if the scheme is a secure one
      • getScheme

        public java.lang.String getScheme()
        This is used to acquire the scheme token for this. The scheme token can be used to prefix a absolute fully qualified URI.
        Returns:
        the scheme token representing this scheme
      • resolveScheme

        public static Scheme resolveScheme​(java.lang.String token)
        This is used to resolve the scheme given a token. If there is no matching scheme for the provided token a default of HTTP is provided.
        Parameters:
        token - this is the token used to determine the scheme
        Returns:
        this returns the match or HTTP if none matched
      • resolveScheme

        public static Scheme resolveScheme​(java.net.URI target)
        This is used to resolve the scheme given a URI. If there is no matching scheme for the provided instance then this will return null.
        Parameters:
        token - this is the object to resolve a scheme for
        Returns:
        this returns the match or null if none matched