java.lang.Object
io.jooby.ForwardingContext.ForwardingBody
- Enclosing class:
- ForwardingContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanConvert this value to boolean (if possible).booleanbooleanValue(boolean defaultValue) Convert this value to boolean (if possible) or fallback to given value when missing.byte[]bytes()HTTP body as byte array.byteConvert this value to byte (if possible).bytebyteValue(byte defaultValue) Convert this value to byte (if possible) or fallback to given value when missing.channel()Body as readable channel.doubleConvert this value to double (if possible).doubledoubleValue(double defaultValue) Convert this value to double (if possible) or fallback to given value when missing.floatConvert this value to float (if possible).floatfloatValue(float defaultValue) Convert this value to float (if possible) or fallback to given value when missing.voidget(int index) Get a value at the given position.Get a value that matches the given name.longgetSize()Size in bytes.intintValue()Convert this value to int (if possible).intintValue(int defaultValue) Convert this value to int (if possible) or fallback to given value when missing.booleanisArray()True if this value is an array/sequence (not single or hash).booleanTrue if body is on memory.booleanTrue for missing values.booleanisObject()True if this is a hash/object value (not single or array).booleanTrue for present values.booleanisSingle()True if this is a single value (not a hash or array).iterator()Value iterator.longConvert this value to long (if possible).longlongValue(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.intsize()The number of values this one has.stream()Body as input stream.<T> TConvert this value to the given type.<T> TConvert 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> TtoNullable(Class<T> type) Convert this value to the given type.<T> TtoNullable(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> Tvalue(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) ornullwhen missing.
-
Constructor Details
-
ForwardingBody
-
-
Method Details
-
value
Description copied from interface:BodyHTTP body as string. -
bytes
@NonNull public byte[] bytes()Description copied from interface:BodyHTTP body as byte array. -
isInMemory
public boolean isInMemory()Description copied from interface:BodyTrue if body is on memory. False, indicates body is on file system. Body larger thanServerOptions.getMaxRequestSize()will be dump to disk.- Specified by:
isInMemoryin interfaceBody- Returns:
- True if body is on memory. False, indicates body is on file system.
-
getSize
public long getSize()Description copied from interface:BodySize in bytes. This is the same asContent-Lengthheader. -
channel
Description copied from interface:BodyBody as readable channel. -
stream
Description copied from interface:BodyBody as input stream. -
toList
Description copied from interface:ValueGet list of the given type. -
toList
Description copied from interface:ValueGet list of values. -
toSet
Description copied from interface:ValueGet set of values. -
to
Description copied from interface:ValueConvert 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:ValueConvert 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:
toNullablein interfaceBody- Specified by:
toNullablein interfaceValue- Type Parameters:
T- Element type.- Parameters:
type- Type to convert.- Returns:
- Instance of the type or
null.
-
to
Description copied from interface:BodyConvert this body into the given type. -
toNullable
Description copied from interface:BodyConvert this body into the given type.- Specified by:
toNullablein interfaceBody- Type Parameters:
T- Generic type.- Parameters:
type- Type to use.- Returns:
- Converted value or
null.
-
get
Description copied from interface:ValueNodeGet a value at the given position. -
get
Description copied from interface:ValueNodeGet a value that matches the given name. -
size
public int size()Description copied from interface:ValueNodeThe number of values this one has. For single values size is0. -
iterator
Description copied from interface:ValueNodeValue iterator. -
resolve
Description copied from interface:ValueNodeProcess 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:ValueNodeProcess 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:ValueNodeProcess 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:ValueNodeProcess 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:
spliteratorin interfaceIterable<ValueNode>
-
longValue
public long longValue()Description copied from interface:ValueConvert this value to long (if possible). -
longValue
public long longValue(long defaultValue) Description copied from interface:ValueConvert this value to long (if possible) or fallback to given value when missing. -
intValue
public int intValue()Description copied from interface:ValueConvert this value to int (if possible). -
intValue
public int intValue(int defaultValue) Description copied from interface:ValueConvert this value to int (if possible) or fallback to given value when missing. -
byteValue
public byte byteValue()Description copied from interface:ValueConvert this value to byte (if possible). -
byteValue
public byte byteValue(byte defaultValue) Description copied from interface:ValueConvert this value to byte (if possible) or fallback to given value when missing. -
floatValue
public float floatValue()Description copied from interface:ValueConvert this value to float (if possible).- Specified by:
floatValuein interfaceValue- Returns:
- Convert this value to float (if possible).
-
floatValue
public float floatValue(float defaultValue) Description copied from interface:ValueConvert this value to float (if possible) or fallback to given value when missing.- Specified by:
floatValuein 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:ValueConvert this value to double (if possible).- Specified by:
doubleValuein interfaceValue- Returns:
- Convert this value to double (if possible).
-
doubleValue
public double doubleValue(double defaultValue) Description copied from interface:ValueConvert this value to double (if possible) or fallback to given value when missing.- Specified by:
doubleValuein 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:ValueConvert this value to boolean (if possible).- Specified by:
booleanValuein interfaceValue- Returns:
- Convert this value to boolean (if possible).
-
booleanValue
public boolean booleanValue(boolean defaultValue) Description copied from interface:ValueConvert this value to boolean (if possible) or fallback to given value when missing.- Specified by:
booleanValuein 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:ValueConvert this value to String (if possible) or fallback to given value when missing. -
valueOrNull
Description copied from interface:ValueConvert this value to String (if possible) ornullwhen missing.- Specified by:
valueOrNullin interfaceValue- Returns:
- Convert this value to String (if possible) or
nullwhen missing.
-
value
Description copied from interface:ValueConvert value using the given function. -
value
Description copied from interface:ValueGet string value. -
toEnum
Description copied from interface:ValueConvert 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:ValueConvert this value to an Enum. -
toOptional
Description copied from interface:ValueGet a value or empty optional.- Specified by:
toOptionalin interfaceValue- Returns:
- Value or empty optional.
-
isSingle
public boolean isSingle()Description copied from interface:ValueTrue if this is a single value (not a hash or array). -
isMissing
public boolean isMissing()Description copied from interface:ValueTrue for missing values. -
isPresent
public boolean isPresent()Description copied from interface:ValueTrue for present values. -
isArray
public boolean isArray()Description copied from interface:ValueTrue if this value is an array/sequence (not single or hash). -
isObject
public boolean isObject()Description copied from interface:ValueTrue if this is a hash/object value (not single or array). -
name
Description copied from interface:ValueName of this value ornull. -
toOptional
Description copied from interface:ValueGet a value or empty optional.- Specified by:
toOptionalin interfaceValue- Type Parameters:
T- Item type.- Parameters:
type- Item type.- Returns:
- Value or empty optional.
-
toSet
Description copied from interface:ValueGet set of the given type. -
toMultimap
Description copied from interface:ValueValue as multi-value map.- Specified by:
toMultimapin interfaceValue- Returns:
- Value as multi-value map.
-
toMap
Description copied from interface:ValueValue as single-value map.
-