8013900: More warnings compiling jaxp

Some internal implementation classes in Jaxp were redefining equals() without redefining hashCode(). This patch adds hashCode() methods that are consistent with equals().

Reviewed-by: chegar, joehw
This commit is contained in:
Daniel Fuchs 2013-05-17 10:40:21 +02:00
parent 8620b1e2d7
commit 98c17c258e
18 changed files with 1496 additions and 974 deletions

View File

@ -97,8 +97,14 @@ public final class BasicType extends Type {
/** @return true if both type objects refer to the same type
*/
@Override
public boolean equals(Object type) {
return (type instanceof BasicType)?
((BasicType)type).type == this.type : false;
}
@Override
public int hashCode() {
return type;
}
}

View File

@ -93,6 +93,7 @@ public abstract class BranchInstruction extends Instruction implements Instructi
* Dump instruction as byte code to stream out.
* @param out Output stream
*/
@Override
public void dump(DataOutputStream out) throws IOException {
out.writeByte(opcode);
@ -153,6 +154,7 @@ public abstract class BranchInstruction extends Instruction implements Instructi
* @param verbose long/short format switch
* @return mnemonic for instruction
*/
@Override
public String toString(boolean verbose) {
String s = super.toString(verbose);
String t = "null";
@ -184,6 +186,7 @@ public abstract class BranchInstruction extends Instruction implements Instructi
* @param wide wide prefix?
* @see InstructionList
*/
@Override
protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
{
length = 3;
@ -204,26 +207,41 @@ public abstract class BranchInstruction extends Instruction implements Instructi
* Set branch target
* @param target branch target
*/
public void setTarget(InstructionHandle target) {
notifyTarget(this.target, target, this);
public final void setTarget(InstructionHandle target) {
notifyTargetChanging(this.target, this);
this.target = target;
notifyTargetChanged(this.target, this);
}
/**
* Used by BranchInstruction, LocalVariableGen, CodeExceptionGen
* Used by BranchInstruction, LocalVariableGen, CodeExceptionGen.
* Must be called before the target is actually changed in the
* InstructionTargeter.
*/
static final void notifyTarget(InstructionHandle old_ih, InstructionHandle new_ih,
static void notifyTargetChanging(InstructionHandle old_ih,
InstructionTargeter t) {
if(old_ih != null)
if(old_ih != null) {
old_ih.removeTargeter(t);
if(new_ih != null)
}
}
/**
* Used by BranchInstruction, LocalVariableGen, CodeExceptionGen.
* Must be called after the target is actually changed in the
* InstructionTargeter.
*/
static void notifyTargetChanged(InstructionHandle new_ih,
InstructionTargeter t) {
if(new_ih != null) {
new_ih.addTargeter(t);
}
}
/**
* @param old_ih old target
* @param new_ih new target
*/
@Override
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
if(target == old_ih)
setTarget(new_ih);
@ -234,6 +252,7 @@ public abstract class BranchInstruction extends Instruction implements Instructi
/**
* @return true, if ih is target of this instruction
*/
@Override
public boolean containsTarget(InstructionHandle ih) {
return (target == ih);
}
@ -241,6 +260,7 @@ public abstract class BranchInstruction extends Instruction implements Instructi
/**
* Inform target that it's not targeted anymore.
*/
@Override
void dispose() {
setTarget(null);
index=-1;

View File

@ -58,7 +58,6 @@ package com.sun.org.apache.bcel.internal.generic;
* <http://www.apache.org/>.
*/
import com.sun.org.apache.bcel.internal.Constants;
import com.sun.org.apache.bcel.internal.classfile.*;
/**
@ -118,31 +117,35 @@ public final class CodeExceptionGen
/* Set start of handler
* @param start_pc Start of handled region (inclusive)
*/
public void setStartPC(InstructionHandle start_pc) {
BranchInstruction.notifyTarget(this.start_pc, start_pc, this);
public final void setStartPC(InstructionHandle start_pc) {
BranchInstruction.notifyTargetChanging(this.start_pc, this);
this.start_pc = start_pc;
BranchInstruction.notifyTargetChanged(this.start_pc, this);
}
/* Set end of handler
* @param end_pc End of handled region (inclusive)
*/
public void setEndPC(InstructionHandle end_pc) {
BranchInstruction.notifyTarget(this.end_pc, end_pc, this);
public final void setEndPC(InstructionHandle end_pc) {
BranchInstruction.notifyTargetChanging(this.end_pc, this);
this.end_pc = end_pc;
BranchInstruction.notifyTargetChanged(this.end_pc, this);
}
/* Set handler code
* @param handler_pc Start of handler
*/
public void setHandlerPC(InstructionHandle handler_pc) {
BranchInstruction.notifyTarget(this.handler_pc, handler_pc, this);
public final void setHandlerPC(InstructionHandle handler_pc) {
BranchInstruction.notifyTargetChanging(this.handler_pc, this);
this.handler_pc = handler_pc;
BranchInstruction.notifyTargetChanged(this.handler_pc, this);
}
/**
* @param old_ih old target, either start or end
* @param new_ih new target
*/
@Override
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
boolean targeted = false;
@ -169,6 +172,7 @@ public final class CodeExceptionGen
/**
* @return true, if ih is target of this handler
*/
@Override
public boolean containsTarget(InstructionHandle ih) {
return (start_pc == ih) || (end_pc == ih) || (handler_pc == ih);
}
@ -190,10 +194,12 @@ public final class CodeExceptionGen
*/
public InstructionHandle getHandlerPC() { return handler_pc; }
@Override
public String toString() {
return "CodeExceptionGen(" + start_pc + ", " + end_pc + ", " + handler_pc + ")";
}
@Override
public Object clone() {
try {
return super.clone();

View File

@ -58,7 +58,6 @@ package com.sun.org.apache.bcel.internal.generic;
* <http://www.apache.org/>.
*/
import com.sun.org.apache.bcel.internal.Constants;
import com.sun.org.apache.bcel.internal.classfile.*;
/**
@ -88,6 +87,7 @@ public class LineNumberGen
/**
* @return true, if ih is target of this line number
*/
@Override
public boolean containsTarget(InstructionHandle ih) {
return this.ih == ih;
}
@ -96,6 +96,7 @@ public class LineNumberGen
* @param old_ih old target
* @param new_ih new target
*/
@Override
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
if(old_ih != ih)
throw new ClassGenException("Not targeting " + old_ih + ", but " + ih + "}");
@ -113,12 +114,13 @@ public class LineNumberGen
return new LineNumber(ih.getPosition(), src_line);
}
public void setInstruction(InstructionHandle ih) {
BranchInstruction.notifyTarget(this.ih, ih, this);
public final void setInstruction(InstructionHandle ih) {
BranchInstruction.notifyTargetChanging(this.ih, this);
this.ih = ih;
BranchInstruction.notifyTargetChanged(this.ih, this);
}
@Override
public Object clone() {
try {
return super.clone();

View File

@ -60,6 +60,7 @@ package com.sun.org.apache.bcel.internal.generic;
import com.sun.org.apache.bcel.internal.Constants;
import com.sun.org.apache.bcel.internal.classfile.*;
import java.util.Objects;
/**
* This class represents a local variable within a method. It contains its
@ -75,7 +76,7 @@ public class LocalVariableGen
implements InstructionTargeter, NamedAndTyped, Cloneable,
java.io.Serializable
{
private int index;
private final int index;
private String name;
private Type type;
private InstructionHandle start, end;
@ -131,30 +132,96 @@ public class LocalVariableGen
signature_index, index, cp.getConstantPool());
}
public void setIndex(int index) { this.index = index; }
public int getIndex() { return index; }
public int getIndex() { return index; }
@Override
public void setName(String name) { this.name = name; }
@Override
public String getName() { return name; }
@Override
public void setType(Type type) { this.type = type; }
@Override
public Type getType() { return type; }
public InstructionHandle getStart() { return start; }
public InstructionHandle getEnd() { return end; }
public void setStart(InstructionHandle start) {
BranchInstruction.notifyTarget(this.start, start, this);
this.start = start;
/**
* Remove this from any known HashSet in which it might be registered.
*/
void notifyTargetChanging() {
// hashCode depends on 'index', 'start', and 'end'.
// Therefore before changing any of these values we
// need to unregister 'this' from any HashSet where
// this is registered, and then we need to add it
// back...
// Unregister 'this' from the HashSet held by 'start'.
BranchInstruction.notifyTargetChanging(this.start, this);
if (this.end != this.start) {
// Since hashCode() is going to change we need to unregister
// 'this' both form 'start' and 'end'.
// Unregister 'this' from the HashSet held by 'end'.
BranchInstruction.notifyTargetChanging(this.end, this);
}
}
public void setEnd(InstructionHandle end) {
BranchInstruction.notifyTarget(this.end, end, this);
/**
* Add back 'this' in all HashSet in which it should be registered.
**/
void notifyTargetChanged() {
// hashCode depends on 'index', 'start', and 'end'.
// Therefore before changing any of these values we
// need to unregister 'this' from any HashSet where
// this is registered, and then we need to add it
// back...
// Register 'this' in the HashSet held by start.
BranchInstruction.notifyTargetChanged(this.start, this);
if (this.end != this.start) {
// Since hashCode() has changed we need to register
// 'this' again in 'end'.
// Add back 'this' in the HashSet held by 'end'.
BranchInstruction.notifyTargetChanged(this.end, this);
}
}
public final void setStart(InstructionHandle start) {
// Call notifyTargetChanging *before* modifying this,
// as the code triggered by notifyTargetChanging
// depends on this pointing to the 'old' start.
notifyTargetChanging();
this.start = start;
// call notifyTargetChanged *after* modifying this,
// as the code triggered by notifyTargetChanged
// depends on this pointing to the 'new' start.
notifyTargetChanged();
}
public final void setEnd(InstructionHandle end) {
// call notifyTargetChanging *before* modifying this,
// as the code triggered by notifyTargetChanging
// depends on this pointing to the 'old' end.
// Unregister 'this' from the HashSet held by the 'old' end.
notifyTargetChanging();
this.end = end;
// call notifyTargetChanged *after* modifying this,
// as the code triggered by notifyTargetChanged
// depends on this pointing to the 'new' end.
// Register 'this' in the HashSet held by the 'new' end.
notifyTargetChanged();
}
/**
* @param old_ih old target, either start or end
* @param new_ih new target
*/
@Override
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
boolean targeted = false;
@ -176,15 +243,20 @@ public class LocalVariableGen
/**
* @return true, if ih is target of this variable
*/
@Override
public boolean containsTarget(InstructionHandle ih) {
return (start == ih) || (end == ih);
}
/**
* We consider to local variables to be equal, if the use the same index and
* We consider two local variables to be equal, if they use the same index and
* are valid in the same range.
*/
@Override
public boolean equals(Object o) {
if (o==this)
return true;
if(!(o instanceof LocalVariableGen))
return false;
@ -192,10 +264,21 @@ public class LocalVariableGen
return (l.index == index) && (l.start == start) && (l.end == end);
}
@Override
public int hashCode() {
int hash = 7;
hash = 59 * hash + this.index;
hash = 59 * hash + Objects.hashCode(this.start);
hash = 59 * hash + Objects.hashCode(this.end);
return hash;
}
@Override
public String toString() {
return "LocalVariableGen(" + name + ", " + type + ", " + start + ", " + end + ")";
}
@Override
public Object clone() {
try {
return super.clone();

View File

@ -58,7 +58,7 @@ package com.sun.org.apache.bcel.internal.generic;
* <http://www.apache.org/>.
*/
import com.sun.org.apache.bcel.internal.Constants;
import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
import java.util.Objects;
/**
* Returnaddress, the type JSR or JSR_W instructions push upon the stack.
@ -86,9 +86,15 @@ public class ReturnaddressType extends Type {
this.returnTarget = returnTarget;
}
@Override
public int hashCode() {
return Objects.hashCode(this.returnTarget);
}
/**
* Returns if the two Returnaddresses refer to the same target.
*/
@Override
public boolean equals(Object rat){
if(!(rat instanceof ReturnaddressType))
return false;

View File

@ -97,8 +97,9 @@ public abstract class Select extends BranchInstruction
super(opcode, target);
this.targets = targets;
for(int i=0; i < targets.length; i++)
notifyTarget(null, targets[i], this);
for(int i=0; i < targets.length; i++) {
BranchInstruction.notifyTargetChanged(targets[i], this);
}
this.match = match;
@ -121,6 +122,7 @@ public abstract class Select extends BranchInstruction
* @param max_offset the maximum offset that may be caused by these instructions
* @return additional offset caused by possible change of this instruction's length
*/
@Override
protected int updatePosition(int offset, int max_offset) {
position += offset; // Additional offset caused by preceding SWITCHs, GOTOs, etc.
@ -138,6 +140,7 @@ public abstract class Select extends BranchInstruction
* Dump instruction as byte code to stream out.
* @param out Output stream
*/
@Override
public void dump(DataOutputStream out) throws IOException {
out.writeByte(opcode);
@ -151,6 +154,7 @@ public abstract class Select extends BranchInstruction
/**
* Read needed data (e.g. index) from file.
*/
@Override
protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
{
padding = (4 - (bytes.getIndex() % 4)) % 4; // Compute number of pad bytes
@ -166,8 +170,9 @@ public abstract class Select extends BranchInstruction
/**
* @return mnemonic for instruction
*/
@Override
public String toString(boolean verbose) {
StringBuffer buf = new StringBuffer(super.toString(verbose));
final StringBuilder buf = new StringBuilder(super.toString(verbose));
if(verbose) {
for(int i=0; i < match_length; i++) {
@ -176,7 +181,8 @@ public abstract class Select extends BranchInstruction
if(targets[i] != null)
s = targets[i].getInstruction().toString();
buf.append("(" + match[i] + ", " + s + " = {" + indices[i] + "})");
buf.append("(").append(match[i]).append(", ")
.append(s).append(" = {").append(indices[i]).append("})");
}
}
else
@ -188,15 +194,17 @@ public abstract class Select extends BranchInstruction
/**
* Set branch target for `i'th case
*/
public void setTarget(int i, InstructionHandle target) {
notifyTarget(targets[i], target, this);
public final void setTarget(int i, InstructionHandle target) {
notifyTargetChanging(targets[i], this);
targets[i] = target;
notifyTargetChanged(targets[i], this);
}
/**
* @param old_ih old target
* @param new_ih new target
*/
@Override
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
boolean targeted = false;
@ -219,6 +227,7 @@ public abstract class Select extends BranchInstruction
/**
* @return true, if ih is target of this instruction
*/
@Override
public boolean containsTarget(InstructionHandle ih) {
if(target == ih)
return true;
@ -233,6 +242,7 @@ public abstract class Select extends BranchInstruction
/**
* Inform targets that they're not targeted anymore.
*/
@Override
void dispose() {
super.dispose();

View File

@ -54,6 +54,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import java.util.Objects;
/**
* @author Jacek Ambroziak
@ -156,8 +157,15 @@ class FunctionCall extends Expression {
this.type = type;
this.distance = distance;
}
@Override
public int hashCode() {
return Objects.hashCode(this.type);
}
@Override
public boolean equals(Object query){
return query.equals(type);
return query != null && query.equals(type);
}
}
@ -277,6 +285,7 @@ class FunctionCall extends Expression {
return(_fname.toString());
}
@Override
public void setParser(Parser parser) {
super.setParser(parser);
if (_arguments != null) {
@ -319,6 +328,7 @@ class FunctionCall extends Expression {
* Type check a function call. Since different type conversions apply,
* type checking is different for standard and external (Java) functions.
*/
@Override
public Type typeCheck(SymbolTable stable)
throws TypeCheckError
{
@ -680,6 +690,7 @@ class FunctionCall extends Expression {
* Compile the function call and treat as an expression
* Update true/false-lists.
*/
@Override
public void translateDesynthesized(ClassGenerator classGen,
MethodGenerator methodGen)
{
@ -700,6 +711,7 @@ class FunctionCall extends Expression {
* Translate a function call. The compiled code will leave the function's
* return value on the JVM's stack.
*/
@Override
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final int n = argumentCount();
final ConstantPoolGen cpg = classGen.getConstantPool();
@ -857,6 +869,7 @@ class FunctionCall extends Expression {
}
}
@Override
public String toString() {
return "funcall(" + _fname + ", " + _arguments + ')';
}
@ -1069,7 +1082,7 @@ class FunctionCall extends Expression {
protected static String replaceDash(String name)
{
char dash = '-';
StringBuffer buff = new StringBuffer("");
final StringBuilder buff = new StringBuilder("");
for (int i = 0; i < name.length(); i++) {
if (i > 0 && name.charAt(i-1) == dash)
buff.append(Character.toUpperCase(name.charAt(i)));

View File

@ -25,6 +25,7 @@ package com.sun.org.apache.xalan.internal.xsltc.compiler;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
import java.util.Objects;
/**
* @author Morten Jorgensen
@ -97,13 +98,15 @@ class VariableRefBase extends Expression {
* Two variable references are deemed equal if they refer to the
* same variable.
*/
@Override
public boolean equals(Object obj) {
try {
return (_variable == ((VariableRefBase) obj)._variable);
}
catch (ClassCastException e) {
return false;
}
return obj == this || (obj instanceof VariableRefBase)
&& (_variable == ((VariableRefBase) obj)._variable);
}
@Override
public int hashCode() {
return Objects.hashCode(this._variable);
}
/**
@ -111,10 +114,12 @@ class VariableRefBase extends Expression {
* format 'variable-ref(<var-name>)'.
* @return Variable reference description
*/
@Override
public String toString() {
return "variable-ref("+_variable.getName()+'/'+_variable.getType()+')';
}
@Override
public Type typeCheck(SymbolTable stable)
throws TypeCheckError
{

View File

@ -26,6 +26,7 @@ import java.math.BigInteger;
import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext;
import com.sun.org.apache.xerces.internal.xs.datatypes.XSDecimal;
import java.util.Objects;
/**
* Represent the schema type "decimal"
@ -38,10 +39,12 @@ import com.sun.org.apache.xerces.internal.xs.datatypes.XSDecimal;
*/
public class DecimalDV extends TypeValidator {
@Override
public final short getAllowedFacets(){
return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE | XSSimpleTypeDecl.FACET_MINEXCLUSIVE | XSSimpleTypeDecl.FACET_TOTALDIGITS | XSSimpleTypeDecl.FACET_FRACTIONDIGITS);
}
@Override
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
try {
return new XDecimal(content);
@ -50,20 +53,23 @@ public class DecimalDV extends TypeValidator {
}
}
@Override
public final int compare(Object value1, Object value2){
return ((XDecimal)value1).compareTo((XDecimal)value2);
}
@Override
public final int getTotalDigits(Object value){
return ((XDecimal)value).totalDigits;
}
@Override
public final int getFractionDigits(Object value){
return ((XDecimal)value).fracDigits;
}
// Avoid using the heavy-weight java.math.BigDecimal
static class XDecimal implements XSDecimal {
static final class XDecimal implements XSDecimal {
// sign: 0 for vlaue 0; 1 for positive values; -1 for negative values
int sign = 1;
// total digits. >= 1
@ -216,6 +222,8 @@ public class DecimalDV extends TypeValidator {
integer = true;
}
@Override
public boolean equals(Object val) {
if (val == this)
return true;
@ -232,6 +240,19 @@ public class DecimalDV extends TypeValidator {
return intDigits == oval.intDigits && fracDigits == oval.fracDigits &&
ivalue.equals(oval.ivalue) && fvalue.equals(oval.fvalue);
}
@Override
public int hashCode() {
int hash = 7;
hash = 17 * hash + this.sign;
if (this.sign == 0) return hash;
hash = 17 * hash + this.intDigits;
hash = 17 * hash + this.fracDigits;
hash = 17 * hash + Objects.hashCode(this.ivalue);
hash = 17 * hash + Objects.hashCode(this.fvalue);
return hash;
}
public int compareTo(XDecimal val) {
if (sign != val.sign)
return sign > val.sign ? 1 : -1;
@ -248,7 +269,9 @@ public class DecimalDV extends TypeValidator {
ret = fvalue.compareTo(val.fvalue);
return ret == 0 ? 0 : (ret > 0 ? 1 : -1);
}
private String canonical;
@Override
public synchronized String toString() {
if (canonical == null) {
makeCanonical();
@ -269,7 +292,7 @@ public class DecimalDV extends TypeValidator {
return;
}
// for -0.1, total digits is 1, so we need 3 extra spots
StringBuffer buffer = new StringBuffer(totalDigits+3);
final StringBuilder buffer = new StringBuilder(totalDigits+3);
if (sign == -1)
buffer.append('-');
if (intDigits != 0)
@ -288,6 +311,7 @@ public class DecimalDV extends TypeValidator {
canonical = buffer.toString();
}
@Override
public BigDecimal getBigDecimal() {
if (sign == 0) {
return new BigDecimal(BigInteger.ZERO);
@ -295,6 +319,7 @@ public class DecimalDV extends TypeValidator {
return new BigDecimal(toString());
}
@Override
public BigInteger getBigInteger() throws NumberFormatException {
if (fracDigits != 0) {
throw new NumberFormatException();
@ -308,6 +333,7 @@ public class DecimalDV extends TypeValidator {
return new BigInteger("-" + ivalue);
}
@Override
public long getLong() throws NumberFormatException {
if (fracDigits != 0) {
throw new NumberFormatException();
@ -321,6 +347,7 @@ public class DecimalDV extends TypeValidator {
return Long.parseLong("-" + ivalue);
}
@Override
public int getInt() throws NumberFormatException {
if (fracDigits != 0) {
throw new NumberFormatException();
@ -334,6 +361,7 @@ public class DecimalDV extends TypeValidator {
return Integer.parseInt("-" + ivalue);
}
@Override
public short getShort() throws NumberFormatException {
if (fracDigits != 0) {
throw new NumberFormatException();
@ -347,6 +375,7 @@ public class DecimalDV extends TypeValidator {
return Short.parseShort("-" + ivalue);
}
@Override
public byte getByte() throws NumberFormatException {
if (fracDigits != 0) {
throw new NumberFormatException();

View File

@ -32,7 +32,7 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext;
*/
class PrecisionDecimalDV extends TypeValidator {
static class XPrecisionDecimal {
static final class XPrecisionDecimal {
// sign: 0 for absent; 1 for positive values; -1 for negative values (except in case of INF, -INF)
int sign = 1;
@ -144,7 +144,71 @@ class PrecisionDecimalDV extends TypeValidator {
totalDigits = intDigits + fracDigits;
}
// Construct a canonical String representation of this number
// for the purpose of deriving a hashCode value compliant with
// equals.
// The toString representation will be:
// NaN for NaN, INF for +infinity, -INF for -infinity, 0 for zero,
// and [1-9].[0-9]*[1-9]?(E[1-9][0-9]*)? for other numbers.
private static String canonicalToStringForHashCode(String ivalue, String fvalue, int sign, int pvalue) {
if ("NaN".equals(ivalue)) {
return "NaN";
}
if ("INF".equals(ivalue)) {
return sign < 0 ? "-INF" : "INF";
}
final StringBuilder builder = new StringBuilder();
final int ilen = ivalue.length();
final int flen0 = fvalue.length();
int lastNonZero;
for (lastNonZero = flen0; lastNonZero > 0 ; lastNonZero--) {
if (fvalue.charAt(lastNonZero -1 ) != '0') break;
}
final int flen = lastNonZero;
int iStart;
int exponent = pvalue;
for (iStart = 0; iStart < ilen; iStart++) {
if (ivalue.charAt(iStart) != '0') break;
}
int fStart = 0;
if (iStart < ivalue.length()) {
builder.append(sign == -1 ? "-" : "");
builder.append(ivalue.charAt(iStart));
iStart++;
} else {
if (flen > 0) {
for (fStart = 0; fStart < flen; fStart++) {
if (fvalue.charAt(fStart) != '0') break;
}
if (fStart < flen) {
builder.append(sign == -1 ? "-" : "");
builder.append(fvalue.charAt(fStart));
exponent -= ++fStart;
} else {
return "0";
}
} else {
return "0";
}
}
if (iStart < ilen || fStart < flen) {
builder.append('.');
}
while (iStart < ilen) {
builder.append(ivalue.charAt(iStart++));
exponent++;
}
while (fStart < flen) {
builder.append(fvalue.charAt(fStart++));
}
if (exponent != 0) {
builder.append("E").append(exponent);
}
return builder.toString();
}
@Override
public boolean equals(Object val) {
if (val == this)
return true;
@ -156,6 +220,20 @@ class PrecisionDecimalDV extends TypeValidator {
return this.compareTo(oval) == EQUAL;
}
@Override
public int hashCode() {
// There's nothing else we can use easily, because equals could
// return true for widely different representation of the
// same number - and we don't have any canonical representation.
// The problem here is that we must ensure that if two numbers
// are equals then their hash code must also be equals.
// hashCode for 1.01E1 should be the same as hashCode for 0.101E2
// So we call cannonicalToStringForHashCode - which implements an
// algorithm that invents a normalized string representation
// for this number, and we return a hash for that.
return canonicalToStringForHashCode(ivalue, fvalue, sign, pvalue).hashCode();
}
/**
* @return
*/
@ -295,6 +373,7 @@ class PrecisionDecimalDV extends TypeValidator {
private String canonical;
@Override
public synchronized String toString() {
if (canonical == null) {
makeCanonical();
@ -325,6 +404,7 @@ class PrecisionDecimalDV extends TypeValidator {
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator#getAllowedFacets()
*/
@Override
public short getAllowedFacets() {
return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE | XSSimpleTypeDecl.FACET_MINEXCLUSIVE | XSSimpleTypeDecl.FACET_TOTALDIGITS | XSSimpleTypeDecl.FACET_FRACTIONDIGITS);
}
@ -332,6 +412,7 @@ class PrecisionDecimalDV extends TypeValidator {
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator#getActualValue(java.lang.String, com.sun.org.apache.xerces.internal.impl.dv.ValidationContext)
*/
@Override
public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException {
try {
@ -341,18 +422,22 @@ class PrecisionDecimalDV extends TypeValidator {
}
}
@Override
public int compare(Object value1, Object value2) {
return ((XPrecisionDecimal)value1).compareTo((XPrecisionDecimal)value2);
}
@Override
public int getFractionDigits(Object value) {
return ((XPrecisionDecimal)value).fracDigits;
}
@Override
public int getTotalDigits(Object value) {
return ((XPrecisionDecimal)value).totalDigits;
}
@Override
public boolean isIdentical(Object value1, Object value2) {
if(!(value2 instanceof XPrecisionDecimal) || !(value1 instanceof XPrecisionDecimal))
return false;

View File

@ -22,6 +22,7 @@ package com.sun.org.apache.xerces.internal.util;
import java.io.IOException;
import java.io.Serializable;
import java.util.Objects;
/**********************************************************************
* A class to represent a Uniform Resource Identifier (URI). This class
@ -1212,7 +1213,7 @@ import java.io.Serializable;
* @return the scheme-specific part for this URI
*/
public String getSchemeSpecificPart() {
StringBuffer schemespec = new StringBuffer();
final StringBuilder schemespec = new StringBuilder();
if (m_host != null || m_regAuthority != null) {
schemespec.append("//");
@ -1297,7 +1298,7 @@ import java.io.Serializable;
* @return the authority
*/
public String getAuthority() {
StringBuffer authority = new StringBuffer();
final StringBuilder authority = new StringBuilder();
if (m_host != null || m_regAuthority != null) {
authority.append("//");
@ -1340,7 +1341,7 @@ import java.io.Serializable;
*/
public String getPath(boolean p_includeQueryString,
boolean p_includeFragment) {
StringBuffer pathString = new StringBuffer(m_path);
final StringBuilder pathString = new StringBuilder(m_path);
if (p_includeQueryString && m_queryString != null) {
pathString.append('?');
@ -1683,6 +1684,7 @@ import java.io.Serializable;
* @return true if p_test is a URI with all values equal to this
* URI, false otherwise
*/
@Override
public boolean equals(Object p_test) {
if (p_test instanceof URI) {
URI testURI = (URI) p_test;
@ -1711,13 +1713,27 @@ import java.io.Serializable;
return false;
}
@Override
public int hashCode() {
int hash = 5;
hash = 47 * hash + Objects.hashCode(this.m_scheme);
hash = 47 * hash + Objects.hashCode(this.m_userinfo);
hash = 47 * hash + Objects.hashCode(this.m_host);
hash = 47 * hash + this.m_port;
hash = 47 * hash + Objects.hashCode(this.m_path);
hash = 47 * hash + Objects.hashCode(this.m_queryString);
hash = 47 * hash + Objects.hashCode(this.m_fragment);
return hash;
}
/**
* Get the URI as a string specification. See RFC 2396 Section 5.2.
*
* @return the URI string specification
*/
@Override
public String toString() {
StringBuffer uriSpecString = new StringBuffer();
final StringBuilder uriSpecString = new StringBuilder();
if (m_scheme != null) {
uriSpecString.append(m_scheme);

View File

@ -68,6 +68,7 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration;
import com.sun.org.apache.xerces.internal.xpointer.XPointerHandler;
import com.sun.org.apache.xerces.internal.xpointer.XPointerProcessor;
import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
import java.util.Objects;
/**
* <p>
@ -390,6 +391,7 @@ public class XIncludeHandler
// XMLComponent methods
@Override
public void reset(XMLComponentManager componentManager)
throws XNIException {
fNamespaceContext = null;
@ -597,6 +599,7 @@ public class XIncludeHandler
* this component. This method may return null if no features
* are recognized by this component.
*/
@Override
public String[] getRecognizedFeatures() {
return (String[])(RECOGNIZED_FEATURES.clone());
} // getRecognizedFeatures():String[]
@ -616,6 +619,7 @@ public class XIncludeHandler
* @throws SAXNotSupportedException The component should not throw
* this exception.
*/
@Override
public void setFeature(String featureId, boolean state)
throws XMLConfigurationException {
if (featureId.equals(ALLOW_UE_AND_NOTATION_EVENTS)) {
@ -632,6 +636,7 @@ public class XIncludeHandler
* this component. This method may return null if no properties
* are recognized by this component.
*/
@Override
public String[] getRecognizedProperties() {
return (String[])(RECOGNIZED_PROPERTIES.clone());
} // getRecognizedProperties():String[]
@ -651,6 +656,7 @@ public class XIncludeHandler
* @throws SAXNotSupportedException The component should not throw
* this exception.
*/
@Override
public void setProperty(String propertyId, Object value)
throws XMLConfigurationException {
if (propertyId.equals(SYMBOL_TABLE)) {
@ -719,6 +725,7 @@ public class XIncludeHandler
*
* @since Xerces 2.2.0
*/
@Override
public Boolean getFeatureDefault(String featureId) {
for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
if (RECOGNIZED_FEATURES[i].equals(featureId)) {
@ -737,6 +744,7 @@ public class XIncludeHandler
*
* @since Xerces 2.2.0
*/
@Override
public Object getPropertyDefault(String propertyId) {
for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {
@ -746,10 +754,12 @@ public class XIncludeHandler
return null;
} // getPropertyDefault(String):Object
@Override
public void setDocumentHandler(XMLDocumentHandler handler) {
fDocumentHandler = handler;
}
@Override
public XMLDocumentHandler getDocumentHandler() {
return fDocumentHandler;
}
@ -764,6 +774,7 @@ public class XIncludeHandler
*
* This event is only passed on to the document handler if this is the root document.
*/
@Override
public void startDocument(
XMLLocator locator,
String encoding,
@ -811,6 +822,7 @@ public class XIncludeHandler
}
}
@Override
public void xmlDecl(
String version,
String encoding,
@ -823,6 +835,7 @@ public class XIncludeHandler
}
}
@Override
public void doctypeDecl(
String rootElement,
String publicId,
@ -834,6 +847,7 @@ public class XIncludeHandler
}
}
@Override
public void comment(XMLString text, Augmentations augs)
throws XNIException {
if (!fInDTD) {
@ -850,6 +864,7 @@ public class XIncludeHandler
}
}
@Override
public void processingInstruction(
String target,
XMLString data,
@ -870,6 +885,7 @@ public class XIncludeHandler
}
}
@Override
public void startElement(
QName element,
XMLAttributes attributes,
@ -940,6 +956,7 @@ public class XIncludeHandler
}
}
@Override
public void emptyElement(
QName element,
XMLAttributes attributes,
@ -1021,6 +1038,7 @@ public class XIncludeHandler
fDepth--;
}
@Override
public void endElement(QName element, Augmentations augs)
throws XNIException {
@ -1066,6 +1084,7 @@ public class XIncludeHandler
fDepth--;
}
@Override
public void startGeneralEntity(
String name,
XMLResourceIdentifier resId,
@ -1084,6 +1103,7 @@ public class XIncludeHandler
}
}
@Override
public void textDecl(String version, String encoding, Augmentations augs)
throws XNIException {
if (fDocumentHandler != null
@ -1092,6 +1112,7 @@ public class XIncludeHandler
}
}
@Override
public void endGeneralEntity(String name, Augmentations augs)
throws XNIException {
if (fDocumentHandler != null
@ -1101,6 +1122,7 @@ public class XIncludeHandler
}
}
@Override
public void characters(XMLString text, Augmentations augs)
throws XNIException {
if (getState() == STATE_NORMAL_PROCESSING) {
@ -1117,6 +1139,7 @@ public class XIncludeHandler
}
}
@Override
public void ignorableWhitespace(XMLString text, Augmentations augs)
throws XNIException {
if (fDocumentHandler != null
@ -1126,6 +1149,7 @@ public class XIncludeHandler
}
}
@Override
public void startCDATA(Augmentations augs) throws XNIException {
if (fDocumentHandler != null
&& getState() == STATE_NORMAL_PROCESSING
@ -1134,6 +1158,7 @@ public class XIncludeHandler
}
}
@Override
public void endCDATA(Augmentations augs) throws XNIException {
if (fDocumentHandler != null
&& getState() == STATE_NORMAL_PROCESSING
@ -1142,6 +1167,7 @@ public class XIncludeHandler
}
}
@Override
public void endDocument(Augmentations augs) throws XNIException {
if (isRootDocument()) {
if (!fSeenRootElement) {
@ -1153,10 +1179,12 @@ public class XIncludeHandler
}
}
@Override
public void setDocumentSource(XMLDocumentSource source) {
fDocumentSource = source;
}
@Override
public XMLDocumentSource getDocumentSource() {
return fDocumentSource;
}
@ -1168,6 +1196,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String[], java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void attributeDecl(
String elementName,
String attributeName,
@ -1194,6 +1223,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#elementDecl(java.lang.String, java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void elementDecl(
String name,
String contentModel,
@ -1207,6 +1237,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endAttlist(com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void endAttlist(Augmentations augmentations) throws XNIException {
if (fDTDHandler != null) {
fDTDHandler.endAttlist(augmentations);
@ -1216,6 +1247,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endConditional(com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void endConditional(Augmentations augmentations)
throws XNIException {
if (fDTDHandler != null) {
@ -1226,6 +1258,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endDTD(com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void endDTD(Augmentations augmentations) throws XNIException {
if (fDTDHandler != null) {
fDTDHandler.endDTD(augmentations);
@ -1236,6 +1269,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endExternalSubset(com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void endExternalSubset(Augmentations augmentations)
throws XNIException {
if (fDTDHandler != null) {
@ -1246,6 +1280,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endParameterEntity(java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void endParameterEntity(String name, Augmentations augmentations)
throws XNIException {
if (fDTDHandler != null) {
@ -1256,6 +1291,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#externalEntityDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void externalEntityDecl(
String name,
XMLResourceIdentifier identifier,
@ -1269,6 +1305,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#getDTDSource()
*/
@Override
public XMLDTDSource getDTDSource() {
return fDTDSource;
}
@ -1276,6 +1313,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#ignoredCharacters(com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void ignoredCharacters(XMLString text, Augmentations augmentations)
throws XNIException {
if (fDTDHandler != null) {
@ -1286,6 +1324,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#internalEntityDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void internalEntityDecl(
String name,
XMLString text,
@ -1304,6 +1343,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#notationDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void notationDecl(
String name,
XMLResourceIdentifier identifier,
@ -1318,6 +1358,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#setDTDSource(com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource)
*/
@Override
public void setDTDSource(XMLDTDSource source) {
fDTDSource = source;
}
@ -1325,6 +1366,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startAttlist(java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void startAttlist(String elementName, Augmentations augmentations)
throws XNIException {
if (fDTDHandler != null) {
@ -1335,6 +1377,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startConditional(short, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void startConditional(short type, Augmentations augmentations)
throws XNIException {
if (fDTDHandler != null) {
@ -1345,6 +1388,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startDTD(com.sun.org.apache.xerces.internal.xni.XMLLocator, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void startDTD(XMLLocator locator, Augmentations augmentations)
throws XNIException {
fInDTD = true;
@ -1356,6 +1400,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startExternalSubset(com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void startExternalSubset(
XMLResourceIdentifier identifier,
Augmentations augmentations)
@ -1368,6 +1413,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startParameterEntity(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void startParameterEntity(
String name,
XMLResourceIdentifier identifier,
@ -1386,6 +1432,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#unparsedEntityDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
@Override
public void unparsedEntityDecl(
String name,
XMLResourceIdentifier identifier,
@ -1405,6 +1452,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource#getDTDHandler()
*/
@Override
public XMLDTDHandler getDTDHandler() {
return fDTDHandler;
}
@ -1412,6 +1460,7 @@ public class XIncludeHandler
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource#setDTDHandler(com.sun.org.apache.xerces.internal.xni.XMLDTDHandler)
*/
@Override
public void setDTDHandler(XMLDTDHandler handler) {
fDTDHandler = handler;
}
@ -1641,11 +1690,10 @@ public class XIncludeHandler
fNamespaceContext);
((XPointerHandler)fXPtrProcessor).setProperty(XINCLUDE_FIXUP_BASE_URIS,
new Boolean(fFixupBaseURIs));
fFixupBaseURIs);
((XPointerHandler)fXPtrProcessor).setProperty(
XINCLUDE_FIXUP_LANGUAGE,
new Boolean (fFixupLanguage));
XINCLUDE_FIXUP_LANGUAGE, fFixupLanguage);
if (fErrorReporter != null)
((XPointerHandler)fXPtrProcessor).setProperty(ERROR_REPORTER, fErrorReporter);
@ -2119,14 +2167,14 @@ public class XIncludeHandler
/** Check whether the scheme components are equal. */
final String baseScheme = base.getScheme();
final String literalScheme = uri.getScheme();
if (!isEqual(baseScheme, literalScheme)) {
if (!Objects.equals(baseScheme, literalScheme)) {
return relativeURI;
}
/** Check whether the authority components are equal. */
final String baseAuthority = base.getAuthority();
final String literalAuthority = uri.getAuthority();
if (!isEqual(baseAuthority, literalAuthority)) {
if (!Objects.equals(baseAuthority, literalAuthority)) {
return uri.getSchemeSpecificPart();
}
@ -2139,7 +2187,7 @@ public class XIncludeHandler
final String literalQuery = uri.getQueryString();
final String literalFragment = uri.getFragment();
if (literalQuery != null || literalFragment != null) {
StringBuffer buffer = new StringBuffer();
final StringBuilder buffer = new StringBuilder();
if (literalPath != null) {
buffer.append(literalPath);
}
@ -2650,15 +2698,15 @@ public class XIncludeHandler
// equals() returns true if two Notations have the same name.
// Useful for searching Vectors for notations with the same name
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj instanceof Notation) {
Notation other = (Notation)obj;
return name.equals(other.name);
}
return false;
return obj == this || obj instanceof Notation
&& Objects.equals(name, ((Notation)obj).name);
}
@Override
public int hashCode() {
return Objects.hashCode(name);
}
// from 4.5.2
@ -2671,16 +2719,12 @@ public class XIncludeHandler
public boolean isDuplicate(Object obj) {
if (obj != null && obj instanceof Notation) {
Notation other = (Notation)obj;
return name.equals(other.name)
&& isEqual(publicId, other.publicId)
&& isEqual(expandedSystemId, other.expandedSystemId);
return Objects.equals(name, other.name)
&& Objects.equals(publicId, other.publicId)
&& Objects.equals(expandedSystemId, other.expandedSystemId);
}
return false;
}
private boolean isEqual(String one, String two) {
return (one == two || (one != null && one.equals(two)));
}
}
// This is a storage class to hold information about the unparsed entities.
@ -2696,15 +2740,15 @@ public class XIncludeHandler
// equals() returns true if two UnparsedEntities have the same name.
// Useful for searching Vectors for entities with the same name
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj instanceof UnparsedEntity) {
UnparsedEntity other = (UnparsedEntity)obj;
return name.equals(other.name);
}
return false;
return obj == this || obj instanceof UnparsedEntity
&& Objects.equals(name, ((UnparsedEntity)obj).name);
}
@Override
public int hashCode() {
return Objects.hashCode(name);
}
// from 4.5.1:
@ -2717,17 +2761,13 @@ public class XIncludeHandler
public boolean isDuplicate(Object obj) {
if (obj != null && obj instanceof UnparsedEntity) {
UnparsedEntity other = (UnparsedEntity)obj;
return name.equals(other.name)
&& isEqual(publicId, other.publicId)
&& isEqual(expandedSystemId, other.expandedSystemId)
&& isEqual(notation, other.notation);
return Objects.equals(name, other.name)
&& Objects.equals(publicId, other.publicId)
&& Objects.equals(expandedSystemId, other.expandedSystemId)
&& Objects.equals(notation, other.notation);
}
return false;
}
private boolean isEqual(String one, String two) {
return (one == two || (one != null && one.equals(two)));
}
}
// The following methods are used for XML Base processing
@ -2917,17 +2957,13 @@ public class XIncludeHandler
return httpSource;
}
private boolean isEqual(String one, String two) {
return (one == two || (one != null && one.equals(two)));
}
// which ASCII characters need to be escaped
private static boolean gNeedEscaping[] = new boolean[128];
private static final boolean gNeedEscaping[] = new boolean[128];
// the first hex character if a character needs to be escaped
private static char gAfterEscaping1[] = new char[128];
private static final char gAfterEscaping1[] = new char[128];
// the second hex character if a character needs to be escaped
private static char gAfterEscaping2[] = new char[128];
private static char[] gHexChs = {'0', '1', '2', '3', '4', '5', '6', '7',
private static final char gAfterEscaping2[] = new char[128];
private static final char[] gHexChs = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
// initialize the above 3 arrays
static {
@ -2957,7 +2993,7 @@ public class XIncludeHandler
private String escapeHref(String href) {
int len = href.length();
int ch;
StringBuffer buffer = new StringBuffer(len*3);
final StringBuilder buffer = new StringBuilder(len*3);
// for each character in the href
int i = 0;

View File

@ -27,6 +27,7 @@ import java.util.Vector;
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xml.internal.dtm.DTMDOMException;
import com.sun.org.apache.xpath.internal.NodeSet;
import java.util.Objects;
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
@ -141,21 +142,21 @@ public class DTMNodeProxy
*
* @return true if the given node has the same handle as this node.
*/
@Override
public final boolean equals(Object node)
{
try
{
// DTMNodeProxy dtmp = (DTMNodeProxy)node;
// return (dtmp.node == this.node);
// Patch attributed to Gary L Peskin <garyp@firstech.com>
return equals((Node) node);
}
catch (ClassCastException cce)
{
return false;
}
return node instanceof Node && equals((Node) node);
}
@Override
public int hashCode() {
int hash = 7;
hash = 29 * hash + Objects.hashCode(this.dtm);
hash = 29 * hash + this.node;
return hash;
}
/**
@ -181,6 +182,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node
*/
@Override
public final String getNodeName()
{
return dtm.getNodeName(node);
@ -199,6 +201,7 @@ public class DTMNodeProxy
*
*
*/
@Override
public final String getTarget()
{
return dtm.getNodeName(node);
@ -209,6 +212,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node as of DOM Level 2
*/
@Override
public final String getLocalName()
{
return dtm.getLocalName(node);
@ -218,6 +222,7 @@ public class DTMNodeProxy
* @return The prefix for this node.
* @see org.w3c.dom.Node as of DOM Level 2
*/
@Override
public final String getPrefix()
{
return dtm.getPrefix(node);
@ -230,6 +235,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Node as of DOM Level 2 -- DTMNodeProxy is read-only
*/
@Override
public final void setPrefix(String prefix) throws DOMException
{
throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
@ -240,6 +246,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node as of DOM Level 2
*/
@Override
public final String getNamespaceURI()
{
return dtm.getNamespaceURI(node);
@ -277,6 +284,7 @@ public class DTMNodeProxy
* @return false
* @see org.w3c.dom.Node as of DOM Level 2
*/
@Override
public final boolean isSupported(String feature, String version)
{
return implementation.hasFeature(feature,version);
@ -290,6 +298,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Node
*/
@Override
public final String getNodeValue() throws DOMException
{
return dtm.getNodeValue(node);
@ -312,6 +321,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Node -- DTMNodeProxy is read-only
*/
@Override
public final void setNodeValue(String nodeValue) throws DOMException
{
throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
@ -322,6 +332,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node
*/
@Override
public final short getNodeType()
{
return (short) dtm.getNodeType(node);
@ -332,6 +343,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node
*/
@Override
public final Node getParentNode()
{
@ -361,6 +373,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node
*/
@Override
public final NodeList getChildNodes()
{
@ -377,6 +390,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node
*/
@Override
public final Node getFirstChild()
{
@ -390,6 +404,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node
*/
@Override
public final Node getLastChild()
{
@ -403,6 +418,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node
*/
@Override
public final Node getPreviousSibling()
{
@ -416,6 +432,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node
*/
@Override
public final Node getNextSibling()
{
@ -435,6 +452,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node
*/
@Override
public final NamedNodeMap getAttributes()
{
@ -448,6 +466,7 @@ public class DTMNodeProxy
* @param name
*
*/
@Override
public boolean hasAttribute(String name)
{
return DTM.NULL != dtm.getAttributeNode(node,null,name);
@ -462,6 +481,7 @@ public class DTMNodeProxy
*
*
*/
@Override
public boolean hasAttributeNS(String namespaceURI, String localName)
{
return DTM.NULL != dtm.getAttributeNode(node,namespaceURI,localName);
@ -472,6 +492,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node
*/
@Override
public final Document getOwnerDocument()
{
// Note that this uses the DOM-compatable version of the call
@ -488,6 +509,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Node -- DTMNodeProxy is read-only
*/
@Override
public final Node insertBefore(Node newChild, Node refChild)
throws DOMException
{
@ -504,6 +526,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Node -- DTMNodeProxy is read-only
*/
@Override
public final Node replaceChild(Node newChild, Node oldChild)
throws DOMException
{
@ -519,6 +542,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Node -- DTMNodeProxy is read-only
*/
@Override
public final Node removeChild(Node oldChild) throws DOMException
{
throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
@ -533,6 +557,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Node -- DTMNodeProxy is read-only
*/
@Override
public final Node appendChild(Node newChild) throws DOMException
{
throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
@ -543,6 +568,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node
*/
@Override
public final boolean hasChildNodes()
{
return (DTM.NULL != dtm.getFirstChild(node));
@ -555,6 +581,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Node -- DTMNodeProxy is read-only
*/
@Override
public final Node cloneNode(boolean deep)
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -565,6 +592,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Document
*/
@Override
public final DocumentType getDoctype()
{
return null;
@ -575,6 +603,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Document
*/
@Override
public final DOMImplementation getImplementation()
{
return implementation;
@ -587,6 +616,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Document
*/
@Override
public final Element getDocumentElement()
{
int dochandle=dtm.getDocument();
@ -634,6 +664,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Document
*/
@Override
public final Element createElement(String tagName) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -644,6 +675,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Document
*/
@Override
public final DocumentFragment createDocumentFragment()
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -656,6 +688,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Document
*/
@Override
public final Text createTextNode(String data)
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -668,6 +701,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Document
*/
@Override
public final Comment createComment(String data)
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -682,6 +716,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Document
*/
@Override
public final CDATASection createCDATASection(String data)
throws DOMException
{
@ -698,8 +733,9 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Document
*/
@Override
public final ProcessingInstruction createProcessingInstruction(
String target, String data) throws DOMException
String target, String data) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
}
@ -713,6 +749,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Document
*/
@Override
public final Attr createAttribute(String name) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -727,6 +764,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Document
*/
@Override
public final EntityReference createEntityReference(String name)
throws DOMException
{
@ -739,6 +777,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Document
*/
@Override
public final NodeList getElementsByTagName(String tagname)
{
Vector listVector = new Vector();
@ -819,6 +858,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Document as of DOM Level 2 -- DTMNodeProxy is read-only
*/
@Override
public final Node importNode(Node importedNode, boolean deep)
throws DOMException
{
@ -835,8 +875,9 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Document as of DOM Level 2
*/
@Override
public final Element createElementNS(
String namespaceURI, String qualifiedName) throws DOMException
String namespaceURI, String qualifiedName) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
}
@ -851,8 +892,9 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Document as of DOM Level 2
*/
@Override
public final Attr createAttributeNS(
String namespaceURI, String qualifiedName) throws DOMException
String namespaceURI, String qualifiedName) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
}
@ -865,6 +907,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Document as of DOM Level 2
*/
@Override
public final NodeList getElementsByTagNameNS(String namespaceURI,
String localName)
{
@ -952,6 +995,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Document as of DOM Level 2
*/
@Override
public final Element getElementById(String elementId)
{
return (Element) dtm.getNode(dtm.getElementById(elementId));
@ -966,6 +1010,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Text
*/
@Override
public final Text splitText(int offset) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -978,6 +1023,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.CharacterData
*/
@Override
public final String getData() throws DOMException
{
return dtm.getNodeValue(node);
@ -990,6 +1036,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.CharacterData
*/
@Override
public final void setData(String data) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1000,6 +1047,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.CharacterData
*/
@Override
public final int getLength()
{
// %OPT% This should do something smarter?
@ -1016,6 +1064,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.CharacterData
*/
@Override
public final String substringData(int offset, int count) throws DOMException
{
return getData().substring(offset,offset+count);
@ -1028,6 +1077,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.CharacterData
*/
@Override
public final void appendData(String arg) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1041,6 +1091,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.CharacterData
*/
@Override
public final void insertData(int offset, String arg) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1054,6 +1105,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.CharacterData
*/
@Override
public final void deleteData(int offset, int count) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1068,6 +1120,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.CharacterData
*/
@Override
public final void replaceData(int offset, int count, String arg)
throws DOMException
{
@ -1079,6 +1132,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Element
*/
@Override
public final String getTagName()
{
return dtm.getNodeName(node);
@ -1091,12 +1145,13 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Element
*/
@Override
public final String getAttribute(String name)
{
DTMNamedNodeMap map = new DTMNamedNodeMap(dtm, node);
Node node = map.getNamedItem(name);
return (null == node) ? EMPTYSTRING : node.getNodeValue(); }
Node n = map.getNamedItem(name);
return (null == n) ? EMPTYSTRING : n.getNodeValue();
}
/**
*
@ -1106,6 +1161,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Element
*/
@Override
public final void setAttribute(String name, String value)
throws DOMException
{
@ -1119,6 +1175,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Element
*/
@Override
public final void removeAttribute(String name) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1131,9 +1188,9 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Element
*/
@Override
public final Attr getAttributeNode(String name)
{
DTMNamedNodeMap map = new DTMNamedNodeMap(dtm, node);
return (Attr)map.getNamedItem(name);
}
@ -1147,6 +1204,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Element
*/
@Override
public final Attr setAttributeNode(Attr newAttr) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1161,6 +1219,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Element
*/
@Override
public final Attr removeAttributeNode(Attr oldAttr) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1171,12 +1230,14 @@ public class DTMNodeProxy
*
*
*/
@Override
public boolean hasAttributes()
{
return DTM.NULL != dtm.getFirstAttribute(node);
}
/** @see org.w3c.dom.Element */
@Override
public final void normalize()
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1190,6 +1251,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Element
*/
@Override
public final String getAttributeNS(String namespaceURI, String localName)
{
Node retNode = null;
@ -1208,6 +1270,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Element
*/
@Override
public final void setAttributeNS(
String namespaceURI, String qualifiedName, String value)
throws DOMException
@ -1223,6 +1286,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Element
*/
@Override
public final void removeAttributeNS(String namespaceURI, String localName)
throws DOMException
{
@ -1237,6 +1301,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Element
*/
@Override
public final Attr getAttributeNodeNS(String namespaceURI, String localName)
{
Attr retAttr = null;
@ -1256,6 +1321,7 @@ public class DTMNodeProxy
* @throws DOMException
* @see org.w3c.dom.Element
*/
@Override
public final Attr setAttributeNodeNS(Attr newAttr) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1266,6 +1332,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Attr
*/
@Override
public final String getName()
{
return dtm.getNodeName(node);
@ -1276,6 +1343,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Attr
*/
@Override
public final boolean getSpecified()
{
// We really don't know which attributes might have come from the
@ -1290,6 +1358,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Attr
*/
@Override
public final String getValue()
{
return dtm.getNodeValue(node);
@ -1300,6 +1369,7 @@ public class DTMNodeProxy
* @param value
* @see org.w3c.dom.Attr
*/
@Override
public final void setValue(String value)
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1311,6 +1381,7 @@ public class DTMNodeProxy
*
* @see org.w3c.dom.Attr as of DOM Level 2
*/
@Override
public final Element getOwnerElement()
{
if (getNodeType() != Node.ATTRIBUTE_NODE)
@ -1331,9 +1402,9 @@ public class DTMNodeProxy
*
* @throws DOMException
*/
@Override
public Node adoptNode(Node source) throws DOMException
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
}
@ -1348,9 +1419,9 @@ public class DTMNodeProxy
*
* NEEDSDOC ($objectName$) @return
*/
@Override
public String getInputEncoding()
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
}
@ -1383,7 +1454,6 @@ public class DTMNodeProxy
*/
public boolean getStandalone()
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
}
@ -1418,9 +1488,9 @@ public class DTMNodeProxy
*
* NEEDSDOC ($objectName$) @return
*/
@Override
public boolean getStrictErrorChecking()
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
}
@ -1439,6 +1509,7 @@ public class DTMNodeProxy
*
* NEEDSDOC @param strictErrorChecking
*/
@Override
public void setStrictErrorChecking(boolean strictErrorChecking)
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1457,7 +1528,6 @@ public class DTMNodeProxy
*/
public String getVersion()
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
}
@ -1482,10 +1552,12 @@ public class DTMNodeProxy
*/
static class DTMNodeProxyImplementation implements DOMImplementation
{
@Override
public DocumentType createDocumentType(String qualifiedName,String publicId, String systemId)
{
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
}
@Override
public Document createDocument(String namespaceURI,String qualfiedName,DocumentType doctype)
{
// Could create a DTM... but why, when it'd have to be permanantly empty?
@ -1500,6 +1572,7 @@ public class DTMNodeProxy
* methods we can't support. I'm not sure which would be more useful
* to the caller.
*/
@Override
public boolean hasFeature(String feature,String version)
{
if( ("CORE".equals(feature.toUpperCase()) || "XML".equals(feature.toUpperCase()))
@ -1530,6 +1603,7 @@ public class DTMNodeProxy
* childNodes, etc.
* @since DOM Level 3
*/
@Override
public Object getFeature(String feature, String version) {
// we don't have any alternate node, either this node does the job
// or we don't have anything that does
@ -1542,6 +1616,7 @@ public class DTMNodeProxy
//RAMESH : Pending proper implementation of DOM Level 3
@Override
public Object setUserData(String key,
Object data,
UserDataHandler handler) {
@ -1557,6 +1632,7 @@ public class DTMNodeProxy
* on this node, or <code>null</code> if there was none.
* @since DOM Level 3
*/
@Override
public Object getUserData(String key) {
return getOwnerDocument().getUserData( key);
}
@ -1581,6 +1657,7 @@ public class DTMNodeProxy
* childNodes, etc.
* @since DOM Level 3
*/
@Override
public Object getFeature(String feature, String version) {
// we don't have any alternate node, either this node does the job
// or we don't have anything that does
@ -1629,6 +1706,7 @@ public class DTMNodeProxy
* <code>true</code> otherwise <code>false</code>.
* @since DOM Level 3
*/
@Override
public boolean isEqualNode(Node arg) {
if (arg == this) {
return true;
@ -1705,6 +1783,7 @@ public class DTMNodeProxy
* @return th URI for the namespace
* @since DOM Level 3
*/
@Override
public String lookupNamespaceURI(String specifiedPrefix) {
short type = this.getNodeType();
switch (type) {
@ -1797,6 +1876,7 @@ public class DTMNodeProxy
* is the default namespace, <code>false</code> otherwise.
* @since DOM Level 3
*/
@Override
public boolean isDefaultNamespace(String namespaceURI){
/*
// REVISIT: remove casts when DOM L3 becomes REC.
@ -1871,6 +1951,7 @@ public class DTMNodeProxy
* @param namespaceURI
* @return the prefix for the namespace
*/
@Override
public String lookupPrefix(String namespaceURI){
// REVISIT: When Namespaces 1.1 comes out this may not be true
@ -1932,6 +2013,7 @@ public class DTMNodeProxy
* <code>false</code> otherwise.
* @since DOM Level 3
*/
@Override
public boolean isSameNode(Node other) {
// we do not use any wrapper so the answer is obvious
return this == other;
@ -1980,8 +2062,9 @@ public class DTMNodeProxy
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
* fit in a <code>DOMString</code> variable on the implementation
* platform.
* @since DOM Level 3
* @since DOM Level 3
*/
@Override
public void setTextContent(String textContent)
throws DOMException {
setNodeValue(textContent);
@ -2031,6 +2114,7 @@ public class DTMNodeProxy
* platform.
* @since DOM Level 3
*/
@Override
public String getTextContent() throws DOMException {
return getNodeValue(); // overriden in some subclasses
}
@ -2043,6 +2127,7 @@ public class DTMNodeProxy
* node.
* @since DOM Level 3
*/
@Override
public short compareDocumentPosition(Node other) throws DOMException {
return 0;
}
@ -2071,14 +2156,16 @@ public class DTMNodeProxy
* Yes. (F2F 26 Sep 2001)
* @since DOM Level 3
*/
@Override
public String getBaseURI() {
return null;
}
/**
/**
* DOM Level 3
* Renaming node
*/
@Override
public Node renameNode(Node n,
String namespaceURI,
String name)
@ -2091,14 +2178,16 @@ public class DTMNodeProxy
* DOM Level 3
* Normalize document.
*/
@Override
public void normalizeDocument(){
}
/**
* The configuration used when <code>Document.normalizeDocument</code> is
* The configuration used when <code>Document.normalizeDocument</code> is
* invoked.
* @since DOM Level 3
*/
@Override
public DOMConfiguration getDomConfig(){
return null;
}
@ -2110,8 +2199,8 @@ public class DTMNodeProxy
/**
* DOM Level 3
*/
@Override
public void setDocumentURI(String documentURI){
fDocumentURI= documentURI;
}
@ -2123,6 +2212,7 @@ public class DTMNodeProxy
* over this attribute.
* @since DOM Level 3
*/
@Override
public String getDocumentURI(){
return fDocumentURI;
}
@ -2154,9 +2244,10 @@ public class DTMNodeProxy
actualEncoding = value;
}
/**
/**
* DOM Level 3
*/
@Override
public Text replaceWholeText(String content)
throws DOMException{
/*
@ -2210,6 +2301,7 @@ public class DTMNodeProxy
* nodes to this node, concatenated in document order.
* @since DOM Level 3
*/
@Override
public String getWholeText(){
/*
@ -2235,13 +2327,11 @@ public class DTMNodeProxy
* Returns whether this text node contains whitespace in element content,
* often abusively called "ignorable whitespace".
*/
@Override
public boolean isElementContentWhitespace(){
return false;
}
/**
* NON-DOM: set the type of this attribute to be ID type.
*
@ -2254,6 +2344,7 @@ public class DTMNodeProxy
/**
* DOM Level 3: register the given attribute node as an ID attribute
*/
@Override
public void setIdAttribute(String name, boolean makeId) {
//PENDING
}
@ -2262,6 +2353,7 @@ public class DTMNodeProxy
/**
* DOM Level 3: register the given attribute node as an ID attribute
*/
@Override
public void setIdAttributeNode(Attr at, boolean makeId) {
//PENDING
}
@ -2269,6 +2361,7 @@ public class DTMNodeProxy
/**
* DOM Level 3: register the given attribute node as an ID attribute
*/
@Override
public void setIdAttributeNS(String namespaceURI, String localName,
boolean makeId) {
//PENDING
@ -2277,16 +2370,19 @@ public class DTMNodeProxy
* Method getSchemaTypeInfo.
* @return TypeInfo
*/
@Override
public TypeInfo getSchemaTypeInfo(){
return null; //PENDING
}
@Override
public boolean isId() {
return false; //PENDING
}
private String xmlEncoding;
@Override
public String getXmlEncoding( ) {
return xmlEncoding;
}
@ -2295,23 +2391,25 @@ public class DTMNodeProxy
}
private boolean xmlStandalone;
@Override
public boolean getXmlStandalone() {
return xmlStandalone;
}
@Override
public void setXmlStandalone(boolean xmlStandalone) throws DOMException {
this.xmlStandalone = xmlStandalone;
}
private String xmlVersion;
@Override
public String getXmlVersion() {
return xmlVersion;
}
@Override
public void setXmlVersion(String xmlVersion) throws DOMException {
this.xmlVersion = xmlVersion;
}
}

View File

@ -23,7 +23,7 @@
package com.sun.org.apache.xml.internal.serializer.utils;
import java.io.IOException;
import java.io.Serializable;
import java.util.Objects;
/**
@ -863,7 +863,7 @@ final class URI
public String getSchemeSpecificPart()
{
StringBuffer schemespec = new StringBuffer();
final StringBuilder schemespec = new StringBuilder();
if (m_userinfo != null || m_host != null || m_port != -1)
{
@ -955,7 +955,7 @@ final class URI
boolean p_includeFragment)
{
StringBuffer pathString = new StringBuffer(m_path);
final StringBuilder pathString = new StringBuilder(m_path);
if (p_includeQueryString && m_queryString != null)
{
@ -1321,6 +1321,7 @@ final class URI
* @return true if p_test is a URI with all values equal to this
* URI, false otherwise
*/
@Override
public boolean equals(Object p_test)
{
@ -1343,15 +1344,29 @@ final class URI
return false;
}
@Override
public int hashCode() {
int hash = 5;
hash = 41 * hash + Objects.hashCode(this.m_scheme);
hash = 41 * hash + Objects.hashCode(this.m_userinfo);
hash = 41 * hash + Objects.hashCode(this.m_host);
hash = 41 * hash + this.m_port;
hash = 41 * hash + Objects.hashCode(this.m_path);
hash = 41 * hash + Objects.hashCode(this.m_queryString);
hash = 41 * hash + Objects.hashCode(this.m_fragment);
return hash;
}
/**
* Get the URI as a string specification. See RFC 2396 Section 5.2.
*
* @return the URI string specification
*/
@Override
public String toString()
{
StringBuffer uriSpecString = new StringBuffer();
final StringBuilder uriSpecString = new StringBuilder();
if (m_scheme != null)
{
@ -1543,7 +1558,7 @@ final class URI
*
*
* @param p_char the character to check
* @return true if the char is betweeen '0' and '9', 'a' and 'f'
* @return true if the char is between '0' and '9', 'a' and 'f'
* or 'A' and 'F', false otherwise
*/
private static boolean isHex(char p_char)

View File

@ -27,6 +27,7 @@ import java.io.Serializable;
import com.sun.org.apache.xml.internal.res.XMLErrorResources;
import com.sun.org.apache.xml.internal.res.XMLMessages;
import java.util.Objects;
/**
* A class to represent a Uniform Resource Identifier (URI). This class
@ -883,7 +884,7 @@ public class URI implements Serializable
public String getSchemeSpecificPart()
{
StringBuffer schemespec = new StringBuffer();
final StringBuilder schemespec = new StringBuilder();
if (m_userinfo != null || m_host != null || m_port != -1)
{
@ -975,7 +976,7 @@ public class URI implements Serializable
boolean p_includeFragment)
{
StringBuffer pathString = new StringBuffer(m_path);
final StringBuilder pathString = new StringBuilder(m_path);
if (p_includeQueryString && m_queryString != null)
{
@ -1341,6 +1342,7 @@ public class URI implements Serializable
* @return true if p_test is a URI with all values equal to this
* URI, false otherwise
*/
@Override
public boolean equals(Object p_test)
{
@ -1363,15 +1365,29 @@ public class URI implements Serializable
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = 59 * hash + Objects.hashCode(this.m_scheme);
hash = 59 * hash + Objects.hashCode(this.m_userinfo);
hash = 59 * hash + Objects.hashCode(this.m_host);
hash = 59 * hash + this.m_port;
hash = 59 * hash + Objects.hashCode(this.m_path);
hash = 59 * hash + Objects.hashCode(this.m_queryString);
hash = 59 * hash + Objects.hashCode(this.m_fragment);
return hash;
}
/**
* Get the URI as a string specification. See RFC 2396 Section 5.2.
*
* @return the URI string specification
*/
@Override
public String toString()
{
StringBuffer uriSpecString = new StringBuffer();
final StringBuilder uriSpecString = new StringBuilder();
if (m_scheme != null)
{

View File

@ -24,6 +24,7 @@ package com.sun.org.apache.xpath.internal;
import com.sun.org.apache.xml.internal.utils.QName;
import com.sun.org.apache.xpath.internal.objects.XObject;
import java.util.Objects;
/**
* This class holds an instance of an argument on
@ -182,7 +183,7 @@ public class Arg
{
m_qname = new QName("");
; // so that string compares can be done.
// so that string compares can be done.
m_val = null;
m_expression = null;
m_isVisible = true;
@ -223,6 +224,11 @@ public class Arg
m_expression = null;
}
@Override
public int hashCode() {
return Objects.hashCode(this.m_qname);
}
/**
* Equality function specialized for the variable name. If the argument
* is not a qname, it will deligate to the super class.
@ -231,6 +237,7 @@ public class Arg
* @return <code>true</code> if this object is the same as the obj
* argument; <code>false</code> otherwise.
*/
@Override
public boolean equals(Object obj)
{
if(obj instanceof QName)