What's the simplest API to use in scala to perform the following XPath queries on a document?
//s:Annotation[@type='attitude']/s:Content/s:Parameter[@role='type' and not(text())]
//s:Annotation[s:Content/s:Parameter[@role='id' and not(text())]]/@type
(s is defined as a nickname for a particular namespace)
The only documentation I ca...
I'm developing a scala library, which I would like to be used by java applications.
If I set up a java project in netbeans, with a reference to the scala library (jar), I can compile the java project without errors.
However I get problems when running the java project directly from netbeans (code from scala library is not executed e.g...
We know that implementing classes are still invariant, despite the fact that their interfaces are variant. However I am inquiring, is cov/contravariance a step closer to parametric polymorphism or these are two separate concepts?
...
I use opencsv to parse csv files, and my code is
while( (line = reader.readNext()) != null ) { .... }
I got a compiler warning saying:
comparing values of types Unit and Null using `!=' will always yield true
[warn] while( (aLine = reader.readNext()) != null ) {
How should I do the while loop?
...
I'm new to Lift framework for scala. For some reason, index.html resides in the web-app directory, and when I start up jetty, http://localhost:8080/ will point to that index.html file just fine. However, if I put a login.html file in the same folder as the index.html, and then go http://localhost:8080/login, Lift does not serve the file....
I am using buildr to build my scala project and suppose I want to run a main program among the source code, I need to define custom task within buildr which is very easy. However, how can I pass the classpath dependency automatically?(i.e) suppose you have a large number of jar files added already as dependency within buildr. Is there an...
I want to issue a native system command from a Scala program, and perhaps trap the output. ("ls" comes to mind. There may be other ways to get directory information without issuing the command, but that's beside the point of my question.) It would correspond to os.system(...) in Python.
I've looked in "Programming in Scala". I've looked...
G'day everyone,
I'm a Scala n00b (but am experienced with other languages) and am learning the language as I find time - very much enjoying it so far!
Usually when learning a new language the first thing I do is implement Conway's Game of Life, since it's just complex enough to give a good sense of the language, but small enough in sco...
I am making my first foray into scala for a production app.
The app is currently packaged as a war file.
My plan is to create a jar file of the scala compiled artifacts and add that into the lib folder for the war file.
My enhancement is a mysql-backed app exposed via Jersey & will be integrated with a 3rd party site via HttpClient inv...
Hi,
I have just started learning Scala and I'm now wondering how I could implement two different Java interfaces with one Scala class? Let's say I have the following interfaces written in Java
public interface EventRecorder {
public void abstract record(Event event);
}
public interface TransactionCapable {
public void abstrac...
I want to create a specific generic method in Scala. It takes two parameters. The first is of the type of a generic Java Interface (it's from the JPA criteria query). It currently looks like this:
def genericFind(attribute:SingularAttribute[Person, _], value:Object) {
...
}
// The Java Interface which is the type of the first paramet...
I have a trait in Scala that has a single method. Call it Computable and the single method is compute(input: Int): Int. I can't figure out whether I should
Leave it as a standalone trait with a single method.
Inherit from (Int => Int) and rename "compute" to "apply."
Just get rid of Computable and use (Int => Int).
A factor in favo...
In my thesis, I woud like to enhance messaging in a cluster.
It's important to log runtime information about how big a message is (should I prefer processing local or remote).
I could just find frameworks about estimating the object memory size based on java instrumentation. I've tested classmexer, which didn't come close to the serial...
Hi.
Scala implicits are very powerfull. I'm curious if they are a new/unique feature of Scala, or the concept already existed in other programming languages.
Thanks.
EDIT:
To clarify my question, yes, I'm talking about this concrete implementation. Having "implicit things" all around seemed strange at first, but having used it for a...
Hi,
I'm trying to use Scala as part of an existing Java application and now I run into an issue with dependencies injected with a setter method (no DI frameworks in this part of code). How is this handled in a Scala way?
In Scala both val and var require to be initialized when declared but I can't do that, since the Java setters injec...
As an exercise I tried to create an implicit conversion that would accept a function and produce a Runnable. That way you could call java methods that accept Runnables and use them like closures.
the implicit conversion is easy enough:
implicit def funToRunnable(fun : Unit) = new Runnable() { def run = fun }
however I don't know ...
I would like to convert a Map[Int, Any] to a SortedMap or a TreeMap and haven't been able to find an easy way to do it.
...
On IntelliJ 9.0.2 with the latest Scala plugin, the problem is that the code formatter turns this:
object Test
{
def main (args: Array[String])
{
if (...)
{
...
}
}
}
into this:
object Test
{
def main (args: Array[String])
{
if (...)
{
...
...
I have two files:
logic.scala and main.scala
logic.scala contains one class
and main.scala have one class with method main (to run it). And i wannt to import class from logic.scala and use this class to create object(s) and work with them.
How to import and compile it in proper way?
...
I'm working on a little project where I'd like to parse some data, and then put it into a database. I'm not working with Lift, and I haven't been able to find a standard way to do this.
I'm fine writing the queries myself, but I'm not sure what to use to actually connect to the DB.
...