Source Code

A set of adaptors for types belonging to the Java language or Java SDK. Includes:

In addition, the functions javaClass() and javaClassFromInstance() allow Ceylon programs to obtain an instance of Class.

Platform: Java
By: The Ceylon Team
Packages
ceylon.interop.java
Dependencies
ceylon.collection1.2.0
java.base7
Aliases
ByteArrayLikeSource Codeshared ByteArrayLike=> Array<Bits>|ByteArray

An array whose elements can be represented as an Array<Byte>.

FloatArrayLikeSource Codeshared FloatArrayLike=> Array<Single>|Array<Double>|FloatArray|DoubleArray

An array whose elements can be represented as an Array<Float>.

IntegerArrayLikeSource Codeshared IntegerArrayLike=> Array<Short>|Array<Int>|Array<Long>|ShortArray|IntArray|LongArray

An array whose elements can be represented as an Array<Integer>.

JavaStringArrayLikeSource Codeshared JavaStringArrayLike=> ObjectArray<String>|Array<String>|Array<String?>

An array whose elements can be represented as an ObjectArray<JavaString>.

StringArrayLikeSource Codeshared StringArrayLike=> ObjectArray<JavaString>|Array<JavaString?>|Array<JavaString>

An array whose elements can be represented as an Array<String?>.

Functions
createJavaBooleanArraySource Codeshared BooleanArray createJavaBooleanArray({Boolean*} booleans)

Create a new BooleanArray, that is, a Java boolean[] array, with the given elements.

createJavaByteArraySource Codeshared ByteArray createJavaByteArray({Byte*} elements)

Create a new ByteArray, that is, a Java byte[] array, with the given elements.

createJavaDoubleArraySource Codeshared DoubleArray createJavaDoubleArray({Float*} elements)

Create a new DoubleArray, that is, a Java double[] array, with the given elements.

createJavaFloatArraySource Codeshared FloatArray createJavaFloatArray({Float*} elements)

Create a new FloatArray, that is, a Java float[] array, with the given elements.

createJavaIntArraySource Codeshared IntArray createJavaIntArray({Integer*} elements)

Create a new IntArray, that is, a Java int[] array, with the given elements.

createJavaLongArraySource Codeshared LongArray createJavaLongArray({Integer*} elements)

Create a new LongArray, that is, a Java long[] array, with the given elements.

createJavaObjectArraySource Codeshared ObjectArray<T> createJavaObjectArray<T>({T?*} elements)
given T satisfies Object

Create a new ObjectArray, that is, a Java Object[] array, with the given elements.

createJavaShortArraySource Codeshared ShortArray createJavaShortArray({Integer*} elements)

Create a new ShortArray, that is, a Java short[] array, with the given elements.

createJavaStringArraySource Codeshared ObjectArray<JavaString> createJavaStringArray({String*} elements)

Create a new string array, that is, a Java String[] array, with the given elements.

javaBooleanArraySource Codeshared BooleanArray javaBooleanArray(Array<Boolean>|Array<Bool> array)

The BooleanArray, that is, the Java boolean[] array, underyling the given Ceylon array. Changes made to this Java array will be reflected in the given Array and vice versa.

javaByteArraySource Codeshared ByteArray javaByteArray(Array<Byte>|Array<Bits> array)

The ByteArray, that is, the Java byte[] array underyling the given Ceylon array. Changes made to this Java array will be reflected in the given Array and vice versa.

javaCharArraySource Codeshared CharArray javaCharArray(Array<Char> array)

The CharArray, that is, the Java char[] array underyling the given Ceylon array. Changes made to this Java array will be reflected in the given Array and vice versa.

javaClassSource Codeshared Class<Type> javaClass<Type>()
given Type satisfies Object

A Java Class object representing the given Type.

javaClassFromDeclarationSource Codeshared Class<out Object> javaClassFromDeclaration(ClassOrInterfaceDeclaration declaration)

A Java Class object representing the given ClassOrInterfaceDeclaration.

javaClassFromInstanceSource Codeshared Class<out Type> javaClassFromInstance<Type>(Type instance)
given Type satisfies Object

A Java Class object representing the concrete type of the given instance.

javaDoubleArraySource Codeshared DoubleArray javaDoubleArray(Array<Float>|Array<Double> array)

The DoubleArray, that is, the Java double[] array underyling the given Ceylon array. Changes made to this Java array will be reflected in the given Array and vice versa.

javaFloatArraySource Codeshared FloatArray javaFloatArray(Array<Single> array)

The FloatArray, that is, the Java float[] array underyling the given Ceylon array. Changes made to this Java array will be reflected in the given Array and vice versa.

javaIntArraySource Codeshared IntArray javaIntArray(Array<Character>|Array<Int> array)

The IntArray, that is, the Java int[] array underyling the given Ceylon array. Changes made to this Java array will be reflected in the given Array and vice versa.

javaLongArraySource Codeshared LongArray javaLongArray(Array<Integer>|Array<Long> array)

The LongArray, that is, the Java long[] array underyling the given Ceylon array. Changes made to this Java array will be reflected in the given Array and vice versa.

javaObjectArraySource Codeshared ObjectArray<Element> javaObjectArray<Element>(Array<Element?> array)
given Element satisfies Object

The ObjectArray, that is, the Java Object[] array underyling the given Ceylon array. Changes made to this Java array will be reflected in the given Array and vice versa.

javaShortArraySource Codeshared ShortArray javaShortArray(Array<Short> array)

The ShortArray, that is, the Java short[] array underyling the given Ceylon array. Changes made to this Java array will be reflected in the given Array and vice versa.

javaStackTraceSource Codeshared StackTraceElement[] javaStackTrace(Throwable throwable)

The stack trace information for the given Throwable as a sequence of Java StackTraceElements, or the empty sequence if no stack trace information is available. The first element of the sequence is the top of the stack, that is, the most deeply nested stack frame. This is usually the stack frame in which the given Throwable was created and thrown.

javaStringSource Codeshared JavaString javaString(String string)

The JavaString underlying the given Ceylon String.

javaStringArraySource Codeshared ObjectArray<JavaString> javaStringArray(Array<String> array)

The string array, that is, the Java String[] array underyling the given Ceylon array. Changes made to this Java array will be reflected in the given Array and vice versa.

toByteArraySource Codeshared Array<Byte> toByteArray(ByteArrayLike array)

Create a new Array<Byte> with the same elements as the given array.

toFloatArraySource Codeshared Array<Float> toFloatArray(FloatArrayLike array)

Create a new Array<Float> with the same elements as the given array.

toIntegerArraySource Codeshared Array<Integer> toIntegerArray(IntegerArrayLike array)

Create a new Array<Integer> with the same elements as the given array.

toJavaStringArraySource Codeshared ObjectArray<JavaString> toJavaStringArray(JavaStringArrayLike array)

Create a new Java string array, that is, a Java String[], with the same elements as the given array of Ceylon strings.

toStringArraySource Codeshared Array<String?> toStringArray(StringArrayLike array)

Create a new Ceylon string array, that is, an Array<String?> with the same elements as the given array of Java strings.

Classes
CeylonCollectionSource Codeshared CeylonCollection<out Element>

A Ceylon Collection that wraps a JCollection.

CeylonDestroyableSource Codeshared CeylonDestroyable<Resource>
given Resource satisfies AutoCloseable

A Ceylon Destroyable that adapts an instance of Java's AutoCloseable, allowing it to be used as a resource in the try construct.

try (inputStream = CeylonDestroyable(FileInputStream(file)) {
    Integer byte = inputStream.resource.read();
    ...
}
CeylonIterableSource Codeshared CeylonIterable<T>

A Ceylon Iterable that adapts an instance of Java's JIterable, allowing its elements to be iterated using a for loop.

IntArray ints = ... ;
for (int in CeylonIterable(Arrays.asList(*ints.array))) {
    ...
}
CeylonIteratorSource Codeshared CeylonIterator<T>

A Ceylon Iterator that adapts an instance of Java's JIterator.

CeylonListSource Codeshared CeylonList<out Element>
given Element satisfies Object

A Ceylon List that wraps a JList.

CeylonMapSource Codeshared CeylonMap<out Key,out Item>
given Key satisfies Object
given Item satisfies Object

A Ceylon Map that wraps a JMap.

CeylonMutableListSource Codeshared CeylonMutableList<Element>
given Element satisfies Object

A Ceylon MutableList that wraps a JList.

CeylonMutableMapSource Codeshared CeylonMutableMap<Key,Item>
given Key satisfies Object
given Item satisfies Object

A Ceylon MutableMap that wraps a JMap.

CeylonMutableSetSource Codeshared CeylonMutableSet<Element>
given Element satisfies Object

A Ceylon MutableSet that wraps a JSet.

CeylonSetSource Codeshared CeylonSet<out Element>
given Element satisfies Object

A Ceylon Set that wraps a JSet.

CeylonStringMapSource Codeshared CeylonStringMap<out Item>

A Map with keys of type ceylon.language::String that wraps a Map with keys of type java.lang.String.

This class can be used to wrap a java.util::Map if the Java map is first wrapped with CeylonMap:

   CeylonStringMap(CeylonMap(javaMap))
CeylonStringMutableMapSource Codeshared CeylonStringMutableMap<Item>

A MutableMap with keys of type ceylon.language::String that wraps a MutableMap with keys of type java.lang::String.

This class can be used to wrap a java.util::Map if the Java map is first wrapped with CeylonMutableMap:

   CeylonStringMutableMap(CeylonMutableMap(javaMap))
JavaCloseableSource Codeshared JavaCloseable<Resource>
given Resource satisfies Destroyable

A Java AutoCloseable that adapts an instance of Ceylon's Destroyable, allowing it to be used as a resource in the try construct.

JavaCollectionSource Codeshared JavaCollection<E>

A Java Collection that wraps a Ceylon Collection. This collection is unmodifiable, throwing UnsupportedOperationException from mutator methods.

JavaComparatorSource Codeshared JavaComparator<Element>

A Java JComparator that wraps a function returning Comparison. The given JavaComparator.compareElements() function will be used to compare null values if Element covers Null. Otherwise, nulls will be ordered according to the JavaComparator.nulls parameter.

JavaIterableSource Codeshared JavaIterable<T>

A Java JIterable that wraps a Ceylon Iterable.

JavaIteratorSource Codeshared JavaIterator<T>

A Java JIterator that wraps a Ceylon Iterator. This iterator is unmodifiable, throwing UnsupportedOperationException from JavaIterator.remove().

JavaListSource Codeshared JavaList<E>

A Java List that wraps a Ceylon List. This list is unmodifiable, throwing UnsupportedOperationException from mutator methods.

JavaMapSource Codeshared JavaMap<K,V>
given K satisfies Object
given V satisfies Object

A Java JMap that wraps a Ceylon Map. This map is unmodifiable, throwing UnsupportedOperationException from mutator methods.

JavaSetSource Codeshared JavaSet<E>
given E satisfies Object

A Java Set that wraps a Ceylon Set. This set is unmodifiable, throwing UnsupportedOperationException from mutator methods.