pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Scala pastebin - Herramienta Colaborativa - Home - View Help - Archive

Posted by ArtemGr on December Thu 10th 5:31 PM - Never Expires (modification of post by ArtemGr view diff)
diff | download | new post

  1. import scala.reflect.BeanProperty
  2. case class DenormalizedRating (@BeanProperty var actLevStart: Int, @BeanProperty var actLevEnd: Int) {
  3.   def this () = this (0, 0) // Default constructor for flexjson.
  4.   def activityRating = actLevEnd - actLevStart
  5. }
  6.  
  7.     def cl = new flexjson.ClassLocator {
  8.       val classLoader = Thread.currentThread.getContextClassLoader
  9.       override def locate (map: java.util.Map[_,_], path: flexjson.Path): Class[_] = {
  10.         if (map.containsKey ("actLevStart")) classOf[DenormalizedRating]
  11.         else {
  12.           val clazz = map.get ("class") // Flexjson class signature.
  13.           if (clazz.isInstanceOf[String]) classLoader.loadClass (clazz.toString)
  14.           else classOf[java.util.HashMap[_, _]]
  15.         }
  16.       }
  17.     }
  18.  
  19. (new flexjson.JSONDeserializer () .use (null, cl) .deserialize ("""
  20.  {"foo1": "bar1",
  21.   "foo2": {"actLevStart": 1, "actLevEnd": 2},
  22.   "foo3": {"someMapKey": "someMapValue"}}
  23. """)).toString

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.
Syntax Highlighting:
To highlight particular lines, prefix each line with @@
Pressing TAB inserts 3 spaces