def toChannelBuffer()

in storehaus-mysql/src/main/scala/com/twitter/storehaus/mysql/ValueMapper.scala [53:67]


  def toChannelBuffer(v: Value): Option[ChannelBuffer] = {
    v match {
      case IntValue(d) => Some(ChannelBuffers.copiedBuffer(d.toString, UTF_8))
      case LongValue(d) => Some(ChannelBuffers.copiedBuffer(d.toString, UTF_8))
      case RawValue(_, _, true, d) => Some(ChannelBuffers.copiedBuffer(d)) // from byte array
      case RawValue(_, _, false, d) => Some(ChannelBuffers.copiedBuffer(new String(d), UTF_8))
      case ShortValue(d) => Some(ChannelBuffers.copiedBuffer(d.toString, UTF_8))
      case StringValue(d) => Some(ChannelBuffers.copiedBuffer(d, UTF_8))
      case EmptyValue => Some(ChannelBuffers.EMPTY_BUFFER)
      case NullValue => None
      // all other types are currently unsupported
      case other => throw new UnsupportedOperationException(
        s"${v.getClass.getName} with value $other is currently not supported.")
    }
  }