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)

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (::VertxWeb::Cookie) cookie(name = nil, value = nil)
  Create a new cookie.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## 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
  The domain for the cookie.
- - (String) get_name
  The name of this cookie.
- - (String) get_path
  The path for this cookie.
- - (String) get_value
  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

### + (`Boolean`) accept?(obj)

Returns:

- (`Boolean`)

    21
    22
    23
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 21

    def @@j_api_type.accept?(obj)
      obj.class == Cookie
    end

### + (`::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`)

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

    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

### + (`Object`) j_api_type

    30
    31
    32
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 30

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

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

    def self.j_class
      Java::IoVertxExtWeb::Cookie.java_class
    end

### + (`Object`) unwrap(obj)

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

    def @@j_api_type.unwrap(obj)
      obj.j_del
    end

### + (`Object`) wrap(obj)

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

    def @@j_api_type.wrap(obj)
      Cookie.new(obj)
    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`)

    153
    154
    155
    156
    157
    158
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 153

    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`)

    145
    146
    147
    148
    149
    150
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 145

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

### - (`String`) get_domain

Returns the domain for the cookie

Returns:

- (`String`) —
  the domain for the cookie

Raises:

- (`ArgumentError`)

    81
    82
    83
    84
    85
    86
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 81

    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

Returns the name of this cookie

Returns:

- (`String`) —
  the name of this cookie

Raises:

- (`ArgumentError`)

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

    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`)

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

    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

Returns the value of this cookie

Returns:

- (`String`) —
  the value of this cookie

Raises:

- (`ArgumentError`)

    54
    55
    56
    57
    58
    59
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 54

    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`)

    163
    164
    165
    166
    167
    168
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 163

    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`)

    73
    74
    75
    76
    77
    78
    79
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 73

    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`)

    136
    137
    138
    139
    140
    141
    142
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 136

    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`)

    112
    113
    114
    115
    116
    117
    118
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 112

    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`)

    90
    91
    92
    93
    94
    95
    96
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 90

    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`)

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

    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`)

    63
    64
    65
    66
    67
    68
    69
    # File '/Users/julien/java/vertx-stack/stack-docs/target/rb/vertx-web/cookie.rb', line 63

    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