Class: VertxWeb::LanguageHeader

Inherits:
Locale
  • Object
show all
Includes:
ParsedHeaderValue
Defined in:
/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb

Overview

A parsed language header. Delivers a more direct access to the individual elements of the header it represents

Constant Summary

@@j_api_type =
Object.new

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Locale

create

Class Method Details

+ (Boolean) accept?(obj)

Returns:

  • (Boolean)


22
23
24
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 22

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

+ (Object) DEFAULT_WEIGHT

If no "q" parameter is present, the default weight is 1.


167
168
169
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 167

def self.DEFAULT_WEIGHT
  Java::IoVertxExtWeb::LanguageHeader.DEFAULT_WEIGHT
end

+ (Object) j_api_type



31
32
33
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 31

def self.j_api_type
  @@j_api_type
end

+ (Object) j_class



34
35
36
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 34

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

+ (Object) unwrap(obj)



28
29
30
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 28

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

+ (Object) wrap(obj)



25
26
27
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 25

def @@j_api_type.wrap(obj)
  LanguageHeader.new(obj)
end

Instance Method Details

- (String) country

Returns the country as reported by the HTTP client.

Returns:

  • (String)
    variant

Raises:

  • (ArgumentError)


123
124
125
126
127
128
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 123

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

- (String) language

Returns the language as reported by the HTTP client.

Returns:

  • (String)
    language

Raises:

  • (ArgumentError)


115
116
117
118
119
120
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 115

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

- (true, false) matched_by?(matchTry = nil)

Test if this header is matched by matchTry header

Parameters:

Returns:

  • (true, false)
    true if this header represents a subset of matchTry, otherwise, false

Raises:

  • (ArgumentError)


99
100
101
102
103
104
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 99

def matched_by?(matchTry=nil)
  if matchTry.class.method_defined?(:j_del) && !block_given?
    return @j_del.java_method(:isMatchedBy, [Java::IoVertxExtWeb::ParsedHeaderValue.java_class]).call(matchTry.j_del)
  end
  raise ArgumentError, "Invalid arguments when calling matched_by?(#{matchTry})"
end

- (String) parameter(key = nil)

The value of the parameter specified by this key. Each is one of 3 things:
  1. null <- That key was not specified
  2. ParsedHeaderValue.EMPTY (tested using ==) <- The value was not specified
  3. [Other] <- The value of the parameter
Note: The q parameter is never present.

Parameters:

  • key (String) (defaults to: nil)

Returns:

  • (String)

Raises:

  • (ArgumentError)


73
74
75
76
77
78
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 73

def parameter(key=nil)
  if key.class == String && !block_given?
    return @j_del.java_method(:parameter, [Java::java.lang.String.java_class]).call(key)
  end
  raise ArgumentError, "Invalid arguments when calling parameter(#{key})"
end

- (Hash{String => String}) parameters

The parameters specified in this header value. Note: The q parameter is never present.

Returns:

  • (Hash{String => String})
    Unmodifiable Map of parameters of this header value

Raises:

  • (ArgumentError)


82
83
84
85
86
87
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 82

def parameters
  if !block_given?
    return Java::IoVertxLangRuby::Helper.adaptingMap(@j_del.java_method(:parameters, []).call(), Proc.new { |val| ::Vertx::Util::Utils.from_object(val) }, Proc.new { |val| ::Vertx::Util::Utils.to_string(val) })
  end
  raise ArgumentError, "Invalid arguments when calling parameters()"
end

- (true, false) permitted?

Is this an allowed operation as specified by the corresponding header?

Returns:

  • (true, false)

Raises:

  • (ArgumentError)


90
91
92
93
94
95
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 90

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

- (String) raw_value

Contains the raw value that was received from the user agent

Returns:

  • (String)

Raises:

  • (ArgumentError)


39
40
41
42
43
44
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 39

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

- (String) subtag(level = nil)

A subtag of this language header.
+ info: rfc7231#section-3.1.3.1

Parameters:

  • level (Fixnum) (defaults to: nil)

Returns:

  • (String)
    The language subtag at specified position

Raises:

  • (ArgumentError)


151
152
153
154
155
156
157
158
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 151

def subtag(level=nil)
  if !block_given? && level == nil
    return @j_del.java_method(:subtag, []).call()
  elsif level.class == Fixnum && !block_given?
    return @j_del.java_method(:subtag, [Java::int.java_class]).call(level)
  end
  raise ArgumentError, "Invalid arguments when calling subtag(#{level})"
end

- (Fixnum) subtag_count

Returns the number of subtags this value has

Returns:

  • (Fixnum)
    the number of subtags this value has

Raises:

  • (ArgumentError)


160
161
162
163
164
165
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 160

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

- (String) tag

The tag of the language as specified by rfc7231#section-3.1.3.1.
Equivalent to

Returns:

  • (String)
    The language tag

Raises:

  • (ArgumentError)


141
142
143
144
145
146
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 141

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

- (String) value

Holds the unparsed value of the header.
For the most part, this is the content before the semi-colon (";")

Returns:

  • (String)

Raises:

  • (ArgumentError)


48
49
50
51
52
53
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 48

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

- (String) variant

Returns the variant as reported by the HTTP client.

Returns:

  • (String)
    variant

Raises:

  • (ArgumentError)


131
132
133
134
135
136
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 131

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

- (Float) weight

Holds the weight specified in the "q" parameter of the header.
If the parameter is not specified, 1.0 is assumed according to rfc7231

Returns:

  • (Float)

Raises:

  • (ArgumentError)


58
59
60
61
62
63
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 58

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

- (Fixnum) weighted_order

An integer that represents the absolute order position of this header

Returns:

  • (Fixnum)

Raises:

  • (ArgumentError)


107
108
109
110
111
112
# File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx-web/language_header.rb', line 107

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