|
Scala Library
|
|
scala/collection/JavaConversions.scala]
object
JavaConversions
extends AnyRefA collection of implicit conversions supporting interoperability between Scala and Java collections.
The following conversions are supported:
scala.collection.Iterable <=> java.lang.Iterablescala.collection.Iterable <=> java.util.Collectionscala.collection.Iterator <=> java.util.{ Iterator, Enumeration }scala.collection.mutable.Buffer <=> java.util.Listscala.collection.mutable.Set <=> java.util.Setscala.collection.mutable.Map <=> java.util.MapIn all cases, converting from a source type to a target type and back again will return the original source object, eg.
import scala.collection.JavaConversions._
val sl = new scala.collection.mutable.ListBuffer[Int]
val jl : java.util.List[Int] = sl
val sl2 : scala.collection.mutable.Buffer[Int] = jl
assert(sl eq sl2)g
Note that no conversion is provided from scala.collection.immutable.List
to java.util.List. Instead it is convertible to an immutable
java.util.Collection which provides size and interation
capabilities, but not access by index as would be provided by
java.util.List.
This is intentional: in combination the implementation of
scala.collection.immutable.List and the typical usage
patterns of java.util.List would perform extremely poorly.
| Method Summary | |
implicit def
|
asBuffer
[A](l : java.util.List[A]) : Buffer[A]
Implicitly converts a Java
List to a Scala mutable Buffer.
The returned Scala Buffer is backed by the provided Java
List and any side-effects of using it via the Scala interface will
be visible via the Java interface and vice versa. |
implicit def
|
asCollection
[A](i : Iterable[A]) : java.util.Collection[A]
Implicitly converts a Scala
Iterable to an immutable Java
Collection. |
implicit def
|
asEnumeration
[A](i : Iterator[A]) : java.util.Enumeration[A]
Implicitly converts a Scala
Iterator to a Java Enumeration.
The returned Java Enumeration is backed by the provided Scala
Iterator and any side-effects of using it via the Java interface will
be visible via the Scala interface and vice versa. |
implicit def
|
asIterable
[A](i : java.lang.Iterable[A]) : Iterable[A]
Implicitly converts a Java
Iterable to a Scala Iterable.
The returned Scala Iterable is backed by the provided Java
Iterable and any side-effects of using it via the Scala interface will
be visible via the Java interface and vice versa. |
implicit def
|
asIterable
[A](i : java.util.Collection[A]) : Iterable[A]
Implicitly converts a Java
Collection to an Scala Iterable. |
implicit def
|
asIterable
[A](i : Iterable[A]) : java.lang.Iterable[A]
Implicitly converts a Scala
Iterable to a Java Iterable.
The returned Java Iterable is backed by the provided Scala
Iterable and any side-effects of using it via the Java interface will
be visible via the Scala interface and vice versa. |
implicit def
|
asIterator
[A](i : java.util.Iterator[A]) : Iterator[A]
Implicitly converts a Java
Iterator to a Scala Iterator.
The returned Scala Iterator is backed by the provided Java
Iterator and any side-effects of using it via the Scala interface will
be visible via the Java interface and vice versa. |
implicit def
|
asIterator
[A](i : Iterator[A]) : java.util.Iterator[A]
Implicitly converts a Scala
Iterator to a Java Iterator.
The returned Java Iterator is backed by the provided Scala
Iterator and any side-effects of using it via the Java interface will
be visible via the Scala interface and vice versa. |
implicit def
|
asIterator
[A](i : java.util.Enumeration[A]) : Iterator[A]
Implicitly converts a Java
Enumeration to a Scala Iterator.
The returned Scala Iterator is backed by the provided Java
Enumeration and any side-effects of using it via the Scala interface will
be visible via the Java interface and vice versa. |
implicit def
|
asList
[A](b : Buffer[A]) : java.util.List[A]
Implicitly converts a Scala mutable
Buffer to a Java List.
The returned Java List is backed by the provided Scala
Buffer and any side-effects of using it via the Java interface will
be visible via the Scala interface and vice versa. |
implicit def
|
asMap
[A, B](m : Map[A, B])(implicit ma : ClassManifest[A]) : java.util.Map[A, B]
Implicitly converts a Scala mutable
Map to a Java Map.
The returned Java Map is backed by the provided Scala
Map and any side-effects of using it via the Java interface will
be visible via the Scala interface and vice versa. |
implicit def
|
asMap
[A, B](m : java.util.Map[A, B]) : Map[A, B]
Implicitly converts a Java
Map to a Scala mutable Map.
The returned Scala Map is backed by the provided Java
Map and any side-effects of using it via the Scala interface will
be visible via the Java interface and vice versa. |
implicit def
|
asSet
[A](s : Set[A])(implicit m : ClassManifest[A]) : java.util.Set[A]
Implicitly converts a Scala mutable
Set to a Java Set.
The returned Java Set is backed by the provided Scala
Set and any side-effects of using it via the Java interface will
be visible via the Scala interface and vice versa. |
implicit def
|
asSet
[A](s : java.util.Set[A]) : Set[A]
Implicitly converts a Java
Set to a Scala mutable Set.
The returned Scala Set is backed by the provided Java
Set and any side-effects of using it via the Scala interface will
be visible via the Java interface and vice versa. |
| Methods inherited from AnyRef | |
| getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized |
| Methods inherited from Any | |
| ==, !=, isInstanceOf, asInstanceOf |
| Class Summary | |
case class
|
IterableWrapper
[A](val underlying : Iterable[A]) extends java.util.AbstractCollection[A] with Product
|
case class
|
IteratorWrapper
[A](val underlying : Iterator[A]) extends java.util.Iterator[A] with java.util.Enumeration[A] with Product
|
case class
|
JCollectionWrapper
[A](val underlying : java.util.Collection[A]) extends Iterable[A] with Product
|
case class
|
JEnumerationWrapper
[A](val underlying : java.util.Enumeration[A]) extends Iterator[A] with Product
|
case class
|
JIterableWrapper
[A](val underlying : java.lang.Iterable[A]) extends Iterable[A] with Product
|
case class
|
JIteratorWrapper
[A](val underlying : java.util.Iterator[A]) extends Iterator[A] with Product
|
case class
|
JListWrapper
[A](val underlying : java.util.List[A]) extends Buffer[A] with Product
|
case class
|
JMapWrapper
[A, B](val underlying : java.util.Map[A, B]) extends Map[A, B] with MapLike[A, B, JMapWrapper[A, B]] with Product
|
case class
|
JSetWrapper
[A](val underlying : java.util.Set[A]) extends Set[A] with SetLike[A, JSetWrapper[A]] with Product
|
case class
|
MutableBufferWrapper
[A](val underlying : Buffer[A]) extends java.util.AbstractList[A] with Product
|
case class
|
MutableMapWrapper
[A, B](val underlying : Map[A, B], m : ClassManifest[A]) extends java.util.AbstractMap[A, B] with Product
|
case class
|
MutableSetWrapper
[A](val underlying : Set[A], m : ClassManifest[A]) extends java.util.AbstractSet[A] with Product
|
| Method Details |
implicit
def
asIterator[A](i : Iterator[A]) : java.util.Iterator[A]
Iterator to a Java Iterator.
The returned Java Iterator is backed by the provided Scala
Iterator and any side-effects of using it via the Java interface will
be visible via the Scala interface and vice versa.
If the Scala Iterator was previously obtained from an implicit or
explicit call of asIterator(java.util.Iterator) then the original
Java Iterator will be returned.
i - The Iterator to be converted.Iterator view of the argument.implicit
def
asEnumeration[A](i : Iterator[A]) : java.util.Enumeration[A]
Iterator to a Java Enumeration.
The returned Java Enumeration is backed by the provided Scala
Iterator and any side-effects of using it via the Java interface will
be visible via the Scala interface and vice versa.
If the Scala Iterator was previously obtained from an implicit or
explicit call of asIterator(java.util.Enumeration) then the
original Java Enumeration will be returned.
i - The Iterator to be converted.Enumeration view of the argument.implicit
def
asIterable[A](i : Iterable[A]) : java.lang.Iterable[A]
Iterable to a Java Iterable.
The returned Java Iterable is backed by the provided Scala
Iterable and any side-effects of using it via the Java interface will
be visible via the Scala interface and vice versa.
If the Scala Iterable was previously obtained from an implicit or
explicit call of asIterable(java.lang.Iterable) then the original
Java Iterable will be returned.
i - The Iterable to be converted.Iterable view of the argument.implicit
def
asCollection[A](i : Iterable[A]) : java.util.Collection[A]
Iterable to an immutable Java
Collection.
If the Scala Iterable was previously obtained from an implicit or
explicit call of asSizedIterable(java.util.Collection) then the original
Java Collection will be returned.
i - The SizedIterable to be converted.Collection view of the argument.implicit
def
asList[A](b : Buffer[A]) : java.util.List[A]
Buffer to a Java List.
The returned Java List is backed by the provided Scala
Buffer and any side-effects of using it via the Java interface will
be visible via the Scala interface and vice versa.
If the Scala Buffer was previously obtained from an implicit or
explicit call of asBuffer(java.util.List) then the original
Java List will be returned.
b - The Buffer to be converted.List view of the argument.implicit
def
asSet[A](s : Set[A])(implicit m : ClassManifest[A]) : java.util.Set[A]
Set to a Java Set.
The returned Java Set is backed by the provided Scala
Set and any side-effects of using it via the Java interface will
be visible via the Scala interface and vice versa.
If the Scala Set was previously obtained from an implicit or
explicit call of asSet(java.util.Set) then the original
Java Set will be returned.
s - The Set to be converted.Set view of the argument.implicit
def
asMap[A, B](m : Map[A, B])(implicit ma : ClassManifest[A]) : java.util.Map[A, B]
Map to a Java Map.
The returned Java Map is backed by the provided Scala
Map and any side-effects of using it via the Java interface will
be visible via the Scala interface and vice versa.
If the Scala Map was previously obtained from an implicit or
explicit call of asMap(java.util.Map) then the original
Java Map will be returned.
m - The Map to be converted.Map view of the argument.implicit
def
asIterator[A](i : java.util.Iterator[A]) : Iterator[A]
Iterator to a Scala Iterator.
The returned Scala Iterator is backed by the provided Java
Iterator and any side-effects of using it via the Scala interface will
be visible via the Java interface and vice versa.
If the Java Iterator was previously obtained from an implicit or
explicit call of asIterator(scala.collection.Iterator) then the original
Scala Iterator will be returned.
i - The Iterator to be converted.Iterator view of the argument.implicit
def
asIterator[A](i : java.util.Enumeration[A]) : Iterator[A]
Enumeration to a Scala Iterator.
The returned Scala Iterator is backed by the provided Java
Enumeration and any side-effects of using it via the Scala interface will
be visible via the Java interface and vice versa.
If the Java Enumeration was previously obtained from an implicit or
explicit call of asEnumeration(scala.collection.Iterator) then the
original Scala Iterator will be returned.
i - The Enumeration to be converted.Iterator view of the argument.implicit
def
asIterable[A](i : java.lang.Iterable[A]) : Iterable[A]
Iterable to a Scala Iterable.
The returned Scala Iterable is backed by the provided Java
Iterable and any side-effects of using it via the Scala interface will
be visible via the Java interface and vice versa.
If the Java Iterable was previously obtained from an implicit or
explicit call of asIterable(scala.collection.Iterable) then the original
Scala Iterable will be returned.
i - The Iterable to be converted.Iterable view of the argument.implicit
def
asIterable[A](i : java.util.Collection[A]) : Iterable[A]
Collection to an Scala Iterable.
If the Java Collection was previously obtained from an implicit or
explicit call of asCollection(scala.collection.SizedIterable) then
the original Scala SizedIterable will be returned.
i - The Collection to be converted.SizedIterable view of the argument.implicit
def
asBuffer[A](l : java.util.List[A]) : Buffer[A]
List to a Scala mutable Buffer.
The returned Scala Buffer is backed by the provided Java
List and any side-effects of using it via the Scala interface will
be visible via the Java interface and vice versa.
If the Java List was previously obtained from an implicit or
explicit call of asList(scala.collection.mutable.Buffer) then the original
Scala Buffer will be returned.
l - The List to be converted.Buffer view of the argument.implicit
def
asSet[A](s : java.util.Set[A]) : Set[A]
Set to a Scala mutable Set.
The returned Scala Set is backed by the provided Java
Set and any side-effects of using it via the Scala interface will
be visible via the Java interface and vice versa.
If the Java Set was previously obtained from an implicit or
explicit call of asSet(scala.collection.mutable.Set) then the original
Scala Set will be returned.
s - The Set to be converted.Set view of the argument.Map to a Scala mutable Map.
The returned Scala Map is backed by the provided Java
Map and any side-effects of using it via the Scala interface will
be visible via the Java interface and vice versa.
If the Java Map was previously obtained from an implicit or
explicit call of asMap(scala.collection.mutable.Map) then the original
Scala Map will be returned.
m - The Map to be converted.Map view of the argument.|
Scala Library
|
|