blob: 0469de448394e9e0886d24572b1f3a52ea648d17 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.xml.dtd;
import scala.runtime.compat.StringBuilder
/** an ExternalIDs - either PublicID or SystemID
*
* @author Burak Emir
* @param target target name of this PI
* @param text text contained in this node, may not contain "?>"
**/
abstract class ExternalID {
/** returns "PUBLIC "+publicLiteral+" SYSTEM "+systemLiteral */
override def toString(): String;
/** returns "PUBLIC "+publicLiteral+" SYSTEM "+systemLiteral */
def toString(sb: StringBuilder): StringBuilder;
def systemId: String;
}
/** a system identifier
*
* @author Burak Emir
* @param systemLiteral the system identifier literal
**/
case class SystemID( systemId:String ) extends ExternalID with parsing.TokenTests{
if( !checkSysID( systemId ) )
throw new IllegalArgumentException(
"can't use both \" and ' in systemLiteral"
);
/** returns " SYSTEM "+systemLiteral */
final override def toString() =
Utility.systemLiteralToString( systemId );
final def toString(sb: StringBuilder): StringBuilder =
Utility.systemLiteralToString( sb, systemId );
}
/** a public identifier
*
* @author Burak Emir
* @param publicLiteral the public identifier literal
* @param systemLiteral (can be null for notation pubIDs) the system identifier literal
**/
case class PublicID( publicId:String, systemId:String ) extends ExternalID with parsing.TokenTests{
//Console.println("constructing PublicID \""+publicLiteral+"\" "+systemLiteral);
//Console.println("util returns "+checkPubID( publicLiteral ));
if( !checkPubID( publicId ))
throw new IllegalArgumentException(
"publicId must consist of PubidChars"
);
if( systemId != null && !checkSysID( systemId ) )
throw new IllegalArgumentException(
"can't use both \" and ' in systemId"
);
/** the constant "#PI" */
final def label = "#PI";
/** always empty */
final def attribute = Node.NoAttributes;
/** always empty */
final def child = Nil;
/** returns "PUBLIC "+publicId+" SYSTEM "+systemId */
final override def toString(): String = {
toString(new StringBuilder()).toString();
}
/** appends "PUBLIC "+publicId+" SYSTEM "+systemId to argument */
final def toString(sb: StringBuilder): StringBuilder = {
Utility.publicLiteralToString( sb, publicId ).append(' ');
if(systemId!=null)
Utility.systemLiteralToString( sb, systemId );
else
sb
}
}
|