CommonFunction.scala 538 Bytes
Newer Older
wang-jinfeng committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
package mobvista.dmp.function

import com.googlecode.aviator.runtime.function.AbstractFunction
import org.apache.commons.lang.StringUtils

abstract class CommonFunction extends AbstractFunction {
  val DATA_SPLIT = "\t"

  def splitFun(line : String, split : String) : Array[String] = {
    if (split == null) {
      StringUtils.splitPreserveAllTokens(line, DATA_SPLIT, -1)
    } else {
      StringUtils.splitPreserveAllTokens(line, split, -1)
    }
  }

  def splitFun(line : String) : Array[String] = {
    splitFun(line, null)
  }
}