constructingparser.scala

来自「JAVA 语言的函数式编程扩展」· SCALA 代码 · 共 68 行

SCALA
68
字号
/*                     __                                               *\**     ________ ___   / /  ___     Scala API                            ****    / __/ __// _ | / /  / _ |    (c) 2003-2006, LAMP/EPFL             ****  __\ \/ /__/ __ |/ /__/ __ |                                         **** /____/\___/_/ |_/____/_/ | |                                         ****                          |/                                          **\*                                                                      */// $Id: ConstructingParser.scala 8624 2006-09-08 09:33:07Z michelou $package scala.xml.parsingimport java.io.Fileimport scala.io.Sourceobject ConstructingParser {  def fromFile(inp: File, preserveWS: Boolean) = {    val p = new ConstructingParser(Source.fromFile(inp), preserveWS)    p.nextch    p  }  def fromSource(inp: Source, preserveWS: Boolean) = {    val p = new ConstructingParser(inp, preserveWS)    p.nextch    p  }}/** An xml parser. parses XML and invokes callback methods of a MarkupHandler. *  Don't forget to call next.ch on a freshly instantiated parser in order to *  initialize it. If you get the parser from the object method, initialization *  is already done for you. * *<pre>object parseFromURL {  def main(args:Array[String]): Unit = {    val url = args(0);    val src = scala.io.Source.fromURL(url);    val cpa = scala.xml.parsing.ConstructingParser.fromSource(src, false); // fromSource initializes automatically    val doc = cpa.document();    // let's see what it is    val ppr = new scala.xml.PrettyPrinter(80,5);    val ele = doc.docElem;    Console.println("finished parsing");    val out = ppr.format(ele);    Console.println(out);  }}</pre> */class ConstructingParser(inp: Source, presWS:Boolean)extends  ConstructingHandlerwith     ExternalSourceswith     MarkupParser  {  // default impl. of Logged  override def log(msg: String): Unit = {}  val preserveWS = presWS  val input = inp}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?