Package liqp
Class LValue
java.lang.Object
liqp.LValue
- Direct Known Subclasses:
AndNode,ComparingExpressionNode,ContainsNode,Filter,Insertion,OrNode,WhereImpl
An abstract class the Filter and Tag classes extend.
It houses some utility methods easily available for said
classes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LValuestatic final LValuestatic DateTimeFormatter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanReturns true iff a and b are equals, where (int) 1 is equal to (double) 1.0asAppendableObject(Object value, TemplateContext context) Returns `value` as an object appendable toRenderTransformer.ObjectAppender.Object[]asArray(Object value, TemplateContext context) Returns this value as an array.booleanConvert `value` to a boolean.static BigDecimalList<?>asList(Object value, TemplateContext context) Returns this value as a `java.util.List`.Returns `value` as a Number.static ZonedDateTimeasRubyDate(Object value, TemplateContext context) Ruby have a single date type, and its equivalent is ZonedDateTime.asStrictNumber(Object number) asString(Object value, TemplateContext context) Returns `value` as a String.static TemporalAccessorasTemporal(Object value, TemplateContext context) This one keeps an original temporal type as is, while `asRubyDate` converts it to ZonedDateTime.booleancanBeDouble(Object value) booleancanBeInteger(Object value) booleancanBeNumber(Object value) booleanReturns true iff `value` is an array or a java.util.Collection.static booleanbooleanisFalsy(Object value, TemplateContext context) booleanReturns true iff `value` is a whole number (Integer or Long).booleanbooleanReturns true iff `value` is a Number.booleanReturns true iff `value` is a String.static booleanisTemporal(Object value) booleanisTruthy(Object value, TemplateContext context) protected Object[]mapAsArray(Map<?, ?> value) Usually we need array representation of items, so theasArray(Object, TemplateContext)do the work well.static Object[]temporalAsArray(ZonedDateTime time)
-
Field Details
-
BREAK
-
CONTINUE
-
rubyDateTimeFormat
-
-
Constructor Details
-
LValue
public LValue()
-
-
Method Details
-
areEqual
Returns true iff a and b are equals, where (int) 1 is equal to (double) 1.0- Parameters:
a- the first object to compare.b- the second object to compare.- Returns:
- true iff a and b are equals, where (int) 1 is equals to (double) 1.0
-
asArray
Returns this value as an array. If a value is already an array, it is cast to a `Object[]`, if it's a `java.util.Collection`, it is converted to an array and in all other cases, `value` is simply returned as an `Object[]` with a single value in it. This function treat `Map` as single element.- Parameters:
value- the value to convert/cast to an array.- Returns:
- this value as an array.
-
asList
Returns this value as a `java.util.List`. If a value is already a `List`, it is returned as-is, if it's a `java.util.Collection` or an array, it is converted to a `List`, and in all other cases, `value` is simply returned as a `List` with a single value in it. This function treats `Map` as a single element.- Parameters:
value- the value to convert/cast to an array.- Returns:
- this value as a list.
-
temporalAsArray
-
asTemporal
This one keeps an original temporal type as is, while `asRubyDate` converts it to ZonedDateTime. -
asRubyDate
Ruby have a single date type, and its equivalent is ZonedDateTime. -
isTemporal
-
mapAsArray
Usually we need array representation of items, so theasArray(Object, TemplateContext)do the work well. But occasionally we need introspect the object (usually `Map`) as array. So this function do so.- Parameters:
value-- Returns:
-
asBoolean
Convert `value` to a boolean. Note that only `nil` and `false` are `false`, all other values are `true`.- Parameters:
value- the value to convert.- Returns:
- `value` as a boolean.
-
asNumber
Returns `value` as a Number. Strings will be coerced into either a Long or Double.- Parameters:
value- the value to cast to a Number.- Returns:
- `value` as a Number.
- Throws:
NumberFormatException- when `value` is a String which could not be parsed as a Long or Double.
-
asStrictNumber
-
asFormattedNumber
-
asString
Returns `value` as a String.- Parameters:
value- the value to convert to a String.- Returns:
- `value` as a String.
-
asAppendableObject
Returns `value` as an object appendable toRenderTransformer.ObjectAppender.- Parameters:
value- the value to convert.- Returns:
- `value` as an appendable object.
-
isArray
Returns true iff `value` is an array or a java.util.Collection.- Parameters:
value- the value to check.- Returns:
- true iff `value` is an array or a java.util.Collection.
-
isInteger
Returns true iff `value` is a whole number (Integer or Long).- Parameters:
value- the value to check.- Returns:
- true iff `value` is a whole number (Integer or Long).
-
isNumber
Returns true iff `value` is a Number.- Parameters:
value- the value to check.- Returns:
- true iff `value` is a Number.
-
isString
Returns true iff `value` is a String.- Parameters:
value- the value to check.- Returns:
- true iff `value` is a String.
-
isTruthy
-
isFalsy
-
canBeInteger
-
canBeDouble
-
canBeNumber
-
isMap
-
asMap
-
isBlank
-