java.lang.Object
io.jooby.ForwardingContext.ForwardingBody
- Enclosing class:
- ForwardingContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Convert this value to boolean (if possible).boolean
booleanValue
(boolean defaultValue) Convert this value to boolean (if possible) or fallback to given value when missing.byte[]
bytes()
HTTP body as byte array.byte
Convert this value to byte (if possible).byte
byteValue
(byte defaultValue) Convert this value to byte (if possible) or fallback to given value when missing.channel()
Body as readable channel.double
Convert this value to double (if possible).double
doubleValue
(double defaultValue) Convert this value to double (if possible) or fallback to given value when missing.float
Convert this value to float (if possible).float
floatValue
(float defaultValue) Convert this value to float (if possible) or fallback to given value when missing.void
get
(int index) Get a value at the given position.Get a value that matches the given name.long
getSize()
Size in bytes.int
intValue()
Convert this value to int (if possible).int
intValue
(int defaultValue) Convert this value to int (if possible) or fallback to given value when missing.boolean
isArray()
True if this value is an array/sequence (not single or hash).boolean
True if body is on memory.boolean
True for missing values.boolean
isObject()
True if this is a hash/object value (not single or array).boolean
True for present values.boolean
isSingle()
True if this is a single value (not a hash or array).iterator()
Value iterator.long
Convert this value to long (if possible).long
longValue
(long defaultValue) Convert this value to long (if possible) or fallback to given value when missing.name()
Name of this value ornull
.Process the given expression and resolve value references.Process the given expression and resolve value references.Process the given expression and resolve value references.Process the given expression and resolve value references.int
size()
The number of values this one has.stream()
Body as input stream.<T> T
Convert this value to the given type.<T> T
Convert this body into the given type.<T extends Enum<T>>
TtoEnum
(SneakyThrows.Function<String, T> fn) Convert this value to an Enum.<T extends Enum<T>>
TConvert this value to an Enum.toList()
Get list of values.<T> List<T>
Get list of the given type.toMap()
Value as single-value map.Value as multi-value map.<T> T
toNullable
(Class<T> type) Convert this value to the given type.<T> T
toNullable
(Type type) Convert this body into the given type.Get a value or empty optional.<T> Optional<T>
toOptional
(Class<T> type) Get a value or empty optional.toSet()
Get set of values.<T> Set<T>
Get set of the given type.value()
Get string value.<T> T
value
(SneakyThrows.Function<String, T> fn) Convert value using the given function.Convert this value to String (if possible) or fallback to given value when missing.HTTP body as string.Convert this value to String (if possible) ornull
when missing.
-
Constructor Details
-
ForwardingBody
-
-
Method Details
-
value
Description copied from interface:Body
HTTP body as string. -
bytes
@NonNull public byte[] bytes()Description copied from interface:Body
HTTP 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 thanServerOptions.getMaxRequestSize()
will be dump to disk.- Specified by:
isInMemory
in interfaceBody
- 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 asContent-Length
header. -
channel
Description copied from interface:Body
Body as readable channel. -
stream
Description copied from interface:Body
Body as input stream. -
toList
Description copied from interface:Value
Get list of the given type. -
toList
Description copied from interface:Value
Get list of values. -
toSet
Description copied from interface:Value
Get set of values. -
to
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. -
toNullable
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 interfaceBody
- Specified by:
toNullable
in interfaceValue
- Type Parameters:
T
- Element type.- Parameters:
type
- Type to convert.- Returns:
- Instance of the type or
null
.
-
to
Description copied from interface:Body
Convert this body into the given type. -
toNullable
Description copied from interface:Body
Convert this body into the given type.- Specified by:
toNullable
in interfaceBody
- Type Parameters:
T
- Generic type.- Parameters:
type
- Type to use.- Returns:
- Converted value or
null
.
-
get
Description copied from interface:ValueNode
Get a value at the given position. -
get
Description copied from interface:ValueNode
Get a value that matches the given name. -
size
public int size()Description copied from interface:ValueNode
The number of values this one has. For single values size is0
. -
iterator
Description copied from interface:ValueNode
Value iterator. -
resolve
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);
-
resolve
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);
-
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);
-
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);
-
forEach
-
spliterator
- Specified by:
spliterator
in interfaceIterable<ValueNode>
-
longValue
public long longValue()Description copied from interface:Value
Convert this value to long (if possible). -
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. -
intValue
public int intValue()Description copied from interface:Value
Convert this value to int (if possible). -
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. -
byteValue
public byte byteValue()Description copied from interface:Value
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. -
floatValue
public float floatValue()Description copied from interface:Value
Convert this value to float (if possible).- Specified by:
floatValue
in interfaceValue
- 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 interfaceValue
- 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 interfaceValue
- 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 interfaceValue
- 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 interfaceValue
- 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 interfaceValue
- Parameters:
defaultValue
- Default value.- Returns:
- Convert this value to boolean (if possible) or fallback to given value when missing.
-
value
Description copied from interface:Value
Convert this value to String (if possible) or fallback to given value when missing. -
valueOrNull
Description copied from interface:Value
Convert this value to String (if possible) ornull
when missing.- Specified by:
valueOrNull
in interfaceValue
- Returns:
- Convert this value to String (if possible) or
null
when missing.
-
value
Description copied from interface:Value
Convert value using the given function. -
value
Description copied from interface:Value
Get string value. -
toEnum
Description copied from interface:Value
Convert this value to an 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. -
toOptional
Description copied from interface:Value
Get a value or empty optional.- Specified by:
toOptional
in interfaceValue
- 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). -
isMissing
public boolean isMissing()Description copied from interface:Value
True for missing values. -
isPresent
public boolean isPresent()Description copied from interface:Value
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). -
isObject
public boolean isObject()Description copied from interface:Value
True if this is a hash/object value (not single or array). -
name
Description copied from interface:Value
Name of this value ornull
. -
toOptional
Description copied from interface:Value
Get a value or empty optional.- Specified by:
toOptional
in interfaceValue
- Type Parameters:
T
- Item type.- Parameters:
type
- Item type.- Returns:
- Value or empty optional.
-
toSet
Description copied from interface:Value
Get set of the given type. -
toMultimap
Description copied from interface:Value
Value as multi-value map.- Specified by:
toMultimap
in interfaceValue
- Returns:
- Value as multi-value map.
-
toMap
Description copied from interface:Value
Value as single-value map.
-