blob: b204466a15451c042cd77a1a844beecf6786a91f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.xml
/** an XML node for processing instructions (PI)
*
* @author Burak Emir
* @param target target name of this PI
* @param text text contained in this node, may not contain "?>"
*/
case class ProcInstr(target:String, proctext:String) extends SpecialNode {
if (!Utility.isName(target))
throw new IllegalArgumentException(target+" must be an XML Name")
else if (text.indexOf("?>") != -1)
throw new IllegalArgumentException(proctext+" may not contain \"?>\"")
final override def typeTag$: Int = -2
(target: Seq[Char]) match {
case Seq('X'|'x','M'|'m','L'|'l') =>
throw new IllegalArgumentException(target+" is reserved")
case _ =>
}
/** structural equality */
override def equals(x: Any): Boolean = x match {
case ProcInstr(x, y) => x.equals(target) && y.equals(proctext)
case _ => false
}
/** the constant "#PI" */
final def label = "#PI"
/** hashcode for this PI */
override def hashCode() = target.hashCode() * 7 + proctext.hashCode()
override def text = ""
/** appends "<?" target (" "+text)?+"?>"
* to this stringbuffer.
*/
override def toString(sb: StringBuilder) = {
sb
.append("<?")
.append(target);
if (proctext.length() > 0) {
sb
.append(' ')
.append(proctext);
}
sb.append("?>")
}
}
|