3
3
* DO NOT REMOVE OR ALTER!
4
4
*/
5
5
/*
6
- * Copyright 2005 The Apache Software Foundation.
7
- *
8
- * Licensed under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License.
10
- * You may obtain a copy of the License at
6
+ * Licensed to the Apache Software Foundation (ASF) under one or more
7
+ * contributor license agreements. See the NOTICE file distributed with
8
+ * this work for additional information regarding copyright ownership.
9
+ * The ASF licenses this file to You under the Apache License, Version 2.0
10
+ * (the "License"); you may not use this file except in compliance with
11
+ * the License. You may obtain a copy of the License at
11
12
*
12
13
* http://www.apache.org/licenses/LICENSE-2.0
13
14
*
17
18
* See the License for the specific language governing permissions and
18
19
* limitations under the License.
19
20
*/
21
+
20
22
package com .sun .org .apache .xerces .internal .xpointer ;
21
23
22
- import java .util .Hashtable ;
23
- import java .util .Vector ;
24
+ import java .util .ArrayList ;
25
+ import java .util .HashMap ;
24
26
25
27
import com .sun .org .apache .xerces .internal .impl .Constants ;
26
28
import com .sun .org .apache .xerces .internal .impl .XMLErrorReporter ;
32
34
import com .sun .org .apache .xerces .internal .xni .Augmentations ;
33
35
import com .sun .org .apache .xerces .internal .xni .QName ;
34
36
import com .sun .org .apache .xerces .internal .xni .XMLAttributes ;
37
+ import com .sun .org .apache .xerces .internal .xni .XMLDocumentHandler ;
35
38
import com .sun .org .apache .xerces .internal .xni .XMLString ;
36
39
import com .sun .org .apache .xerces .internal .xni .XNIException ;
37
40
import com .sun .org .apache .xerces .internal .xni .parser .XMLConfigurationException ;
@@ -64,8 +67,8 @@ public final class XPointerHandler extends XIncludeHandler implements
64
67
XPointerProcessor {
65
68
66
69
// Fields
67
- // A Vector of XPointerParts
68
- protected Vector fXPointerParts = null ;
70
+ // An ArrayList of XPointerParts
71
+ protected ArrayList < XPointerPart > fXPointerParts = null ;
69
72
70
73
// The current XPointerPart
71
74
protected XPointerPart fXPointerPart = null ;
@@ -102,21 +105,25 @@ public final class XPointerHandler extends XIncludeHandler implements
102
105
public XPointerHandler () {
103
106
super ();
104
107
105
- fXPointerParts = new Vector ();
108
+ fXPointerParts = new ArrayList <> ();
106
109
fSymbolTable = new SymbolTable ();
107
110
}
108
111
109
112
public XPointerHandler (SymbolTable symbolTable ,
110
113
XMLErrorHandler errorHandler , XMLErrorReporter errorReporter ) {
111
114
super ();
112
115
113
- fXPointerParts = new Vector ();
116
+ fXPointerParts = new ArrayList <> ();
114
117
fSymbolTable = symbolTable ;
115
118
fErrorHandler = errorHandler ;
116
119
fXPointerErrorReporter = errorReporter ;
117
120
//fErrorReporter = errorReporter; // The XInclude ErrorReporter
118
121
}
119
122
123
+ public void setDocumentHandler (XMLDocumentHandler handler ) {
124
+ fDocumentHandler = handler ;
125
+ }
126
+
120
127
// ************************************************************************
121
128
// Implementation of the XPointerProcessor interface.
122
129
// ************************************************************************
@@ -300,7 +307,7 @@ public boolean resolveXPointer(QName element, XMLAttributes attributes,
300
307
// in the XPointer expression until a matching element is found.
301
308
for (int i = 0 ; i < fXPointerParts .size (); i ++) {
302
309
303
- fXPointerPart = ( XPointerPart ) fXPointerParts .get (i );
310
+ fXPointerPart = fXPointerParts .get (i );
304
311
305
312
if (fXPointerPart .resolveXPointer (element , attributes , augs ,
306
313
event )) {
@@ -430,11 +437,11 @@ protected void init() {
430
437
}
431
438
432
439
/**
433
- * Returns a Vector of XPointerPart objects
440
+ * Returns an ArrayList of XPointerPart objects
434
441
*
435
- * @return A Vector of XPointerPart objects.
442
+ * @return An ArrayList of XPointerPart objects.
436
443
*/
437
- public Vector getPointerParts () {
444
+ public ArrayList < XPointerPart > getPointerParts () {
438
445
return fXPointerParts ;
439
446
}
440
447
@@ -480,7 +487,7 @@ private final class Tokens {
480
487
481
488
private SymbolTable fSymbolTable ;
482
489
483
- private Hashtable fTokenNames = new Hashtable ();
490
+ private HashMap < Integer , String > fTokenNames = new HashMap <> ();
484
491
485
492
/**
486
493
* Constructor
@@ -508,7 +515,7 @@ private Tokens(SymbolTable symbolTable) {
508
515
* @return String The token string
509
516
*/
510
517
private String getTokenString (int token ) {
511
- return ( String ) fTokenNames .get (new Integer (token ));
518
+ return fTokenNames .get (new Integer (token ));
512
519
}
513
520
514
521
/**
@@ -517,12 +524,11 @@ private String getTokenString(int token) {
517
524
* @param token The token string
518
525
*/
519
526
private void addToken (String tokenStr ) {
520
- Integer tokenInt = (Integer ) fTokenNames .get (tokenStr );
521
- if (tokenInt == null ) {
522
- tokenInt = new Integer (fTokenNames .size ());
527
+ if (!fTokenNames .containsValue (tokenStr )) {
528
+ Integer tokenInt = new Integer (fTokenNames .size ());
523
529
fTokenNames .put (tokenInt , tokenStr );
530
+ addToken (tokenInt .intValue ());
524
531
}
525
- addToken (tokenInt .intValue ());
526
532
}
527
533
528
534
/**
0 commit comments