github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

jorgeortiz85 / scala-javautils

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 92
    • 2
  • Source
  • Commits
  • Network (2)
  • Issues (0)
  • Downloads (5)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (6)
    • 270
    • 271
    • 272
    • 273
    • master ✓
    • osgi
  • Tags (5)
    • 2.7.4-0.1
    • 2.7.3-0.1
    • 2.7.2-0.1
    • 2.7.1-0.1
    • 2.7.0-0.1
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

An set of utilities for dealing with Java and Scala collections. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Note Heiko's changes 
jorgeortiz85 (author)
Wed May 13 01:08:46 -0700 2009
commit  9a8c2de1f56b85c86709afa168f5f68c052dd6dd
tree    ed7b12f64bd1f35c5d64cf35209058d0af511662
parent  d1d527de15bf840030de4997118b98b61826fe96
scala-javautils /
name age
history
message
file .gitignore Sun Apr 05 20:48:48 -0700 2009 Initial commit [Jorge Ortiz]
file LICENSE Mon Apr 06 01:07:52 -0700 2009 LICENSE, README, Copyright notices [Jorge Ortiz]
file NOTES Wed Apr 29 13:51:39 -0700 2009 Update NOTES to reflect Dictionary stuff [Jorge Ortiz]
file README Mon Apr 27 05:26:00 -0700 2009 Tidy up, add some sample usage [Jorge Ortiz]
file pom.xml Wed May 13 01:07:57 -0700 2009 Merge branch 'osgi' [jorgeortiz85]
directory src/ Wed May 13 01:08:46 -0700 2009 Note Heiko's changes [jorgeortiz85]
README
Utilities for dealing with Java and Scala collections.

USAGE:

Turn any Scala collection into the corresponding Java collection:

  import org.scala_tools.javautils.Imports._

  List(1, 2, 3).asJava
  // returns java.util.List[Int]

  Map(1 -> "a", 2 -> "b", 3 -> "c").asJava
  // returns java.util.Map[Int, String]

  Set(1, 2, 3).asJava
  // returns java.util.Set[Int]

Turn any Java collection into the corresponding Scala collection:

  val list = new java.util.ArrayList[Int]
  list.add(1)
  list.add(2)
  list.add(3)
  list.asScala
  // returns scala.Seq[Int]

For the full list of available conversions, please see the NOTES file.

You can also use foreach on any Java collection:

  list.foreach(print)
  // prints "123"

The "map", "filter", and "flatMap" methods are still pending.

MOTIVATION:

The Scala standard library includes a set of utilities for working with Java
collection in Scala (scala.collection.jcl). It is deficient in several ways:

1) It neglects several important Java interfaces, most notably: Enumeration,
   Iterator, Iterable, and Collection.

2) There is no way to convert from an arbitrary Scala collection to a Java
   collection. It is suitable for those wishing to use Java collections via
   Scala collection interfaces, but is unsuitable for those wishing to use
   Scala collections with legacy Java libraries that expect Java collections.

3) It is reckless in its use of implicits. The implicit conversions in
   scala.collection.jcl.Conversions are dangerous and should not be trusted.
   They "massage" types in ways that can be unpredictable for users not
   intimately familiar with scala.collections.jcl.

KNOWN ISSUES:

There are no tests.

Iterators on mutable collections aren't themselves mutable.

None of the wrappers make any attempt at thread-safety, even when the underlying
collection is thread-safe.

Classes inheriting from Wrapper probably lose symmetry for "equals".

Wrappers may throw the wrong exception (i.e., exception thrown by the wrapped
collection are not anticipated by the wrapper interface).
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server