Class List Method List File List

# Class: VertxWeb::Cookie

Inherits:
  Object
  - Object
  - VertxWeb::Cookie
  show all
Defined in:
  /Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb

## Overview

Represents an HTTP Cookie.

All cookies must have a name and a value and can optionally have other fields set such as path, domain, etc.

(Derived from io.netty.handler.codec.http.Cookie)

## Class Method Summary (collapse)

- + (::VertxWeb::Cookie) cookie(name = nil, value = nil)
  Create a new cookie.

## Instance Method Summary (collapse)

- - (true, false) changed?
  Has the cookie been changed? Changed cookies will be saved out in the response and sent to the browser.
- - (String) encode
  Encode the cookie to a string.
- - (String) get_domain
  @return the domain for the cookie.
- - (String) get_name
  @return the name of this cookie.
- - (String) get_path
  The path for this cookie.
- - (String) get_value
  @return the value of this cookie.
- - (void) set_changed(changed = nil)
  Set the cookie as being changed.
- - (self) set_domain(domain = nil)
  Sets the domain of this cookie.
- - (self) set_http_only(httpOnly = nil)
  Determines if this cookie is HTTP only.
- - (self) set_max_age(maxAge = nil)
  Sets the maximum age of this cookie in seconds.
- - (self) set_path(path = nil)
  Sets the path of this cookie.
- - (self) set_secure(secure = nil)
  Sets the security getStatus of this cookie.
- - (self) set_value(value = nil)
  Sets the value of this cookie.

## Class Method Details

### + (`::VertxWeb::Cookie`) cookie(name = nil, value = nil)

Create a new cookie

Parameters:

- name (`String`) (defaults to: `nil`) —
  the name of the cookie
- value (`String`) (defaults to: `nil`) —
  the cookie value

Returns:

- (`::VertxWeb::Cookie`) —
  the cookie

Raises:

- (`ArgumentError`)

    24
    25
    26
    27
    28
    29
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 24

    def self.cookie(name=nil,value=nil)
      if name.class == String && value.class == String && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxExtWeb::Cookie.java_method(:cookie, [Java::java.lang.String.java_class,Java::java.lang.String.java_class]).call(name,value),::VertxWeb::Cookie)
      end
      raise ArgumentError, "Invalid arguments when calling cookie(name,value)"
    end

## Instance Method Details

### - (`true`, `false`) changed?

Has the cookie been changed? Changed cookies will be saved out in the response and sent to the browser.

Returns:

- (`true`, `false`) —
  true if changed

Raises:

- (`ArgumentError`)

    140
    141
    142
    143
    144
    145
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 140

    def changed?
      if !block_given?
        return @j_del.java_method(:isChanged, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling changed?()"
    end

### - (`String`) encode

Encode the cookie to a string. This is what is used in the Set-Cookie header

Returns:

- (`String`) —
  the encoded cookie

Raises:

- (`ArgumentError`)

    132
    133
    134
    135
    136
    137
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 132

    def encode
      if !block_given?
        return @j_del.java_method(:encode, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling encode()"
    end

### - (`String`) get_domain

@return the domain for the cookie

Returns:

- (`String`)

Raises:

- (`ArgumentError`)

    68
    69
    70
    71
    72
    73
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 68

    def get_domain
      if !block_given?
        return @j_del.java_method(:getDomain, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling get_domain()"
    end

### - (`String`) get_name

@return the name of this cookie

Returns:

- (`String`)

Raises:

- (`ArgumentError`)

    32
    33
    34
    35
    36
    37
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 32

    def get_name
      if !block_given?
        return @j_del.java_method(:getName, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling get_name()"
    end

### - (`String`) get_path

Returns the path for this cookie

Returns:

- (`String`) —
  the path for this cookie

Raises:

- (`ArgumentError`)

    85
    86
    87
    88
    89
    90
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 85

    def get_path
      if !block_given?
        return @j_del.java_method(:getPath, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling get_path()"
    end

### - (`String`) get_value

@return the value of this cookie

Returns:

- (`String`)

Raises:

- (`ArgumentError`)

    40
    41
    42
    43
    44
    45
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 40

    def get_value
      if !block_given?
        return @j_del.java_method(:getValue, []).call()
      end
      raise ArgumentError, "Invalid arguments when calling get_value()"
    end

### - (`void`) set_changed(changed = nil)

This method returns an undefined value.

Set the cookie as being changed. Changed will be true for a cookie just created, false by default if just read from the request

Parameters:

- changed (`true`, `false`) (defaults to: `nil`) —
  true if changed

Raises:

- (`ArgumentError`)

    150
    151
    152
    153
    154
    155
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 150

    def set_changed(changed=nil)
      if (changed.class == TrueClass || changed.class == FalseClass) && !block_given?
        return @j_del.java_method(:setChanged, [Java::boolean.java_class]).call(changed)
      end
      raise ArgumentError, "Invalid arguments when calling set_changed(changed)"
    end

### - (`self`) set_domain(domain = nil)

Sets the domain of this cookie

Parameters:

- domain (`String`) (defaults to: `nil`) —
  The domain to use

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    59
    60
    61
    62
    63
    64
    65
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 59

    def set_domain(domain=nil)
      if domain.class == String && !block_given?
        @j_del.java_method(:setDomain, [Java::java.lang.String.java_class]).call(domain)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_domain(domain)"
    end

### - (`self`) set_http_only(httpOnly = nil)

Determines if this cookie is HTTP only. If set to true, this cookie cannot be accessed by a client side script. However, this works only if the browser supports it. For for information, please look here.

Parameters:

- httpOnly (`true`, `false`) (defaults to: `nil`) —
  True if the cookie is HTTP only, otherwise false.

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    123
    124
    125
    126
    127
    128
    129
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 123

    def set_http_only(httpOnly=nil)
      if (httpOnly.class == TrueClass || httpOnly.class == FalseClass) && !block_given?
        @j_del.java_method(:setHttpOnly, [Java::boolean.java_class]).call(httpOnly)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_http_only(httpOnly)"
    end

### - (`self`) set_max_age(maxAge = nil)

Sets the maximum age of this cookie in seconds. If an age of `0` is specified, this cookie will be automatically removed by browser because it will expire immediately. If MIN_VALUE is specified, this cookie will be removed when the browser is closed. If you don't set this the cookie will be a session cookie and be removed when the browser is closed.

Parameters:

- maxAge (`Fixnum`) (defaults to: `nil`) —
  The maximum age of this cookie in seconds

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    99
    100
    101
    102
    103
    104
    105
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 99

    def set_max_age(maxAge=nil)
      if maxAge.class == Fixnum && !block_given?
        @j_del.java_method(:setMaxAge, [Java::long.java_class]).call(maxAge)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_max_age(maxAge)"
    end

### - (`self`) set_path(path = nil)

Sets the path of this cookie.

Parameters:

- path (`String`) (defaults to: `nil`) —
  The path to use for this cookie

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    77
    78
    79
    80
    81
    82
    83
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 77

    def set_path(path=nil)
      if path.class == String && !block_given?
        @j_del.java_method(:setPath, [Java::java.lang.String.java_class]).call(path)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_path(path)"
    end

### - (`self`) set_secure(secure = nil)

Sets the security getStatus of this cookie

Parameters:

- secure (`true`, `false`) (defaults to: `nil`) —
  True if this cookie is to be secure, otherwise false

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    109
    110
    111
    112
    113
    114
    115
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 109

    def set_secure(secure=nil)
      if (secure.class == TrueClass || secure.class == FalseClass) && !block_given?
        @j_del.java_method(:setSecure, [Java::boolean.java_class]).call(secure)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_secure(secure)"
    end

### - (`self`) set_value(value = nil)

Sets the value of this cookie

Parameters:

- value (`String`) (defaults to: `nil`) —
  The value to set

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    49
    50
    51
    52
    53
    54
    55
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 49

    def set_value(value=nil)
      if value.class == String && !block_given?
        @j_del.java_method(:setValue, [Java::java.lang.String.java_class]).call(value)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling set_value(value)"
    end