Utility methods of HTTL markup

httl.spi.methods .CollectionMethod

toCycle(Collection<T> values)
toCycle(T[] values)

It converts a passed sequence of items into single endless cyclic collection where that sequence will be repeated constantly.

Returns a cyclic iterator having the following properties:

  • next - the next item
  • value - the current item
  • values - an array of all elements
  • size - the size of the cyclic array
  • index - the current index of element

Example:

#set(colors = ["red","blue","green"].toCycle)
<table>
#for(item: list)
    <tr style="color:${colors.next}">
        <td>${item.name}</td>
    </tr>
#end
</table>
Return type:Cyclic iterator, depending on the transferred type
length(Map<?, ?> values)
length(Collection<T> values)
length(T[] values)

It returns the length of the passed collection or array.

Return type:int
sort(List<T> values)
sort(Set<T> values)
sort(Collection<T> values)
sort(T[] values)

Creates a new copy of the specified collection and sorts its elements.

Return type:Type of transferred values collection
recursive(Map<K, V> values)
recursive(Collection<T> values)

TODO

httl.spi.methods .EscapeMethod

escapeString(String value)
unescapeString(String value)

Escape/unescape , `, `t, n, r, b, f characters in the Java string.

escapeXml(String value)

Escape XML in the string.

unescapeXml(String value)

Unescape XML in the string.

escapeUrl(String value)

Encode a part of URL in the string.

unescapeUrl(String value)

Decode the part of URL in the string.

escapeBase64(String value)

Encode the string in the Base64.

unescapeBase64(String value)

Decode the string from the Base64.

httl.spi.methods .StringMethod

clip(String value, int max)

It returns the specified value limiting its length up to the max characters substituting the rest to ....

Example:

${"Hi word".clip(6)}

Displays: Hi...

Return type:java.lang.String
repeat(String value, int count)

Repeats an output value count times

Return type:java.lang.String
split(String value, char separator)

The transmitted value is divided into substrings delimited by separator and returns substrings in the form of string array.

Return type:String[]
md5(String value)

Converts a transmitted value to MD5 hash.

Return type:java.lang.String
sha(String value)

Converts a transmitted value to SHA hash.

Return type:java.lang.String
digest(String value, String digest)

Converts a transmitted value to hash with digest algorithm.

Example:

${"abc".sha} equal to ${"abc".digest("SHA")}
Return type:java.lang.String
toCamelName(String name)

TODO

httl.spi.methods .TypeMethod

format([int,byte,short,long,float,double,Number] value, String format)

Converts a number to a string according to a predetermined format. Refer to java.text.DecimalFormat.

Return type:java.lang.String
toDate(String value[, String format])

Converts a string to an object of java.util.Date class.

Example:

${"2016-05-27".toDate}
Arguments:
  • format (String) – Format of transmitted string. HTTL configuration: date.format=yyyy-MM-dd HH:mm:ss
Return type:

java.util.Date

toList(Object[] values)

Converts an array of values to a java.util.List list.

toList(Collection<T> values)

Converts an array of values to a java.util.List<T> list.

toArray(Collection<T> values)

Converts a collection to an array of values T[].

toBoolean(Object obj)

Converts an argument to java.lang.Boolean.

Example:

${"true".toBoolean}

Note

Similarly toByte, toChar, toShort, toInt, toLong, toFloat, toDouble, toClass.

httl.spi.methods .SystemMethod

now()

Example:

${now()}
Returns:current date :rtype: java.util.Date
random()
Returns:Normally distributed pseudo-random number in the interval: [-2^31, 2^31-1]
uuid()
Return type:java.util.UUID