Class List Method List File List

# Class: Vertx::JsonPointer

Inherits:
  Object
  - Object
  - Vertx::JsonPointer
  show all
Defined in:
  /Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb

## Overview

Implementation of RFC6901 Json Pointers.

## Constant Summary

@@j_api_type =

      Object.new

## Class Method Summary (collapse)

- + (Boolean) accept?(obj)
- + (::Vertx::JsonPointer) create
  Build an empty JsonPointer.
- + (::Vertx::JsonPointer) from(pointer = nil)
  Build a JsonPointer from a json pointer string.
- + (Object) j_api_type
- + (Object) j_class
- + (Object) unwrap(obj)
- + (Object) wrap(obj)

## Instance Method Summary (collapse)

- - (self) append(param_1 = nil)
  Append all tokens of pointer to this pointer Note: The base URI of this pointer will remain untouched.
- - (::Vertx::JsonPointer) copy
  Copy a JsonPointer.
- - (true, false) local_pointer?
  Return true if the pointer is local (URI with only fragment).
- - (self) parent
  Remove last reference token of this pointer.
- - (true, false) parent?(child = nil)
  Return true if this pointer is a parent pointer of child.
- - (Object) query(objectToQuery = nil, iterator = nil)
  Query objectToQuery using the provided JsonPointerIterator.
- - (Object) query_json(jsonElement = nil)
  Query jsonElement.
- - (Object) query_json_or_default(jsonElement = nil, defaultValue = nil)
  Query jsonElement.
- - (Object) query_or_default(objectToQuery = nil, iterator = nil, defaultValue = nil)
  Query objectToQuery using the provided JsonPointerIterator.
- - (true, false) root_pointer?
  Return true if the pointer is a root pointer.
- - (String) to_string
  Build a string representation of the JSON Pointer.
- - (Array<Object>) traced_query(objectToQuery = nil, iterator = nil)
  Query objectToQuery tracing each element walked during the query, including the first and the result (if any).
- - (Object) write(objectToWrite = nil, iterator = nil, newElement = nil, createOnMissing = nil)
  Write newElement in objectToWrite using this pointer.
- - (Object) write_json(jsonElement = nil, newElement = nil, createOnMissing = nil)
  Write newElement in jsonElement using this pointer.

## Class Method Details

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

Returns:

- (`Boolean`)

    18
    19
    20
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 18

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

### + (`::Vertx::JsonPointer`) create

Build an empty JsonPointer

Returns:

- (`::Vertx::JsonPointer`) —
  a new empty JsonPointer

Raises:

- (`ArgumentError`)

    197
    198
    199
    200
    201
    202
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 197

    def self.create
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxCoreJsonPointer::JsonPointer.java_method(:create, []).call(),::Vertx::JsonPointer)
      end
      raise ArgumentError, "Invalid arguments when calling create()"
    end

### + (`::Vertx::JsonPointer`) from(pointer = nil)

Build a JsonPointer from a json pointer string

Parameters:

- pointer (`String`) (defaults to: `nil`) —
  the string representing a pointer

Returns:

- (`::Vertx::JsonPointer`) —
  new instance of JsonPointer

Raises:

- (`ArgumentError`)

    206
    207
    208
    209
    210
    211
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 206

    def self.from(pointer=nil)
      if pointer.class == String && !block_given?
        return ::Vertx::Util::Utils.safe_create(Java::IoVertxCoreJsonPointer::JsonPointer.java_method(:from, [Java::java.lang.String.java_class]).call(pointer),::Vertx::JsonPointer)
      end
      raise ArgumentError, "Invalid arguments when calling from(#{pointer})"
    end

### + (`Object`) j_api_type

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

    def self.j_api_type
      @@j_api_type
    end

### + (`Object`) j_class

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

    def self.j_class
      Java::IoVertxCoreJsonPointer::JsonPointer.java_class
    end

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

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

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

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

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

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

## Instance Method Details

### - (`self`) append(token) - (`self`) append(index) - (`self`) append(tokens) - (`self`) append(pointer)

Append all tokens of `pointer` to this pointer
Note: The base URI of this pointer will remain untouched

Overloads:

- - (`self`) append(token)

  Parameters:

  - token (`String`) —
    the unescaped reference token
- - (`self`) append(index)

  Parameters:

  - index (`Fixnum`)
- - (`self`) append(tokens)

  Parameters:

  - tokens (`Array<String>`) —
    unescaped reference tokens
- - (`self`) append(pointer)

  Parameters:

  - pointer (`::Vertx::JsonPointer`) —
    other pointer

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 79

    def append(param_1=nil)
      if param_1.class == String && !block_given?
        @j_del.java_method(:append, [Java::java.lang.String.java_class]).call(param_1)
        return self
      elsif param_1.class == Fixnum && !block_given?
        @j_del.java_method(:append, [Java::int.java_class]).call(param_1)
        return self
      elsif param_1.class == Array && !block_given?
        @j_del.java_method(:append, [Java::JavaUtil::List.java_class]).call(param_1.map { |element| element })
        return self
      elsif param_1.class.method_defined?(:j_del) && !block_given?
        @j_del.java_method(:append, [Java::IoVertxCoreJsonPointer::JsonPointer.java_class]).call(param_1.j_del)
        return self
      end
      raise ArgumentError, "Invalid arguments when calling append(#{param_1})"
    end

### - (`::Vertx::JsonPointer`) copy

Copy a JsonPointer

Returns:

- (`::Vertx::JsonPointer`) —
  a copy of this pointer

Raises:

- (`ArgumentError`)

    189
    190
    191
    192
    193
    194
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 189

    def copy
      if !block_given?
        return ::Vertx::Util::Utils.safe_create(@j_del.java_method(:copy, []).call(),::Vertx::JsonPointer)
      end
      raise ArgumentError, "Invalid arguments when calling copy()"
    end

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

Return `true` if the pointer is local (URI with only fragment)

Returns:

- (`true`, `false`)

Raises:

- (`ArgumentError`)

    43
    44
    45
    46
    47
    48
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 43

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

### - (`self`) parent

Remove last reference token of this pointer

Returns:

- (`self`)

Raises:

- (`ArgumentError`)

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

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

### - (`true`, `false`) parent?(child = nil)

Return `true` if this pointer is a parent pointer of `child`.
For instance `"/properties"` pointer is parent pointer of `"/properties/parent"`

Parameters:

- child (`::Vertx::JsonPointer`) (defaults to: `nil`)

Returns:

- (`true`, `false`)

Raises:

- (`ArgumentError`)

    54
    55
    56
    57
    58
    59
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 54

    def parent?(child=nil)
      if child.class.method_defined?(:j_del) && !block_given?
        return @j_del.java_method(:isParent, [Java::IoVertxCoreJsonPointer::JsonPointer.java_class]).call(child.j_del)
      end
      raise ArgumentError, "Invalid arguments when calling parent?(#{child})"
    end

### - (`Object`) query(objectToQuery = nil, iterator = nil)

Query `objectToQuery` using the provided Vertx::JsonPointerIterator.
If you need to query Vert.x json data structures, use #query_json
Note: if this pointer is a root pointer, this function returns the provided object

Parameters:

- objectToQuery (`Object`) (defaults to: `nil`) —
  the object to query
- iterator (`::Vertx::JsonPointerIterator`) (defaults to: `nil`) —
  the json pointer iterator that provides the logic to access to the objectToQuery

Returns:

- (`Object`) —
  null if pointer points to not existing value, otherwise the requested value

Raises:

- (`ArgumentError`)

    110
    111
    112
    113
    114
    115
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 110

    def query(objectToQuery=nil,iterator=nil)
      if ::Vertx::Util::unknown_type.accept?(objectToQuery) && iterator.class.method_defined?(:j_del) && !block_given?
        return ::Vertx::Util::Utils.from_object(@j_del.java_method(:query, [Java::java.lang.Object.java_class,Java::IoVertxCoreJsonPointer::JsonPointerIterator.java_class]).call(::Vertx::Util::Utils.to_object(objectToQuery),iterator.j_del))
      end
      raise ArgumentError, "Invalid arguments when calling query(#{objectToQuery},#{iterator})"
    end

### - (`Object`) query_json(jsonElement = nil)

Query `jsonElement`.
Note: if this pointer is a root pointer, this function returns the provided json element

Parameters:

- jsonElement (`Object`) (defaults to: `nil`) —
  the json element to query

Returns:

- (`Object`) —
  null if pointer points to not existing value, otherwise the requested value

Raises:

- (`ArgumentError`)

    133
    134
    135
    136
    137
    138
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 133

    def query_json(jsonElement=nil)
      if ::Vertx::Util::unknown_type.accept?(jsonElement) && !block_given?
        return ::Vertx::Util::Utils.from_object(@j_del.java_method(:queryJson, [Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(jsonElement)))
      end
      raise ArgumentError, "Invalid arguments when calling query_json(#{jsonElement})"
    end

### - (`Object`) query_json_or_default(jsonElement = nil, defaultValue = nil)

Query `jsonElement`. If the query result is null, returns the default.
Note: if this pointer is a root pointer, this function returns the provided object

Parameters:

- jsonElement (`Object`) (defaults to: `nil`) —
  the json element to query
- defaultValue (`Object`) (defaults to: `nil`) —
  default value if query result is null

Returns:

- (`Object`) —
  null if pointer points to not existing value, otherwise the requested value

Raises:

- (`ArgumentError`)

    144
    145
    146
    147
    148
    149
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 144

    def query_json_or_default(jsonElement=nil,defaultValue=nil)
      if ::Vertx::Util::unknown_type.accept?(jsonElement) && ::Vertx::Util::unknown_type.accept?(defaultValue) && !block_given?
        return ::Vertx::Util::Utils.from_object(@j_del.java_method(:queryJsonOrDefault, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(jsonElement),::Vertx::Util::Utils.to_object(defaultValue)))
      end
      raise ArgumentError, "Invalid arguments when calling query_json_or_default(#{jsonElement},#{defaultValue})"
    end

### - (`Object`) query_or_default(objectToQuery = nil, iterator = nil, defaultValue = nil)

Query `objectToQuery` using the provided Vertx::JsonPointerIterator. If the query result is null, returns the default.
If you need to query Vert.x json data structures, use #query_json_or_default
Note: if this pointer is a root pointer, this function returns the provided object

Parameters:

- objectToQuery (`Object`) (defaults to: `nil`) —
  the object to query
- iterator (`::Vertx::JsonPointerIterator`) (defaults to: `nil`) —
  the json pointer iterator that provides the logic to access to the objectToQuery
- defaultValue (`Object`) (defaults to: `nil`) —
  default value if query result is null

Returns:

- (`Object`) —
  null if pointer points to not existing value, otherwise the requested value

Raises:

- (`ArgumentError`)

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

    def query_or_default(objectToQuery=nil,iterator=nil,defaultValue=nil)
      if ::Vertx::Util::unknown_type.accept?(objectToQuery) && iterator.class.method_defined?(:j_del) && ::Vertx::Util::unknown_type.accept?(defaultValue) && !block_given?
        return ::Vertx::Util::Utils.from_object(@j_del.java_method(:queryOrDefault, [Java::java.lang.Object.java_class,Java::IoVertxCoreJsonPointer::JsonPointerIterator.java_class,Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(objectToQuery),iterator.j_del,::Vertx::Util::Utils.to_object(defaultValue)))
      end
      raise ArgumentError, "Invalid arguments when calling query_or_default(#{objectToQuery},#{iterator},#{defaultValue})"
    end

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

Return `true` if the pointer is a root pointer

Returns:

- (`true`, `false`)

Raises:

- (`ArgumentError`)

    35
    36
    37
    38
    39
    40
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 35

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

### - (`String`) to_string

Build a string representation of the JSON Pointer

Returns:

- (`String`)

Raises:

- (`ArgumentError`)

    62
    63
    64
    65
    66
    67
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 62

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

### - (`Array<Object>`) traced_query(objectToQuery = nil, iterator = nil)

Query `objectToQuery` tracing each element walked during the query, including the first and the result (if any).
The first element of the list is objectToQuery and the last is the result, or the element before the first null was encountered

Parameters:

- objectToQuery (`Object`) (defaults to: `nil`) —
  the object to query
- iterator (`::Vertx::JsonPointerIterator`) (defaults to: `nil`) —
  the json pointer iterator that provides the logic to access to the objectToQuery

Returns:

- (`Array<Object>`) —
  the stream of walked elements

Raises:

- (`ArgumentError`)

    155
    156
    157
    158
    159
    160
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 155

    def traced_query(objectToQuery=nil,iterator=nil)
      if ::Vertx::Util::unknown_type.accept?(objectToQuery) && iterator.class.method_defined?(:j_del) && !block_given?
        return @j_del.java_method(:tracedQuery, [Java::java.lang.Object.java_class,Java::IoVertxCoreJsonPointer::JsonPointerIterator.java_class]).call(::Vertx::Util::Utils.to_object(objectToQuery),iterator.j_del).to_a.map { |elt| ::Vertx::Util::Utils.from_object(elt) }
      end
      raise ArgumentError, "Invalid arguments when calling traced_query(#{objectToQuery},#{iterator})"
    end

### - (`Object`) write(objectToWrite = nil, iterator = nil, newElement = nil, createOnMissing = nil)

Write `newElement` in `objectToWrite` using this pointer. The path token "-" is handled as append to end of array
If you need to write in Vert.x json data structures, use #write_json (Object)}

Parameters:

- objectToWrite (`Object`) (defaults to: `nil`) —
  object to write
- iterator (`::Vertx::JsonPointerIterator`) (defaults to: `nil`) —
  the json pointer iterator that provides the logic to access to the objectToMutate
- newElement (`Object`) (defaults to: `nil`) —
  object to insert
- createOnMissing (`true`, `false`) (defaults to: `nil`) —
  create objects when missing a object key or an array index

Returns:

- (`Object`) —
  a reference to objectToWrite if the write was completed, a reference to newElement if the pointer is a root pointer, null if the write failed

Raises:

- (`ArgumentError`)

    168
    169
    170
    171
    172
    173
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 168

    def write(objectToWrite=nil,iterator=nil,newElement=nil,createOnMissing=nil)
      if ::Vertx::Util::unknown_type.accept?(objectToWrite) && iterator.class.method_defined?(:j_del) && ::Vertx::Util::unknown_type.accept?(newElement) && (createOnMissing.class == TrueClass || createOnMissing.class == FalseClass) && !block_given?
        return ::Vertx::Util::Utils.from_object(@j_del.java_method(:write, [Java::java.lang.Object.java_class,Java::IoVertxCoreJsonPointer::JsonPointerIterator.java_class,Java::java.lang.Object.java_class,Java::boolean.java_class]).call(::Vertx::Util::Utils.to_object(objectToWrite),iterator.j_del,::Vertx::Util::Utils.to_object(newElement),createOnMissing))
      end
      raise ArgumentError, "Invalid arguments when calling write(#{objectToWrite},#{iterator},#{newElement},#{createOnMissing})"
    end

### - (`Object`) write_json(jsonElement = nil, newElement = nil, createOnMissing = nil)

Write `newElement` in `jsonElement` using this pointer. The path token "-" is handled as append to end of array.

Parameters:

- jsonElement (`Object`) (defaults to: `nil`) —
  json to query and write
- newElement (`Object`) (defaults to: `nil`) —
  json to insert
- createOnMissing (`true`, `false`) (defaults to: `nil`) —
  create JsonObject when missing a object key or an array index

Returns:

- (`Object`) —
  a reference to json if the write was completed, a reference to newElement if the pointer is a root pointer, null if the write failed

Raises:

- (`ArgumentError`)

    179
    180
    181
    182
    183
    184
    185
    186
    # File '/Users/julien/java/vertx-aggregator/modules/vertx-lang-ruby/vertx-lang-ruby/target/classes/vertx/json_pointer.rb', line 179

    def write_json(jsonElement=nil,newElement=nil,createOnMissing=nil)
      if ::Vertx::Util::unknown_type.accept?(jsonElement) && ::Vertx::Util::unknown_type.accept?(newElement) && !block_given? && createOnMissing == nil
        return ::Vertx::Util::Utils.from_object(@j_del.java_method(:writeJson, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class]).call(::Vertx::Util::Utils.to_object(jsonElement),::Vertx::Util::Utils.to_object(newElement)))
      elsif ::Vertx::Util::unknown_type.accept?(jsonElement) && ::Vertx::Util::unknown_type.accept?(newElement) && (createOnMissing.class == TrueClass || createOnMissing.class == FalseClass) && !block_given?
        return ::Vertx::Util::Utils.from_object(@j_del.java_method(:writeJson, [Java::java.lang.Object.java_class,Java::java.lang.Object.java_class,Java::boolean.java_class]).call(::Vertx::Util::Utils.to_object(jsonElement),::Vertx::Util::Utils.to_object(newElement),createOnMissing))
      end
      raise ArgumentError, "Invalid arguments when calling write_json(#{jsonElement},#{newElement},#{createOnMissing})"
    end