Module io.jooby
Package io.jooby

Interface ValueNode

All Superinterfaces:
Iterable<ValueNode>, Value
All Known Subinterfaces:
Body, Formdata, QueryString

public interface ValueNode extends Iterable<ValueNode>, Value
Unified API for HTTP value. This API plays two role:

- unify access to HTTP values, like query, path, form and header parameter - works as validation API, because it is able to check for required and type-safe values

The value API is composed by three types:

- Single value - Object value - Sequence of values (array)

Single value are can be converted to string, int, boolean, enum like values. Object value is a key:value structure (like a hash). Sequence of values are index based structure.

All these 3 types are modeled into a single Value class. At any time you can treat a value as 1) single, 2) hash or 3) array of them.

Since:
2.0.0
Author:
edgar
  • Method Details

    • get

      @NonNull ValueNode get(@NonNull int index)
      Get a value at the given position.
      Parameters:
      index - Position.
      Returns:
      A value at the given position.
    • get

      @NonNull ValueNode get(@NonNull String name)
      Get a value that matches the given name.
      Parameters:
      name - Field name.
      Returns:
      Field value.
    • size

      default int size()
      The number of values this one has. For single values size is 0.
      Returns:
      Number of values. Mainly for array and hash values.
    • iterator

      @NonNull default Iterator<ValueNode> iterator()
      Value iterator.
      Specified by:
      iterator in interface Iterable<ValueNode>
      Returns:
      Value iterator.
    • resolve

      @NonNull default String resolve(@NonNull String expression)
      Process the given expression and resolve value references.
      
       Value value = Value.single("foo", "bar");
      
       String output = value.resolve("${foo}");
       System.out.println(output);
       
      Parameters:
      expression - Text expression.
      Returns:
      Resolved text.
    • resolve

      @NonNull default String resolve(@NonNull String expression, boolean ignoreMissing)
      Process the given expression and resolve value references.
      
       Value value = Value.single("foo", "bar");
      
       String output = value.resolve("${missing}", true);
       System.out.println(output);
       
      Parameters:
      expression - Text expression.
      ignoreMissing - On missing values, keep the expression as it is.
      Returns:
      Resolved text.
    • resolve

      @NonNull default String resolve(@NonNull String expression, @NonNull String startDelim, @NonNull String endDelim)
      Process the given expression and resolve value references.
      
       Value value = Value.single("foo", "bar");
      
       String output = value.resolve("<%missing%>", "<%", "%>");
       System.out.println(output);
       
      Parameters:
      expression - Text expression.
      startDelim - Start delimiter.
      endDelim - End delimiter.
      Returns:
      Resolved text.
    • resolve

      @NonNull default String resolve(@NonNull String expression, boolean ignoreMissing, @NonNull String startDelim, @NonNull String endDelim)
      Process the given expression and resolve value references.
      
       Value value = Value.single("foo", "bar");
      
       String output = value.resolve("<%missing%>", "<%", "%>");
       System.out.println(output);
       
      Parameters:
      expression - Text expression.
      ignoreMissing - On missing values, keep the expression as it is.
      startDelim - Start delimiter.
      endDelim - End delimiter.
      Returns:
      Resolved text.