public final class Predefined extends Object
Predefined provides the module of predefined functions in Golo. The provided module is imported by
default.| Modifier and Type | Method and Description |
|---|---|
static Object |
aget(Object a,
Object i)
Deprecated.
|
static Object |
alength(Object a)
Deprecated.
|
static Object |
Array(Object... values)
Deprecated.
|
static Class<?> |
arrayTypeOf(Object klass)
Returns an array class given a type class.
|
static void |
aset(Object a,
Object i,
Object value)
Deprecated.
|
static Object |
asInterfaceInstance(Object interfaceClass,
Object target)
Turns a method handle into a instance of a single-method interface.
|
static Object |
atoList(Object[] values)
Deprecated.
|
static Object |
charValue(Object obj)
Gives the Character value of some number or String object.
|
static String |
currentDir()
Return current path of execution.
|
static Object |
doubleValue(Object obj)
Gives the Double value of some number or String object.
|
static boolean |
fileExists(Object file)
Check if a file exists.
|
static Object |
fileToText(Object file,
Object encoding)
Reads the content of a text file.
|
static Object |
floatValue(Object obj)
Gives the Float value of some number or String object.
|
static Object |
fun(Object name,
Object module)
Obtains the first method handle / closure to a function.
|
static Object |
fun(Object name,
Object module,
Object arity)
Obtains a method handle / closure to a function.
|
static Object |
intValue(Object obj)
Gives the Integer value of some number or String object.
|
static boolean |
isArray(Object object)
Checks if an object is a (JVM) array or not.
|
static Object |
isClosure(Object object)
Test whether an object is a closure or not.
|
static Object |
longValue(Object obj)
Gives the Long value of some number or String object.
|
static Object |
mapEntry(Object key,
Object value)
Makes a key / value pair.
|
static Object |
newTypedArray(Class<?> type,
int length)
Makes a new typed JVM array.
|
static Class<?> |
objectArrayType()
Function to obtain the
Object[].class reference. |
static void |
print(Object obj)
Prints to the standard console.
|
static void |
println(Object obj)
Prints to the standard console, including a newline.
|
static void |
raise(Object message)
Raises a
RuntimeException with a message. |
static void |
raise(Object message,
Object cause)
Raises a
RuntimeException with a message and a cause. |
static Object |
range(Object to)
Makes an range object starting from the default value.
|
static Object |
range(Object from,
Object to)
Makes an range object between two bounds.
|
static String |
readln()
Reads the next line of characters from the console.
|
static String |
readln(String message)
Reads the next line of characters from the console.
|
static String |
readPassword()
Reads a password from the console with echoing disabled.
|
static String |
readPassword(String message)
Reads a password from the console with echoing disabled.
|
static void |
require(Object condition,
Object errorMessage)
Requires that a condition be
true. |
static void |
requireNotNull(Object obj)
Requires that an object is not the
null reference. |
static Object |
reversed_range(Object from)
Makes an decreasing range object up to the default value.
|
static Object |
reversed_range(Object from,
Object to)
Makes an decreasing range object between two bounds.
|
static char[] |
secureReadPassword()
Reads a password from the console with echoing disabled, returning an
char[] array. |
static char[] |
secureReadPassword(String message)
Reads a password from the console with echoing disabled, returning an
char[] array. |
static void |
sleep(long ms)
Return current path of execution.
|
static void |
textToFile(Object text,
Object file)
Writes some text to a file.
|
static String |
uuid()
Return a universally unique identifier as String.
|
public static void raise(Object message)
RuntimeException with a message.message - the exception description.RuntimeException - (always)public static void raise(Object message, Object cause)
RuntimeException with a message and a cause.message - the exception description.cause - the exception cause.RuntimeException - (always)public static void print(Object obj)
obj - the object to be printed.public static void println(Object obj)
obj - obj the object to be printed.public static String readln() throws IOException
IOExceptionpublic static String readln(String message) throws IOException
message - displays a prompt message.IOExceptionpublic static String readPassword() throws IOException
IOExceptionpublic static String readPassword(String message) throws IOException
message - displays a prompt message.IOExceptionpublic static char[] secureReadPassword()
throws IOException
char[] array.IOExceptionpublic static char[] secureReadPassword(String message) throws IOException
char[] array.message - displays a prompt message.IOExceptionpublic static void requireNotNull(Object obj) throws AssertionError
null reference.obj - the object to test against null.AssertionError - if obj is null.public static void require(Object condition, Object errorMessage) throws IllegalArgumentException, AssertionError
true.condition - the condition, must be a Boolean.errorMessage - the error message, must be a String.IllegalArgumentException - if the arguments are of the wrong type.AssertionError - if condition is false.public static Object newTypedArray(Class<?> type, int length)
java.lang.reflect.Array.newInstance.type - the array type.length - the array length.@Deprecated public static Object Array(Object... values)
values - the values.@Deprecated public static Object atoList(Object[] values)
values - the array.java.util package.@Deprecated public static Object aget(Object a, Object i)
a - the array.i - the index.i.@Deprecated public static void aset(Object a, Object i, Object value)
a - the array.i - the index.value - the new value.@Deprecated public static Object alength(Object a)
a - the array.a.public static Object range(Object from, Object to)
java.lang.Collection (immutable), so they can be used in Golo foreach
loops.from - the lower-bound (inclusive) as an Integer, Long, or
Character.to - the upper-bound (exclusive) as an Integer, Long or
CharacterCollectionpublic static Object range(Object to)
The default value is 0 for numbers and 'A' for chars.
to - the upper-bound (exclusive) as an Integer or Long.gololang.Predefined.rangepublic static Object reversed_range(Object from, Object to)
java.lang.Collection, so
they can be used in Golo foreach loops.from - the upper-bound (inclusive) as an Integer, Long or
Character.to - the lower-bound (exclusive) as an Integer, Long or
Character.gololang.Predefined.rangepublic static Object reversed_range(Object from)
The default value is 0 for numbers and 'A' for chars.
from - the upper-bound (inclusive) as an Integer, Long or
Character.gololang.Predefined.reversed_range,
gololang.Predefined.rangepublic static Object mapEntry(Object key, Object value)
key - the key.value - the value.AbstractMap.SimpleEntryAbstractMap.SimpleEntrypublic static Object asInterfaceInstance(Object interfaceClass, Object target)
interfaceClass - the target single-method interface class.target - the implementation method handle.interfaceClass.MethodHandleProxies.asInterfaceInstance(Class, java.lang.invoke.MethodHandle)public static Object isClosure(Object object)
object - the object.true if object is an instance of java.lang.invoke.MethodHandle,
false otherwise.public static Object fun(Object name, Object module, Object arity) throws Throwable
name - the function name.module - the function enclosing module (a Java class).arity - the function arity, where a negative value means that any arity will do.NoSuchMethodException - if the target function could not be found.IllegalArgumentException - if the argument types are not of types (String, Class, Integer).Throwable - if an error occurs.public static Object fun(Object name, Object module) throws Throwable
This is the same as calling fun(name, module, -1).
Throwablefun(Object, Object, Object)public static Object fileToText(Object file, Object encoding) throws Throwable
public static void textToFile(Object text, Object file) throws Throwable
public static boolean fileExists(Object file)
public static String currentDir() throws Throwable
Throwablepublic static void sleep(long ms)
throws InterruptedException
InterruptedExceptionpublic static String uuid()
public static boolean isArray(Object object)
object - the object to check.true if object is an array, false otherwise or if null.public static Class<?> objectArrayType()
Object[].class reference.Object[].classpublic static Class<?> arrayTypeOf(Object klass) throws ClassNotFoundException
klass - the array type.klass, i.e., klass[].ClassNotFoundException - if the type could not be found.public static Object charValue(Object obj) throws IllegalArgumentException
obj - a boxed number or String value.IllegalArgumentException - if obj is not a number or a String.public static Object intValue(Object obj) throws IllegalArgumentException
obj - a boxed number or String value.IllegalArgumentException - if obj is not a number or a String.public static Object longValue(Object obj) throws IllegalArgumentException
obj - a boxed number or String value.IllegalArgumentException - if obj is not a number or a String.public static Object doubleValue(Object obj) throws IllegalArgumentException
obj - a boxed number or String value.IllegalArgumentException - if obj is not a number or a String.public static Object floatValue(Object obj) throws IllegalArgumentException
obj - a boxed number or String value.IllegalArgumentException - if obj is not a number or a String.Copyright © 2015 Institut National des Sciences Appliquées de Lyon (INSA-Lyon). All rights reserved.