def copy()

in cassandra/src/main/scala/org/apache/zeppelin/cassandra/CqlFormatter.scala [138:196]


  def copy(outputFormat: String = this.outputFormat,
           floatPrecision: Int = this.floatPrecision,
           doublePrecision: Int = this.doublePrecision,
           decimalPrecision: Int = this.decimalPrecision,
           timestampFormat: String = this.timestampFormat,
           timeFormat: String = this.timeFormat,
           dateFormat: String = this.dateFormat,
           timeZoneId: String = this.timeZoneId,
           localeStr: String = this.localeStr) =
    new CqlFormatter(outputFormat, floatPrecision, doublePrecision, decimalPrecision,
      timestampFormat, timeFormat, dateFormat, timeZoneId, localeStr)

  def formatHuman(obj: Object): String = {
    if (obj == null) {
      "null"
    } else {
      obj match {
        case f: java.lang.Float =>
          floatFormatter match {
            case None => java.lang.Float.toString(f)
            case Some(fmt) => fmt.format(f)
          }
        case d: java.lang.Double =>
          doubleFormatter match {
            case None => java.lang.Double.toString(d)
            case Some(fmt) => fmt.format(d)
          }
        case dc: java.math.BigDecimal =>
          decimalFormatter match {
            case None => dc.toString
            case Some(fmt) => fmt.format(dc)
          }
        case m: java.util.Map[Object, Object] =>
          m.asScala.map{case(k,v) => formatHuman(k) + ": " + formatHuman(v)}.mkString("{", ", ", "}")
        case l: java.util.List[Object] =>
          l.asScala.map(x => formatHuman(x)).mkString("[", ", ", "]")
        case s: java.util.Set[Object] =>
          s.asScala.map(x => formatHuman(x)).mkString("{", ", ", "}")
        case t: Instant =>
            timestampFormatter.format(t.atZone(timeZone))
        case d: LocalDate =>
          dateFormatter.format(d)
        case t: LocalTime =>
          timeFormatter.format(t)
        case b: ByteBuffer =>
          "0x" + ByteBufUtil.hexDump(b.array())
        case i: InetAddress =>
          i.getHostAddress
        case t: TupleValue =>
          (0 until t.size()).map(i => formatHuman(t.getObject(i))).mkString("(", ", ", ")")
        case u: UdtValue =>
          val names = u.getType.getFieldNames
          (0 until u.size()).map(i => names.get(i).asInternal + ": " + formatHuman(u.getObject(i)))
            .mkString("{", ", ", "}")

        case _ => obj.toString
      }
    }
  }