Permalink
Browse files

added source arg to Streamy class

  • Loading branch information...
Jeremy Cloud
Jeremy Cloud committed Dec 27, 2010
1 parent 4d4ad90 commit 7b6448f124b4d8f119a92ab8a2b9312ef2deb7bb
Showing with 10 additions and 8 deletions.
  1. +1 −1 project/plugins/Plugins.scala
  2. +9 −7 src/main/scala/com/twitter/streamyj/Streamy.scala
@@ -2,5 +2,5 @@ import sbt._
class Plugins(info: ProjectInfo) extends PluginDefinition(info) {
val twitterMaven = "twitter.com" at "http://maven.twttr.com/"
- val defaultProject = "com.twitter" % "standard-project" % "0.7.17"
+ val defaultProject = "com.twitter" % "standard-project" % "0.7.23"
}
@@ -17,26 +17,28 @@ object Streamy {
*/
val factory = new JsonFactory()
- def apply(source: String): Streamy = apply(factory.createJsonParser(source))
- def apply(reader: Reader): Streamy = apply(factory.createJsonParser(reader))
- def apply(file: File): Streamy = apply(factory.createJsonParser(file))
- def apply(parser: JsonParser): Streamy = new Streamy(parser)
+ def apply(source: String): Streamy = apply(factory.createJsonParser(source), source)
+ def apply(reader: Reader): Streamy = apply(factory.createJsonParser(reader), reader.toString)
+ def apply(file: File): Streamy = apply(factory.createJsonParser(file), file.getPath)
+ def apply(parser: JsonParser): Streamy = apply(parser, parser.toString)
+ def apply(parser: JsonParser, src: => String ): Streamy = new Streamy(parser, src)
}
/**
* A helper for the Jackson JSON parser.
*
* Streamy allows you to write streaming parsers in an elegant,
- * Scala-idiomatic manner. A quick example:
- *
+ * Scala-idiomatic manner.
*/
-class Streamy(parser: JsonParser) {
+class Streamy(parser: JsonParser, val source: String) {
import Streamy.ObjectParseFunc
import Streamy.ArrayParseFunc
private var currentToken: StreamyToken = NotAvailable
private var peekedToken: StreamyToken = NotAvailable
+ override def toString = "Streamy(" + source + ")"
+
/**
* Advances the parser and sets the current token.
* @throws JsonParseException if the are no more tokens

0 comments on commit 7b6448f

Please sign in to comment.