mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8037259: xerces update: xpointer update
Reviewed-by: lancea
This commit is contained in:
parent
7e0e645fa1
commit
ca3fd10341
@ -3,11 +3,12 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
@ -19,7 +20,7 @@
|
||||
*/
|
||||
package com.sun.org.apache.xerces.internal.xpointer;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
|
||||
import com.sun.org.apache.xerces.internal.util.SymbolTable;
|
||||
@ -38,9 +39,8 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
|
||||
* @xerces.internal
|
||||
*
|
||||
* @version $Id: ElementSchemePointer.java,v 1.4 2009/06/11 23:51:50 joehw Exp $
|
||||
*
|
||||
*/
|
||||
class ElementSchemePointer implements XPointerPart {
|
||||
final class ElementSchemePointer implements XPointerPart {
|
||||
|
||||
// Fields
|
||||
|
||||
@ -346,15 +346,17 @@ class ElementSchemePointer implements XPointerPart {
|
||||
|
||||
// Donot check for empty elements if the empty element is
|
||||
// a child of a found parent element
|
||||
//if (!fIsElementFound) {
|
||||
if (checkMatch()) {
|
||||
fIsElementFound = true;
|
||||
if (checkMatch()) {
|
||||
if (!fIsElementFound) {
|
||||
fWasOnlyEmptyElementFound = true;
|
||||
} else {
|
||||
fIsElementFound = false;
|
||||
fWasOnlyEmptyElementFound = false;
|
||||
}
|
||||
//}
|
||||
|
||||
fIsElementFound = true;
|
||||
} else {
|
||||
fIsElementFound = false;
|
||||
fWasOnlyEmptyElementFound = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -526,7 +528,7 @@ class ElementSchemePointer implements XPointerPart {
|
||||
|
||||
private SymbolTable fSymbolTable;
|
||||
|
||||
private Hashtable fTokenNames = new Hashtable();
|
||||
private HashMap<Integer, String> fTokenNames = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -548,16 +550,7 @@ class ElementSchemePointer implements XPointerPart {
|
||||
* @return String The token string
|
||||
*/
|
||||
private String getTokenString(int token) {
|
||||
return (String) fTokenNames.get(new Integer(token));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the token String
|
||||
* @param token The index of the token
|
||||
* @return String The token string
|
||||
*/
|
||||
private Integer getToken(int token) {
|
||||
return (Integer) fTokenNames.get(new Integer(token));
|
||||
return fTokenNames.get(new Integer(token));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -566,12 +559,11 @@ class ElementSchemePointer implements XPointerPart {
|
||||
* @param token The token string
|
||||
*/
|
||||
private void addToken(String tokenStr) {
|
||||
Integer tokenInt = (Integer) fTokenNames.get(tokenStr);
|
||||
if (tokenInt == null) {
|
||||
tokenInt = new Integer(fTokenNames.size());
|
||||
if (!fTokenNames.containsValue(tokenStr)) {
|
||||
Integer tokenInt = new Integer(fTokenNames.size());
|
||||
fTokenNames.put(tokenInt, tokenStr);
|
||||
addToken(tokenInt.intValue());
|
||||
}
|
||||
addToken(tokenInt.intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -3,11 +3,12 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
@ -17,6 +18,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xerces.internal.xpointer;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.impl.Constants;
|
||||
@ -37,9 +39,8 @@ import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
|
||||
* in document order that has a matching NCName as an identifier.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
*/
|
||||
class ShortHandPointer implements XPointerPart {
|
||||
final class ShortHandPointer implements XPointerPart {
|
||||
|
||||
// The name of the ShortHand pointer
|
||||
private String fShortHandPointer;
|
||||
@ -261,7 +262,7 @@ class ShortHandPointer implements XPointerPart {
|
||||
* @see com.sun.org.apache.xerces.internal.xpointer.XPointerPart#isChildFragmentResolved()
|
||||
*/
|
||||
public boolean isChildFragmentResolved() {
|
||||
return fIsFragmentResolved & ( fMatchingChildCount > 0);
|
||||
return fIsFragmentResolved && ( fMatchingChildCount > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -3,11 +3,12 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
@ -17,6 +18,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xerces.internal.xpointer;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
@ -31,7 +33,7 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
|
||||
* implementation and reported as resource errors.
|
||||
*
|
||||
*/
|
||||
class XPointerErrorHandler implements XMLErrorHandler {
|
||||
final class XPointerErrorHandler implements XMLErrorHandler {
|
||||
|
||||
//
|
||||
// Data
|
||||
|
||||
@ -3,11 +3,12 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
@ -17,10 +18,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xerces.internal.xpointer;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.impl.Constants;
|
||||
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
|
||||
@ -32,6 +34,7 @@ import com.sun.org.apache.xerces.internal.xinclude.XIncludeNamespaceSupport;
|
||||
import com.sun.org.apache.xerces.internal.xni.Augmentations;
|
||||
import com.sun.org.apache.xerces.internal.xni.QName;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLString;
|
||||
import com.sun.org.apache.xerces.internal.xni.XNIException;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
|
||||
@ -64,8 +67,8 @@ public final class XPointerHandler extends XIncludeHandler implements
|
||||
XPointerProcessor {
|
||||
|
||||
// Fields
|
||||
// A Vector of XPointerParts
|
||||
protected Vector fXPointerParts = null;
|
||||
// An ArrayList of XPointerParts
|
||||
protected ArrayList<XPointerPart> fXPointerParts = null;
|
||||
|
||||
// The current XPointerPart
|
||||
protected XPointerPart fXPointerPart = null;
|
||||
@ -102,7 +105,7 @@ public final class XPointerHandler extends XIncludeHandler implements
|
||||
public XPointerHandler() {
|
||||
super();
|
||||
|
||||
fXPointerParts = new Vector();
|
||||
fXPointerParts = new ArrayList<>();
|
||||
fSymbolTable = new SymbolTable();
|
||||
}
|
||||
|
||||
@ -110,13 +113,17 @@ public final class XPointerHandler extends XIncludeHandler implements
|
||||
XMLErrorHandler errorHandler, XMLErrorReporter errorReporter) {
|
||||
super();
|
||||
|
||||
fXPointerParts = new Vector();
|
||||
fXPointerParts = new ArrayList<>();
|
||||
fSymbolTable = symbolTable;
|
||||
fErrorHandler = errorHandler;
|
||||
fXPointerErrorReporter = errorReporter;
|
||||
//fErrorReporter = errorReporter; // The XInclude ErrorReporter
|
||||
}
|
||||
|
||||
public void setDocumentHandler(XMLDocumentHandler handler) {
|
||||
fDocumentHandler = handler;
|
||||
}
|
||||
|
||||
// ************************************************************************
|
||||
// Implementation of the XPointerProcessor interface.
|
||||
// ************************************************************************
|
||||
@ -300,7 +307,7 @@ public final class XPointerHandler extends XIncludeHandler implements
|
||||
// in the XPointer expression until a matching element is found.
|
||||
for (int i = 0; i < fXPointerParts.size(); i++) {
|
||||
|
||||
fXPointerPart = (XPointerPart) fXPointerParts.get(i);
|
||||
fXPointerPart = fXPointerParts.get(i);
|
||||
|
||||
if (fXPointerPart.resolveXPointer(element, attributes, augs,
|
||||
event)) {
|
||||
@ -430,11 +437,11 @@ public final class XPointerHandler extends XIncludeHandler implements
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Vector of XPointerPart objects
|
||||
* Returns an ArrayList of XPointerPart objects
|
||||
*
|
||||
* @return A Vector of XPointerPart objects.
|
||||
* @return An ArrayList of XPointerPart objects.
|
||||
*/
|
||||
public Vector getPointerParts() {
|
||||
public ArrayList<XPointerPart> getPointerParts() {
|
||||
return fXPointerParts;
|
||||
}
|
||||
|
||||
@ -480,7 +487,7 @@ public final class XPointerHandler extends XIncludeHandler implements
|
||||
|
||||
private SymbolTable fSymbolTable;
|
||||
|
||||
private Hashtable fTokenNames = new Hashtable();
|
||||
private HashMap<Integer, String> fTokenNames = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -508,7 +515,7 @@ public final class XPointerHandler extends XIncludeHandler implements
|
||||
* @return String The token string
|
||||
*/
|
||||
private String getTokenString(int token) {
|
||||
return (String) fTokenNames.get(new Integer(token));
|
||||
return fTokenNames.get(new Integer(token));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -517,12 +524,11 @@ public final class XPointerHandler extends XIncludeHandler implements
|
||||
* @param token The token string
|
||||
*/
|
||||
private void addToken(String tokenStr) {
|
||||
Integer tokenInt = (Integer) fTokenNames.get(tokenStr);
|
||||
if (tokenInt == null) {
|
||||
tokenInt = new Integer(fTokenNames.size());
|
||||
if (!fTokenNames.containsValue(tokenStr)) {
|
||||
Integer tokenInt = new Integer(fTokenNames.size());
|
||||
fTokenNames.put(tokenInt, tokenStr);
|
||||
addToken(tokenInt.intValue());
|
||||
}
|
||||
addToken(tokenInt.intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -3,11 +3,12 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
@ -17,6 +18,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xerces.internal.xpointer;
|
||||
|
||||
import java.util.Locale;
|
||||
@ -34,7 +36,7 @@ import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
|
||||
*
|
||||
* @version $Id: XPointerMessageFormatter.java,v 1.5 2010-11-01 04:40:26 joehw Exp $
|
||||
*/
|
||||
class XPointerMessageFormatter implements MessageFormatter {
|
||||
final class XPointerMessageFormatter implements MessageFormatter {
|
||||
|
||||
public static final String XPOINTER_DOMAIN = "http://www.w3.org/TR/XPTR";
|
||||
|
||||
|
||||
@ -3,11 +3,12 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
@ -17,6 +18,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xerces.internal.xpointer;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.xni.Augmentations;
|
||||
@ -49,7 +51,7 @@ public interface XPointerPart {
|
||||
* Provides scheme specific parsing of a XPointer expression i.e.
|
||||
* the PointerPart or ShortHandPointer.
|
||||
*
|
||||
* @param xpointer A String representing the PointerPart or ShortHandPointer.
|
||||
* @param part A String representing the PointerPart or ShortHandPointer.
|
||||
* @throws XNIException Thrown if the PointerPart string does not conform to
|
||||
* the syntax defined by its scheme.
|
||||
*
|
||||
|
||||
@ -3,11 +3,12 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
@ -34,7 +35,6 @@ import com.sun.org.apache.xerces.internal.xni.XNIException;
|
||||
*
|
||||
* @xerces.internal
|
||||
*
|
||||
*
|
||||
*/
|
||||
public interface XPointerProcessor {
|
||||
|
||||
@ -56,7 +56,6 @@ public interface XPointerProcessor {
|
||||
* @throws XNIException Thrown if the xpointer string does not conform to
|
||||
* the XPointer Framework syntax or the syntax of the pointer part does
|
||||
* not conform to its definition for its scheme.
|
||||
*
|
||||
*/
|
||||
public void parseXPointer(String xpointer) throws XNIException;
|
||||
|
||||
@ -74,7 +73,6 @@ public interface XPointerProcessor {
|
||||
* 2 - An empty element call
|
||||
* @return true if the element was resolved by the xpointer
|
||||
* @throws XNIException Thrown to signal an error
|
||||
*
|
||||
*/
|
||||
public boolean resolveXPointer(QName element, XMLAttributes attributes,
|
||||
Augmentations augs, int event) throws XNIException;
|
||||
@ -86,7 +84,6 @@ public interface XPointerProcessor {
|
||||
* @return True if the xpointer expression matches a node/fragment in the resource
|
||||
* else returns false.
|
||||
* @throws XNIException Thrown to signal an error
|
||||
*
|
||||
*/
|
||||
public boolean isFragmentResolved() throws XNIException;
|
||||
|
||||
@ -97,7 +94,6 @@ public interface XPointerProcessor {
|
||||
* @return True if the xpointer expression matches a fragment in the resource
|
||||
* else returns false.
|
||||
* @throws XNIException Thrown to signal an error
|
||||
*
|
||||
*/
|
||||
public boolean isXPointerResolved() throws XNIException;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user