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