You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: shared/src/main/scala/scala/xml/parsing/FactoryAdapter.scala
+47-17
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,6 @@ package scala
10
10
packagexml
11
11
packageparsing
12
12
13
-
importscala.collection.{ mutable, Iterator }
14
13
importscala.collection.Seq
15
14
importorg.xml.sax.Attributes
16
15
importorg.xml.sax.helpers.DefaultHandler
@@ -40,10 +39,34 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node
40
39
varrootElem:Node=null
41
40
42
41
valbuffer=newStringBuilder()
43
-
valattribStack=new mutable.Stack[MetaData]
44
-
valhStack=new mutable.Stack[Node] // [ element ] contains siblings
45
-
valtagStack=new mutable.Stack[String]
46
-
varscopeStack=new mutable.Stack[NamespaceBinding]
42
+
/** List of attributes
43
+
*
44
+
* Previously was a mutable [[scala.collection.mutable.Stack Stack]], but is now a mutable reference to an immutable [[scala.collection.immutable.List List]].
45
+
*
46
+
* @since 1.1.0
47
+
*/
48
+
varattribStack=List.empty[MetaData]
49
+
/** List of elements
50
+
*
51
+
* Previously was a mutable [[scala.collection.mutable.Stack Stack]], but is now a mutable reference to an immutable [[scala.collection.immutable.List List]].
52
+
*
53
+
* @since 1.1.0
54
+
*/
55
+
varhStack=List.empty[Node] // [ element ] contains siblings
56
+
/** List of element names
57
+
*
58
+
* Previously was a mutable [[scala.collection.mutable.Stack Stack]], but is now a mutable reference to an immutable [[scala.collection.immutable.List List]].
59
+
*
60
+
* @since 1.1.0
61
+
*/
62
+
vartagStack=List.empty[String]
63
+
/** List of namespaces
64
+
*
65
+
* Previously was a mutable [[scala.collection.mutable.Stack Stack]], but is now a mutable reference to an immutable [[scala.collection.immutable.List List]].
66
+
*
67
+
* @since 1.1.0
68
+
*/
69
+
varscopeStack=List.empty[NamespaceBinding]
47
70
48
71
varcurTag:String=null
49
72
varcapture:Boolean=false
@@ -123,17 +146,17 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node
123
146
attributes: Attributes):Unit=
124
147
{
125
148
captureText()
126
-
tagStack push curTag
149
+
tagStack = curTag:: tagStack
127
150
curTag = qname
128
151
129
152
vallocalName= splitName(qname)._2
130
153
capture = nodeContainsText(localName)
131
154
132
-
hStack push null
155
+
hStack =null:: hStack
133
156
varm:MetaData=Null
134
157
varscpe:NamespaceBinding=
135
158
if (scopeStack.isEmpty) TopScope
136
-
else scopeStack.top
159
+
else scopeStack.head
137
160
138
161
for (i <-0 until attributes.getLength()) {
139
162
valqname= attributes getQName i
@@ -148,16 +171,16 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node
148
171
m =Attribute(Option(pre), key, Text(value), m)
149
172
}
150
173
151
-
scopeStack push scpe
152
-
attribStack push m
174
+
scopeStack = scpe:: scopeStack
175
+
attribStack = m :: attribStack
153
176
}
154
177
155
178
/**
156
179
* captures text, possibly normalizing whitespace
157
180
*/
158
181
defcaptureText():Unit= {
159
182
if (capture && buffer.length >0)
160
-
hStack push createText(buffer.toString)
183
+
hStack = createText(buffer.toString):: hStack
161
184
162
185
buffer.clear()
163
186
}
@@ -171,17 +194,24 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node
0 commit comments