The jpropel library has a Scala flavour
Scala
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
licenses
src
README.markdown
propels-core-1.0.7.jar
propels-core-1.0.7.pom
propels-core-1.0.8.jar
propels-core-1.0.8.pom

README.markdown

Hi there!

PropelS is a Scala library porting features of JPropel.

  • LINQ for Scala, with Scala semantics (such as functions, implicits, etc)
  • Conversions for easily working between Java and Scala collections
  • Free and open-source, can be used for commercial purposes (LGPL license)

LINQ

A very popular language feature of C#, Language INtegrated Query adds native data querying capabilities. The Scala collections library supports most of these features, but you may not have the time to learn an entirely new API. Using PropelS you can continue using an API you already know. Also, having a Java port of LINQ you may re-use your experience across three languages (C#, Java, Scala).

// declaration
val buff = Buffer("john", "james", "eddie")

// transform & filter
val upper = Linq.select(buff, (x : String)=> StringUtils.titleCase(x) )
val jays = Linq.where(upper, (x : String) => x.startsWith("J"))

// output: "John, James"
println(StringUtils.delimit(Linq.toArray(jays), ", "))

Java <--> Scala collections bridging

There are a lot moving parts in Scala collections and having them changed a few times did not help many developers. Using PropelS (this project!) you can easily convert between Java/Scala collections:

toArray(...)

// Scala Traversable -> Array conversion
val buff = Buffer("a", "b", "c", "d").asInstanceOf[Traversable[String]]
Linq.toArray(buff)

// JDK ArrayList -> Array conversion
val list = new java.util.ArrayList[String]()
Linq.toArray(list)

// JDK Iterable -> Array conversion
val iterable = new java.util.ArrayList[String]().asInstanceOf[java.lang.Iterable[String]]
Linq.toArray(iterable)

// JDK Enumeration -> Array conversion
val enum = new java.util.StringTokenizer("test")  // note: implements Enumeration[Object]
Linq.toArray(enum)  

toBuffer(...)

// Array -> Scala mutable Buffer
val arr = Array("a", "b", "c", "d")
Linq.toBuffer(arr)

// Scala Traversable -> Scala mutable Buffer
val seq = Buffer("a", "b", "c", "d").asInstanceOf[Traversable[String]]
Linq.toBuffer(seq)    

// JDK ArrayList -> Scala mutable Buffer
val list = new java.util.ArrayList[String]()
Linq.toBuffer(list)

// JDK Iterable -> Scala mutable Buffer
val iterable = new java.util.ArrayList[String]().asInstanceOf[java.lang.Iterable[String]]
Linq.toBuffer(iterable)

// JDK Enumeration -> Scala mutable Buffer
val enum = new java.util.StringTokenizer("test")  // note: implements Enumeration[Object]
Linq.toBuffer(enum)  

toSeq(...)

// Array -> Scala immutable IndexedSeq
val arr = Array("a", "b", "c", "d")
Linq.toSeq(arr)

// Scala Traversable -> Scala immutable IndexedSeq
val seq = Buffer("a", "b", "c", "d").asInstanceOf[Traversable[String]]
Linq.toSeq(seq)    

// JDK ArrayList -> Scala immutable IndexedSeq
val list = new java.util.ArrayList[String]()
Linq.toSeq(list)

// JDK Iterable -> Scala immutable IndexedSeq
val iterable = new java.util.ArrayList[String]().asInstanceOf[java.lang.Iterable[String]]
Linq.toSeq(iterable)

// JDK Enumeration -> Scala immutable IndexedSeq
val enum = new java.util.StringTokenizer("test")  // note: implements Enumeration[Object]
Linq.toSeq(enum)

toArrayList(...)

// Array -> JDK ArrayList
val arr = Array("a", "b", "c", "d")
Linq.toArrayList(arr)

// Scala Traversable -> JDK ArrayList
val seq = Buffer("a", "b", "c", "d").asInstanceOf[Traversable[String]]
Linq.toArrayList(seq)    

// JDK Iterable -> JDK ArrayList
val iterable = new java.util.ArrayList[String]().asInstanceOf[java.lang.Iterable[String]]
Linq.toArrayList(iterable)

// JDK Enumeration -> JDK ArrayList
val enum = new java.util.StringTokenizer("test")  // note: implements Enumeration[Object]
Linq.toArrayList(enum)

Free and Open

You may use this project in open and closed source projects. The LGPL license simply requests any changes made to this library alone, to be contributed back. Help us evolve!

Dependencies

As PropelS is in its early stages, it currently depends on the latest JPropel-light library because it requires certain un-ported yet classes. There are plans to port certain things over to Scala (especially if they are using functional features), which are currently handled using lombok-pg.

Changelog

1.0.8: Upgrade dependency

Update dependency: jpropel-light v1.1.8 Linq.toString for arrays, iterables, sequence

1.0.7: Upgrade!

Scala 2.10 compatibility Update dependency: jpropel v1.0.7

1.0.1: update to jpropel v1.0.5

1.0: feature complete

0.5: Upgrade

Updated dependencies to latest versions

0.3/0.4: Bugfixing

For comprehension "return"

0.2: Almost all functional classes ported

ArrayUtils ported LINQ bugfixes

0.1: Creation

All LINQ methods have been ported.
Added extra methods: partition, unzip (these will be backported to jpropel)