Module io.jooby
Package io.jooby

Class ForwardingContext.ForwardingBody

java.lang.Object
io.jooby.ForwardingContext.ForwardingBody
All Implemented Interfaces:
Body, Value, ValueNode, Iterable<ValueNode>
Enclosing class:
ForwardingContext

public static class ForwardingContext.ForwardingBody extends Object implements Body
  • Constructor Details

    • ForwardingBody

      public ForwardingBody(Body body)
  • Method Details

    • value

      @NonNull public String value(@NonNull Charset charset)
      Description copied from interface: Body
      HTTP body as string.
      Specified by:
      value in interface Body
      Parameters:
      charset - Charset.
      Returns:
      Body as string.
    • bytes

      @NonNull public byte[] bytes()
      Description copied from interface: Body
      HTTP body as byte array.
      Specified by:
      bytes in interface Body
      Returns:
      Body as byte array.
    • isInMemory

      public boolean isInMemory()
      Description copied from interface: Body
      True if body is on memory. False, indicates body is on file system. Body larger than ServerOptions.getMaxRequestSize() will be dump to disk.
      Specified by:
      isInMemory in interface Body
      Returns:
      True if body is on memory. False, indicates body is on file system.
    • getSize

      public long getSize()
      Description copied from interface: Body
      Size in bytes. This is the same as Content-Length header.
      Specified by:
      getSize in interface Body
      Returns:
      Size in bytes. This is the same as Content-Length header.
    • channel

      @NonNull public ReadableByteChannel channel()
      Description copied from interface: Body
      Body as readable channel.
      Specified by:
      channel in interface Body
      Returns:
      Body as readable channel.
    • stream

      @NonNull public InputStream stream()
      Description copied from interface: Body
      Body as input stream.
      Specified by:
      stream in interface Body
      Returns:
      Body as input stream.
    • toList

      @NonNull public <T> List<T> toList(@NonNull Class<T> type)
      Description copied from interface: Value
      Get list of the given type.
      Specified by:
      toList in interface Body
      Specified by:
      toList in interface Value
      Type Parameters:
      T - Item type.
      Parameters:
      type - Type to convert.
      Returns:
      List of items.
    • toList

      @NonNull public List<String> toList()
      Description copied from interface: Value
      Get list of values.
      Specified by:
      toList in interface Body
      Specified by:
      toList in interface Value
      Returns:
      List of values.
    • toSet

      @NonNull public Set<String> toSet()
      Description copied from interface: Value
      Get set of values.
      Specified by:
      toSet in interface Body
      Specified by:
      toSet in interface Value
      Returns:
      set of values.
    • to

      @NonNull public <T> T to(@NonNull Class<T> type)
      Description copied from interface: Value
      Convert this value to the given type. Support values are single-value, array-value and object-value. Object-value can be converted to a JavaBean type.
      Specified by:
      to in interface Body
      Specified by:
      to in interface Value
      Type Parameters:
      T - Element type.
      Parameters:
      type - Type to convert.
      Returns:
      Instance of the type.
    • toNullable

      @Nullable public <T> T toNullable(@NonNull Class<T> type)
      Description copied from interface: Value
      Convert this value to the given type. Support values are single-value, array-value and object-value. Object-value can be converted to a JavaBean type.
      Specified by:
      toNullable in interface Body
      Specified by:
      toNullable in interface Value
      Type Parameters:
      T - Element type.
      Parameters:
      type - Type to convert.
      Returns:
      Instance of the type or null.
    • to

      @NonNull public <T> T to(@NonNull Type type)
      Description copied from interface: Body
      Convert this body into the given type.
      Specified by:
      to in interface Body
      Type Parameters:
      T - Generic type.
      Parameters:
      type - Type to use.
      Returns:
      Converted value.
    • toNullable

      @Nullable public <T> T toNullable(@NonNull Type type)
      Description copied from interface: Body
      Convert this body into the given type.
      Specified by:
      toNullable in interface Body
      Type Parameters:
      T - Generic type.
      Parameters:
      type - Type to use.
      Returns:
      Converted value or null.
    • get

      @NonNull public ValueNode get(@NonNull int index)
      Description copied from interface: ValueNode
      Get a value at the given position.
      Specified by:
      get in interface ValueNode
      Parameters:
      index - Position.
      Returns:
      A value at the given position.
    • get

      @NonNull public ValueNode get(@NonNull String name)
      Description copied from interface: ValueNode
      Get a value that matches the given name.
      Specified by:
      get in interface ValueNode
      Parameters:
      name - Field name.
      Returns:
      Field value.
    • size

      public int size()
      Description copied from interface: ValueNode
      The number of values this one has. For single values size is 0.
      Specified by:
      size in interface ValueNode
      Returns:
      Number of values. Mainly for array and hash values.
    • iterator

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

      @NonNull public String resolve(@NonNull String expression)
      Description copied from interface: ValueNode
      Process the given expression and resolve value references.
      
       Value value = Value.single("foo", "bar");
      
       String output = value.resolve("${foo}");
       System.out.println(output);
       
      Specified by:
      resolve in interface ValueNode
      Parameters:
      expression - Text expression.
      Returns:
      Resolved text.
    • resolve

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

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

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

      public void forEach(Consumer<? super ValueNode> action)
      Specified by:
      forEach in interface Iterable<ValueNode>
    • spliterator

      public Spliterator<ValueNode> spliterator()
      Specified by:
      spliterator in interface Iterable<ValueNode>
    • longValue

      public long longValue()
      Description copied from interface: Value
      Convert this value to long (if possible).
      Specified by:
      longValue in interface Value
      Returns:
      Long value.
    • longValue

      public long longValue(long defaultValue)
      Description copied from interface: Value
      Convert this value to long (if possible) or fallback to given value when missing.
      Specified by:
      longValue in interface Value
      Parameters:
      defaultValue - Default value.
      Returns:
      Convert this value to long (if possible) or fallback to given value when missing.
    • intValue

      public int intValue()
      Description copied from interface: Value
      Convert this value to int (if possible).
      Specified by:
      intValue in interface Value
      Returns:
      Int value.
    • intValue

      public int intValue(int defaultValue)
      Description copied from interface: Value
      Convert this value to int (if possible) or fallback to given value when missing.
      Specified by:
      intValue in interface Value
      Parameters:
      defaultValue - Default value.
      Returns:
      Convert this value to int (if possible) or fallback to given value when missing.
    • byteValue

      public byte byteValue()
      Description copied from interface: Value
      Convert this value to byte (if possible).
      Specified by:
      byteValue in interface Value
      Returns:
      Convert this value to byte (if possible).
    • byteValue

      public byte byteValue(byte defaultValue)
      Description copied from interface: Value
      Convert this value to byte (if possible) or fallback to given value when missing.
      Specified by:
      byteValue in interface Value
      Parameters:
      defaultValue - Default value.
      Returns:
      Convert this value to byte (if possible) or fallback to given value when missing.
    • floatValue

      public float floatValue()
      Description copied from interface: Value
      Convert this value to float (if possible).
      Specified by:
      floatValue in interface Value
      Returns:
      Convert this value to float (if possible).
    • floatValue

      public float floatValue(float defaultValue)
      Description copied from interface: Value
      Convert this value to float (if possible) or fallback to given value when missing.
      Specified by:
      floatValue in interface Value
      Parameters:
      defaultValue - Default value.
      Returns:
      Convert this value to float (if possible) or fallback to given value when missing.
    • doubleValue

      public double doubleValue()
      Description copied from interface: Value
      Convert this value to double (if possible).
      Specified by:
      doubleValue in interface Value
      Returns:
      Convert this value to double (if possible).
    • doubleValue

      public double doubleValue(double defaultValue)
      Description copied from interface: Value
      Convert this value to double (if possible) or fallback to given value when missing.
      Specified by:
      doubleValue in interface Value
      Parameters:
      defaultValue - Default value.
      Returns:
      Convert this value to double (if possible) or fallback to given value when missing.
    • booleanValue

      public boolean booleanValue()
      Description copied from interface: Value
      Convert this value to boolean (if possible).
      Specified by:
      booleanValue in interface Value
      Returns:
      Convert this value to boolean (if possible).
    • booleanValue

      public boolean booleanValue(boolean defaultValue)
      Description copied from interface: Value
      Convert this value to boolean (if possible) or fallback to given value when missing.
      Specified by:
      booleanValue in interface Value
      Parameters:
      defaultValue - Default value.
      Returns:
      Convert this value to boolean (if possible) or fallback to given value when missing.
    • value

      @NonNull public String value(@NonNull String defaultValue)
      Description copied from interface: Value
      Convert this value to String (if possible) or fallback to given value when missing.
      Specified by:
      value in interface Value
      Parameters:
      defaultValue - Default value.
      Returns:
      Convert this value to String (if possible) or fallback to given value when missing.
    • valueOrNull

      @Nullable public String valueOrNull()
      Description copied from interface: Value
      Convert this value to String (if possible) or null when missing.
      Specified by:
      valueOrNull in interface Value
      Returns:
      Convert this value to String (if possible) or null when missing.
    • value

      @NonNull public <T> T value(@NonNull SneakyThrows.Function<String,T> fn)
      Description copied from interface: Value
      Convert value using the given function.
      Specified by:
      value in interface Value
      Type Parameters:
      T - Target type.
      Parameters:
      fn - Function.
      Returns:
      Converted value.
    • value

      @NonNull public String value()
      Description copied from interface: Value
      Get string value.
      Specified by:
      value in interface Value
      Returns:
      String value.
    • toEnum

      @NonNull public <T extends Enum<T>> T toEnum(@NonNull SneakyThrows.Function<String,T> fn)
      Description copied from interface: Value
      Convert this value to an Enum.
      Specified by:
      toEnum in interface Value
      Type Parameters:
      T - Enum type.
      Parameters:
      fn - Mapping function.
      Returns:
      Enum.
    • toEnum

      @NonNull public <T extends Enum<T>> T toEnum(@NonNull SneakyThrows.Function<String,T> fn, @NonNull Function<String,String> nameProvider)
      Description copied from interface: Value
      Convert this value to an Enum.
      Specified by:
      toEnum in interface Value
      Type Parameters:
      T - Enum type.
      Parameters:
      fn - Mapping function.
      nameProvider - Enum name provider.
      Returns:
      Enum.
    • toOptional

      @NonNull public Optional<String> toOptional()
      Description copied from interface: Value
      Get a value or empty optional.
      Specified by:
      toOptional in interface Value
      Returns:
      Value or empty optional.
    • isSingle

      public boolean isSingle()
      Description copied from interface: Value
      True if this is a single value (not a hash or array).
      Specified by:
      isSingle in interface Value
      Returns:
      True if this is a single value (not a hash or array).
    • isMissing

      public boolean isMissing()
      Description copied from interface: Value
      True for missing values.
      Specified by:
      isMissing in interface Value
      Returns:
      True for missing values.
    • isPresent

      public boolean isPresent()
      Description copied from interface: Value
      True for present values.
      Specified by:
      isPresent in interface Value
      Returns:
      True for present values.
    • isArray

      public boolean isArray()
      Description copied from interface: Value
      True if this value is an array/sequence (not single or hash).
      Specified by:
      isArray in interface Value
      Returns:
      True if this value is an array/sequence.
    • isObject

      public boolean isObject()
      Description copied from interface: Value
      True if this is a hash/object value (not single or array).
      Specified by:
      isObject in interface Value
      Returns:
      True if this is a hash/object value (not single or array).
    • name

      @Nullable public String name()
      Description copied from interface: Value
      Name of this value or null.
      Specified by:
      name in interface Value
      Returns:
      Name of this value or null.
    • toOptional

      @NonNull public <T> Optional<T> toOptional(@NonNull Class<T> type)
      Description copied from interface: Value
      Get a value or empty optional.
      Specified by:
      toOptional in interface Value
      Type Parameters:
      T - Item type.
      Parameters:
      type - Item type.
      Returns:
      Value or empty optional.
    • toSet

      @NonNull public <T> Set<T> toSet(@NonNull Class<T> type)
      Description copied from interface: Value
      Get set of the given type.
      Specified by:
      toSet in interface Value
      Type Parameters:
      T - Item type.
      Parameters:
      type - Type to convert.
      Returns:
      Set of items.
    • toMultimap

      @NonNull public Map<String,List<String>> toMultimap()
      Description copied from interface: Value
      Value as multi-value map.
      Specified by:
      toMultimap in interface Value
      Returns:
      Value as multi-value map.
    • toMap

      @NonNull public Map<String,String> toMap()
      Description copied from interface: Value
      Value as single-value map.
      Specified by:
      toMap in interface Value
      Returns:
      Value as single-value map.