summaryrefslogtreecommitdiff
path: root/src/library/scala/xml/Comment.scala
blob: 2f4ad96e9ea92af7af0f71bc8cb7a9ce54de5a1a (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
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2006, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |                                         **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

// $Id$


package scala.xml


import compat.StringBuilder

/** an XML node for comments.
 *
 * @author Burak Emir
 * @param text text contained in this node, may not contain "--"
 */

case class Comment(commentText: String) extends SpecialNode {

  final override def typeTag$:Int = -3

  if (commentText.indexOf("--") != -1)
    throw new IllegalArgumentException("text containts \"--\"")

  /** structural equality */
  override def equals(x: Any): Boolean = x match {
    case Comment(x) => x.equals(commentText)
    case _ => false
  }

  /** the constant "#REM" */
  def label = "#REM"

  /** hashcode for this Comment */
  override def hashCode() = commentText.hashCode()

  override def text = ""

  /** appends &quot;<!-- text -->&quot; to this stringbuffer */
  def toString(sb: StringBuilder) =
    sb.append("<!--").append(commentText).append("-->")
}