<commit_before>package circumflex.freemarker

import core.RouteContext
import _root_.freemarker.core.Environment
import java.io.StringWriter
import _root_.freemarker.ext.beans.BeansWrapper
import _root_.freemarker.template._
import java.util.Date
import net.java.textilej.parser.builder.HtmlDocumentBuilder
import net.java.textilej.parser.markup.textile.TextileDialect
import net.java.textilej.parser.MarkupParser
import org.apache.commons.beanutils.{MethodUtils, PropertyUtils}
import java.lang.reflect.{Field, Method}
import java.lang.String
import scala.collection.jcl.Conversions._

class ScalaObjectWrapper extends ObjectWrapper {
  override def wrap(obj: Any) = obj match {
    case option:Option[Any] => option match {
      case Some(o) => wrap(o)
      case _ => wrap("")
    }
    case model:TemplateModel => model
    case ctx:RouteContext => new ScalaRequestContextWrapper(ctx, this)
    case seq:Seq[Any] => new ScalaSeqWrapper(seq, this)
    case map:Map[Any, Any] => new ScalaMapWrapper(map, this)
    case it:Iterable[Any] => new ScalaIterableWrapper(it, this)
    case it:Iterator[Any] => new ScalaIteratorWrapper(it, this)
    case str:String => new SimpleScalar(str)
    case date:Date => new SimpleDate(date, TemplateDateModel.UNKNOWN)
    case num:Number => new SimpleNumber(num)
    case bool:Boolean => if (bool) TemplateBooleanModel.TRUE else TemplateBooleanModel.FALSE
    case obj => new ScalaBaseWrapper(obj, this)
  }
}

class ScalaSeqWrapper[T](val seq: Seq[T], wrapper: ObjectWrapper)
    extends ScalaBaseWrapper(seq, wrapper) with TemplateSequenceModel {
  def get(index: Int) = wrapper.wrap(seq(index))
  def size = seq.size
}

class ScalaMapWrapper[String,V](val map: Map[String,V], wrapper: ObjectWrapper)
    extends ScalaBaseWrapper(map, wrapper) {
  override def get(key: java.lang.String) = wrapper.wrap(
    map.get(key.asInstanceOf[String])
        orElse map.get(key.replaceAll("\\$","_").asInstanceOf[String])
        orElse Some(super.get(key)))
  override def isEmpty = map.isEmpty
}

class ScalaIterableWrapper[T](val it: Iterable[T], wrapper: ObjectWrapper)<commit_msg>Changed an ftl wrapper behavior on NULLs.<commit_after>package circumflex.freemarker

import core.RouteContext
import _root_.freemarker.core.Environment
import java.io.StringWriter
import _root_.freemarker.ext.beans.BeansWrapper
import _root_.freemarker.template._
import java.util.Date
import net.java.textilej.parser.builder.HtmlDocumentBuilder
import net.java.textilej.parser.markup.textile.TextileDialect
import net.java.textilej.parser.MarkupParser
import org.apache.commons.beanutils.{MethodUtils, PropertyUtils}
import java.lang.reflect.{Field, Method}
import java.lang.String
import scala.collection.jcl.Conversions._

class ScalaObjectWrapper extends ObjectWrapper {
  override def wrap(obj: Any) = obj match {
    case null => null
    case option:Option[Any] => option match {
      case Some(o) => wrap(o)
      case _ => null
    }
    case model:TemplateModel => model
    case ctx:RouteContext => new ScalaRequestContextWrapper(ctx, this)
    case seq:Seq[Any] => new ScalaSeqWrapper(seq, this)
    case map:Map[Any, Any] => new ScalaMapWrapper(map, this)
    case it:Iterable[Any] => new ScalaIterableWrapper(it, this)
    case it:Iterator[Any] => new ScalaIteratorWrapper(it, this)
    case str:String => new SimpleScalar(str)
    case date:Date => new SimpleDate(date, TemplateDateModel.UNKNOWN)
    case num:Number => new SimpleNumber(num)
    case bool:Boolean => if (bool) TemplateBooleanModel.TRUE else TemplateBooleanModel.FALSE
    case obj => new ScalaBaseWrapper(obj, this)
  }
}

class ScalaSeqWrapper[T](val seq: Seq[T], wrapper: ObjectWrapper)
    extends ScalaBaseWrapper(seq, wrapper) with TemplateSequenceModel {
  def get(index: Int) = wrapper.wrap(seq(index))
  def size = seq.size
}

class ScalaMapWrapper[String,V](val map: Map[String,V], wrapper: ObjectWrapper)
    extends ScalaBaseWrapper(map, wrapper) {
  override def get(key: java.lang.String) = wrapper.wrap(
    map.get(key.asInstanceOf[String])
        orElse map.get(key.replaceAll("\\$","_").asInstanceOf[String])
        orElse Some(super.get(key)))
  override def isEmpty = map.isEmpty
}

class ScalaIterableWrapper[T](val it: Iterable[T], wrapper: ObjectWrapper)
{'fraction_non_alphanumeric': 0.11196820944366527, 'fraction_numerical': 0.0, 'mean_word_length': 4.992997198879552, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7140266', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1325, 'n_words': 308}