All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ujson.CharSequenceParser.scala Maven / Gradle / Ivy

package ujson

import upickle.core.{ObjArrVisitor, Visitor}
/**
 * Lazy character sequence parsing.
 *
 * This is similar to StringParser, but acts on character sequences.
 */
private[ujson] final class CharSequenceParser[J](cs: CharSequence) extends CharParser[J]{
  override def growBuffer(until: Int): Unit = ()
  def readDataIntoBuffer(buffer: Array[Char], bufferOffset: Int) = {
    if(buffer == null) (cs.toString.toCharArray, cs.length == 0, cs.length)
    else (buffer, true, -1)
  }
  final def close() = ()
}

object CharSequenceParser extends Transformer[CharSequence]{
  def transform[T](j: CharSequence, f: Visitor[_, T]) = new CharSequenceParser(j).parse(f)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy