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 /** @return true if both type objects refer to the same type
*/ */
@Override
public boolean equals(Object type) { public boolean equals(Object type) {
return (type instanceof BasicType)? return (type instanceof BasicType)?
((BasicType)type).type == this.type : false; ((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. * Dump instruction as byte code to stream out.
* @param out Output stream * @param out Output stream
*/ */
@Override
public void dump(DataOutputStream out) throws IOException { public void dump(DataOutputStream out) throws IOException {
out.writeByte(opcode); out.writeByte(opcode);
@ -153,6 +154,7 @@ public abstract class BranchInstruction extends Instruction implements Instructi
* @param verbose long/short format switch * @param verbose long/short format switch
* @return mnemonic for instruction * @return mnemonic for instruction
*/ */
@Override
public String toString(boolean verbose) { public String toString(boolean verbose) {
String s = super.toString(verbose); String s = super.toString(verbose);
String t = "null"; String t = "null";
@ -184,6 +186,7 @@ public abstract class BranchInstruction extends Instruction implements Instructi
* @param wide wide prefix? * @param wide wide prefix?
* @see InstructionList * @see InstructionList
*/ */
@Override
protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
{ {
length = 3; length = 3;
@ -204,26 +207,41 @@ public abstract class BranchInstruction extends Instruction implements Instructi
* Set branch target * Set branch target
* @param target branch target * @param target branch target
*/ */
public void setTarget(InstructionHandle target) { public final void setTarget(InstructionHandle target) {
notifyTarget(this.target, target, this); notifyTargetChanging(this.target, this);
this.target = target; 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) { InstructionTargeter t) {
if(old_ih != null) if(old_ih != null) {
old_ih.removeTargeter(t); 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); new_ih.addTargeter(t);
} }
}
/** /**
* @param old_ih old target * @param old_ih old target
* @param new_ih new target * @param new_ih new target
*/ */
@Override
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
if(target == old_ih) if(target == old_ih)
setTarget(new_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 * @return true, if ih is target of this instruction
*/ */
@Override
public boolean containsTarget(InstructionHandle ih) { public boolean containsTarget(InstructionHandle ih) {
return (target == ih); return (target == ih);
} }
@ -241,6 +260,7 @@ public abstract class BranchInstruction extends Instruction implements Instructi
/** /**
* Inform target that it's not targeted anymore. * Inform target that it's not targeted anymore.
*/ */
@Override
void dispose() { void dispose() {
setTarget(null); setTarget(null);
index=-1; index=-1;

View file

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

View file

@ -58,7 +58,6 @@ package com.sun.org.apache.bcel.internal.generic;
* <http://www.apache.org/>. * <http://www.apache.org/>.
*/ */
import com.sun.org.apache.bcel.internal.Constants;
import com.sun.org.apache.bcel.internal.classfile.*; 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 * @return true, if ih is target of this line number
*/ */
@Override
public boolean containsTarget(InstructionHandle ih) { public boolean containsTarget(InstructionHandle ih) {
return this.ih == ih; return this.ih == ih;
} }
@ -96,6 +96,7 @@ public class LineNumberGen
* @param old_ih old target * @param old_ih old target
* @param new_ih new target * @param new_ih new target
*/ */
@Override
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
if(old_ih != ih) if(old_ih != ih)
throw new ClassGenException("Not targeting " + old_ih + ", but " + ih + "}"); throw new ClassGenException("Not targeting " + old_ih + ", but " + ih + "}");
@ -113,12 +114,13 @@ public class LineNumberGen
return new LineNumber(ih.getPosition(), src_line); return new LineNumber(ih.getPosition(), src_line);
} }
public void setInstruction(InstructionHandle ih) { public final void setInstruction(InstructionHandle ih) {
BranchInstruction.notifyTarget(this.ih, ih, this); BranchInstruction.notifyTargetChanging(this.ih, this);
this.ih = ih; this.ih = ih;
BranchInstruction.notifyTargetChanged(this.ih, this);
} }
@Override
public Object clone() { public Object clone() {
try { try {
return super.clone(); 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.Constants;
import com.sun.org.apache.bcel.internal.classfile.*; import com.sun.org.apache.bcel.internal.classfile.*;
import java.util.Objects;
/** /**
* This class represents a local variable within a method. It contains its * This class represents a local variable within a method. It contains its
@ -75,7 +76,7 @@ public class LocalVariableGen
implements InstructionTargeter, NamedAndTyped, Cloneable, implements InstructionTargeter, NamedAndTyped, Cloneable,
java.io.Serializable java.io.Serializable
{ {
private int index; private final int index;
private String name; private String name;
private Type type; private Type type;
private InstructionHandle start, end; private InstructionHandle start, end;
@ -131,30 +132,96 @@ public class LocalVariableGen
signature_index, index, cp.getConstantPool()); 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; } public void setName(String name) { this.name = name; }
@Override
public String getName() { return name; } public String getName() { return name; }
@Override
public void setType(Type type) { this.type = type; } public void setType(Type type) { this.type = type; }
@Override
public Type getType() { return type; } public Type getType() { return type; }
public InstructionHandle getStart() { return start; } public InstructionHandle getStart() { return start; }
public InstructionHandle getEnd() { return end; } public InstructionHandle getEnd() { return end; }
public void setStart(InstructionHandle start) { /**
BranchInstruction.notifyTarget(this.start, start, this); * Remove this from any known HashSet in which it might be registered.
this.start = start; */
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; 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 old_ih old target, either start or end
* @param new_ih new target * @param new_ih new target
*/ */
@Override
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
boolean targeted = false; boolean targeted = false;
@ -176,15 +243,20 @@ public class LocalVariableGen
/** /**
* @return true, if ih is target of this variable * @return true, if ih is target of this variable
*/ */
@Override
public boolean containsTarget(InstructionHandle ih) { public boolean containsTarget(InstructionHandle ih) {
return (start == ih) || (end == 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. * are valid in the same range.
*/ */
@Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (o==this)
return true;
if(!(o instanceof LocalVariableGen)) if(!(o instanceof LocalVariableGen))
return false; return false;
@ -192,10 +264,21 @@ public class LocalVariableGen
return (l.index == index) && (l.start == start) && (l.end == end); 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() { public String toString() {
return "LocalVariableGen(" + name + ", " + type + ", " + start + ", " + end + ")"; return "LocalVariableGen(" + name + ", " + type + ", " + start + ", " + end + ")";
} }
@Override
public Object clone() { public Object clone() {
try { try {
return super.clone(); return super.clone();

View file

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

View file

@ -97,8 +97,9 @@ public abstract class Select extends BranchInstruction
super(opcode, target); super(opcode, target);
this.targets = targets; this.targets = targets;
for(int i=0; i < targets.length; i++) for(int i=0; i < targets.length; i++) {
notifyTarget(null, targets[i], this); BranchInstruction.notifyTargetChanged(targets[i], this);
}
this.match = match; 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 * @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 * @return additional offset caused by possible change of this instruction's length
*/ */
@Override
protected int updatePosition(int offset, int max_offset) { protected int updatePosition(int offset, int max_offset) {
position += offset; // Additional offset caused by preceding SWITCHs, GOTOs, etc. 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. * Dump instruction as byte code to stream out.
* @param out Output stream * @param out Output stream
*/ */
@Override
public void dump(DataOutputStream out) throws IOException { public void dump(DataOutputStream out) throws IOException {
out.writeByte(opcode); out.writeByte(opcode);
@ -151,6 +154,7 @@ public abstract class Select extends BranchInstruction
/** /**
* Read needed data (e.g. index) from file. * Read needed data (e.g. index) from file.
*/ */
@Override
protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
{ {
padding = (4 - (bytes.getIndex() % 4)) % 4; // Compute number of pad bytes 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 * @return mnemonic for instruction
*/ */
@Override
public String toString(boolean verbose) { public String toString(boolean verbose) {
StringBuffer buf = new StringBuffer(super.toString(verbose)); final StringBuilder buf = new StringBuilder(super.toString(verbose));
if(verbose) { if(verbose) {
for(int i=0; i < match_length; i++) { for(int i=0; i < match_length; i++) {
@ -176,7 +181,8 @@ public abstract class Select extends BranchInstruction
if(targets[i] != null) if(targets[i] != null)
s = targets[i].getInstruction().toString(); 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 else
@ -188,15 +194,17 @@ public abstract class Select extends BranchInstruction
/** /**
* Set branch target for `i'th case * Set branch target for `i'th case
*/ */
public void setTarget(int i, InstructionHandle target) { public final void setTarget(int i, InstructionHandle target) {
notifyTarget(targets[i], target, this); notifyTargetChanging(targets[i], this);
targets[i] = target; targets[i] = target;
notifyTargetChanged(targets[i], this);
} }
/** /**
* @param old_ih old target * @param old_ih old target
* @param new_ih new target * @param new_ih new target
*/ */
@Override
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) { public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
boolean targeted = false; boolean targeted = false;
@ -219,6 +227,7 @@ public abstract class Select extends BranchInstruction
/** /**
* @return true, if ih is target of this instruction * @return true, if ih is target of this instruction
*/ */
@Override
public boolean containsTarget(InstructionHandle ih) { public boolean containsTarget(InstructionHandle ih) {
if(target == ih) if(target == ih)
return true; return true;
@ -233,6 +242,7 @@ public abstract class Select extends BranchInstruction
/** /**
* Inform targets that they're not targeted anymore. * Inform targets that they're not targeted anymore.
*/ */
@Override
void dispose() { void dispose() {
super.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.Type;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
import com.sun.org.apache.xalan.internal.utils.ObjectFactory; import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
import java.util.Objects;
/** /**
* @author Jacek Ambroziak * @author Jacek Ambroziak
@ -156,8 +157,15 @@ class FunctionCall extends Expression {
this.type = type; this.type = type;
this.distance = distance; this.distance = distance;
} }
@Override
public int hashCode() {
return Objects.hashCode(this.type);
}
@Override
public boolean equals(Object query){ 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()); return(_fname.toString());
} }
@Override
public void setParser(Parser parser) { public void setParser(Parser parser) {
super.setParser(parser); super.setParser(parser);
if (_arguments != null) { if (_arguments != null) {
@ -319,6 +328,7 @@ class FunctionCall extends Expression {
* Type check a function call. Since different type conversions apply, * Type check a function call. Since different type conversions apply,
* type checking is different for standard and external (Java) functions. * type checking is different for standard and external (Java) functions.
*/ */
@Override
public Type typeCheck(SymbolTable stable) public Type typeCheck(SymbolTable stable)
throws TypeCheckError throws TypeCheckError
{ {
@ -680,6 +690,7 @@ class FunctionCall extends Expression {
* Compile the function call and treat as an expression * Compile the function call and treat as an expression
* Update true/false-lists. * Update true/false-lists.
*/ */
@Override
public void translateDesynthesized(ClassGenerator classGen, public void translateDesynthesized(ClassGenerator classGen,
MethodGenerator methodGen) MethodGenerator methodGen)
{ {
@ -700,6 +711,7 @@ class FunctionCall extends Expression {
* Translate a function call. The compiled code will leave the function's * Translate a function call. The compiled code will leave the function's
* return value on the JVM's stack. * return value on the JVM's stack.
*/ */
@Override
public void translate(ClassGenerator classGen, MethodGenerator methodGen) { public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
final int n = argumentCount(); final int n = argumentCount();
final ConstantPoolGen cpg = classGen.getConstantPool(); final ConstantPoolGen cpg = classGen.getConstantPool();
@ -857,6 +869,7 @@ class FunctionCall extends Expression {
} }
} }
@Override
public String toString() { public String toString() {
return "funcall(" + _fname + ", " + _arguments + ')'; return "funcall(" + _fname + ", " + _arguments + ')';
} }
@ -1069,7 +1082,7 @@ class FunctionCall extends Expression {
protected static String replaceDash(String name) protected static String replaceDash(String name)
{ {
char dash = '-'; char dash = '-';
StringBuffer buff = new StringBuffer(""); final StringBuilder buff = new StringBuilder("");
for (int i = 0; i < name.length(); i++) { for (int i = 0; i < name.length(); i++) {
if (i > 0 && name.charAt(i-1) == dash) if (i > 0 && name.charAt(i-1) == dash)
buff.append(Character.toUpperCase(name.charAt(i))); 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.Type;
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError; import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
import java.util.Objects;
/** /**
* @author Morten Jorgensen * @author Morten Jorgensen
@ -97,13 +98,15 @@ class VariableRefBase extends Expression {
* Two variable references are deemed equal if they refer to the * Two variable references are deemed equal if they refer to the
* same variable. * same variable.
*/ */
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
try { return obj == this || (obj instanceof VariableRefBase)
return (_variable == ((VariableRefBase) obj)._variable); && (_variable == ((VariableRefBase) obj)._variable);
}
catch (ClassCastException e) {
return false;
} }
@Override
public int hashCode() {
return Objects.hashCode(this._variable);
} }
/** /**
@ -111,10 +114,12 @@ class VariableRefBase extends Expression {
* format 'variable-ref(<var-name>)'. * format 'variable-ref(<var-name>)'.
* @return Variable reference description * @return Variable reference description
*/ */
@Override
public String toString() { public String toString() {
return "variable-ref("+_variable.getName()+'/'+_variable.getType()+')'; return "variable-ref("+_variable.getName()+'/'+_variable.getType()+')';
} }
@Override
public Type typeCheck(SymbolTable stable) public Type typeCheck(SymbolTable stable)
throws TypeCheckError throws TypeCheckError
{ {

View file

@ -53,26 +53,23 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
//debugging //debugging
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
//define shared variables for date/time //define shared variables for date/time
//define constants to be used in assigning default values for //define constants to be used in assigning default values for
//all date/time excluding duration //all date/time excluding duration
protected final static int YEAR = 2000; protected final static int YEAR = 2000;
protected final static int MONTH = 01; protected final static int MONTH = 01;
protected final static int DAY = 01; protected final static int DAY = 01;
protected static final DatatypeFactory datatypeFactory = new DatatypeFactoryImpl(); protected static final DatatypeFactory datatypeFactory = new DatatypeFactoryImpl();
@Override
public short getAllowedFacets() { 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); return (XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION | XSSimpleTypeDecl.FACET_MAXINCLUSIVE | XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE | XSSimpleTypeDecl.FACET_MINEXCLUSIVE);
}//getAllowedFacets() }//getAllowedFacets()
// distinguishes between identity and equality for date/time values // distinguishes between identity and equality for date/time values
// ie: two values representing the same "moment in time" but with different // ie: two values representing the same "moment in time" but with different
// remembered timezones are now equal but not identical. // remembered timezones are now equal but not identical.
@Override
public boolean isIdentical(Object value1, Object value2) { public boolean isIdentical(Object value1, Object value2) {
if (!(value1 instanceof DateTimeData) || !(value2 instanceof DateTimeData)) { if (!(value1 instanceof DateTimeData) || !(value2 instanceof DateTimeData)) {
return false; return false;
@ -91,14 +88,15 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
}//isIdentical() }//isIdentical()
// the parameters are in compiled form (from getActualValue) // the parameters are in compiled form (from getActualValue)
@Override
public int compare(Object value1, Object value2) { public int compare(Object value1, Object value2) {
return compareDates(((DateTimeData) value1), return compareDates(((DateTimeData) value1),
((DateTimeData) value2), true); ((DateTimeData) value2), true);
}//compare() }//compare()
/** /**
* Compare algorithm described in dateDime (3.2.7). * Compare algorithm described in dateDime (3.2.7). Duration datatype
* Duration datatype overwrites this method * overwrites this method
* *
* @param date1 normalized date representation of the first value * @param date1 normalized date representation of the first value
* @param date2 normalized date representation of the second value * @param date2 normalized date representation of the second value
@ -123,8 +121,9 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
tempDate.utc = '+'; tempDate.utc = '+';
normalize(tempDate); normalize(tempDate);
c1 = compareOrder(date1, tempDate); c1 = compareOrder(date1, tempDate);
if (c1 == LESS_THAN) if (c1 == LESS_THAN) {
return c1; return c1;
}
//compare date1>=(date2 with time zone +14) //compare date1>=(date2 with time zone +14)
// //
@ -134,12 +133,12 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
tempDate.utc = '-'; tempDate.utc = '-';
normalize(tempDate); normalize(tempDate);
c2 = compareOrder(date1, tempDate); c2 = compareOrder(date1, tempDate);
if (c2 == GREATER_THAN) if (c2 == GREATER_THAN) {
return c2; return c2;
}
return INDETERMINATE; return INDETERMINATE;
} } else if (date2.utc == 'Z') {
else if ( date2.utc=='Z' ) {
//compare (date1 with time zone -14)<=date2 //compare (date1 with time zone -14)<=date2
// //
@ -156,8 +155,9 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
System.out.println("date=" + dateToString(date2)); System.out.println("date=" + dateToString(date2));
System.out.println("tempDate=" + dateToString(tempDate)); System.out.println("tempDate=" + dateToString(tempDate));
} }
if (c1 == LESS_THAN) if (c1 == LESS_THAN) {
return c1; return c1;
}
//compare (date1 with time zone +14)<=date2 //compare (date1 with time zone +14)<=date2
// //
@ -170,8 +170,9 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
if (DEBUG) { if (DEBUG) {
System.out.println("tempDate=" + dateToString(tempDate)); System.out.println("tempDate=" + dateToString(tempDate));
} }
if (c2 == GREATER_THAN) if (c2 == GREATER_THAN) {
return c2; return c2;
}
return INDETERMINATE; return INDETERMINATE;
} }
@ -180,46 +181,61 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
} }
/** /**
* Given normalized values, determines order-relation * Given normalized values, determines order-relation between give date/time
* between give date/time objects. * objects.
* *
* @param date1 date/time object * @param date1 date/time object
* @param date2 date/time object * @param date2 date/time object
* @return 0 if date1 and date2 are equal, a value less than 0 if date1 is less than date2, a value greater than 0 if date1 is greater than date2 * @return 0 if date1 and date2 are equal, a value less than 0 if date1 is
* less than date2, a value greater than 0 if date1 is greater than date2
*/ */
protected short compareOrder(DateTimeData date1, DateTimeData date2) { protected short compareOrder(DateTimeData date1, DateTimeData date2) {
if (date1.position < 1) { if (date1.position < 1) {
if (date1.year < date2.year) if (date1.year < date2.year) {
return -1; return -1;
if (date1.year > date2.year) }
if (date1.year > date2.year) {
return 1; return 1;
} }
}
if (date1.position < 2) { if (date1.position < 2) {
if (date1.month < date2.month) if (date1.month < date2.month) {
return -1; return -1;
if (date1.month > date2.month) }
if (date1.month > date2.month) {
return 1; return 1;
} }
if (date1.day < date2.day) }
if (date1.day < date2.day) {
return -1; return -1;
if (date1.day > date2.day) }
if (date1.day > date2.day) {
return 1; return 1;
if (date1.hour < date2.hour) }
if (date1.hour < date2.hour) {
return -1; return -1;
if (date1.hour > date2.hour) }
if (date1.hour > date2.hour) {
return 1; return 1;
if (date1.minute < date2.minute) }
if (date1.minute < date2.minute) {
return -1; return -1;
if (date1.minute > date2.minute) }
if (date1.minute > date2.minute) {
return 1; return 1;
if (date1.second < date2.second) }
if (date1.second < date2.second) {
return -1; return -1;
if (date1.second > date2.second) }
if (date1.second > date2.second) {
return 1; return 1;
if (date1.utc < date2.utc) }
if (date1.utc < date2.utc) {
return -1; return -1;
if (date1.utc > date2.utc) }
if (date1.utc > date2.utc) {
return 1; return 1;
}
return 0; return 0;
} }
@ -305,12 +321,13 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
start++; start++;
} }
int i = indexOf(buffer, start, end, '-'); int i = indexOf(buffer, start, end, '-');
if ( i==-1 ) throw new RuntimeException("Year separator is missing or misplaced"); if (i == -1) {
throw new RuntimeException("Year separator is missing or misplaced");
}
int length = i - start; int length = i - start;
if (length < 4) { if (length < 4) {
throw new RuntimeException("Year must have 'CCYY' format"); throw new RuntimeException("Year must have 'CCYY' format");
} } else if (length > 4 && buffer.charAt(start) == '0') {
else if (length > 4 && buffer.charAt(start)=='0'){
throw new RuntimeException("Leading zeros are required if the year value would otherwise have fewer than four digits; otherwise they are forbidden"); throw new RuntimeException("Leading zeros are required if the year value would otherwise have fewer than four digits; otherwise they are forbidden");
} }
date.year = parseIntYear(buffer, i); date.year = parseIntYear(buffer, i);
@ -324,8 +341,8 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
} }
/** /**
* Shared code from Date and YearMonth datatypes. * Shared code from Date and YearMonth datatypes. Finds if time zone sign is
* Finds if time zone sign is present * present
* *
* @param end * @param end
* @param date * @param date
@ -338,8 +355,7 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
if (start < end) { if (start < end) {
if (!isNextCharUTCSign(buffer, start, end)) { if (!isNextCharUTCSign(buffer, start, end)) {
throw new RuntimeException("Error in month parsing"); throw new RuntimeException("Error in month parsing");
} } else {
else {
getTimeZone(buffer, date, start, end); getTimeZone(buffer, date, start, end);
} }
} }
@ -377,10 +393,10 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
if (stop + 2 != end) { if (stop + 2 != end) {
throw new RuntimeException("Error in parsing time zone"); throw new RuntimeException("Error in parsing time zone");
} }
if(data.timezoneHr != 0 || data.timezoneMin != 0) if (data.timezoneHr != 0 || data.timezoneMin != 0) {
data.normalized = false; data.normalized = false;
} }
else { } else {
throw new RuntimeException("Error in parsing time zone"); throw new RuntimeException("Error in parsing time zone");
} }
if (DEBUG) { if (DEBUG) {
@ -406,8 +422,8 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
} }
/** /**
* Validates given date/time object accoring to W3C PR Schema * Validates given date/time object accoring to W3C PR Schema [D.1 ISO 8601
* [D.1 ISO 8601 Conventions] * Conventions]
* *
* @param data * @param data
*/ */
@ -444,14 +460,12 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
data.month = 1; data.month = 1;
if (Constants.SCHEMA_1_1_SUPPORT) { if (Constants.SCHEMA_1_1_SUPPORT) {
++data.year; ++data.year;
} } else if (++data.year == 0) {
else if (++data.year == 0) {
data.year = 1; data.year = 1;
} }
} }
} }
} } else {
else {
throw new RuntimeException("Hour must have values 0-23, unless 24:00:00"); throw new RuntimeException("Hour must have values 0-23, unless 24:00:00");
} }
} }
@ -470,13 +484,13 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
//validate //validate
if (data.timezoneHr > 14 || data.timezoneHr < -14) { if (data.timezoneHr > 14 || data.timezoneHr < -14) {
throw new RuntimeException("Time zone should have range -14:00 to +14:00"); throw new RuntimeException("Time zone should have range -14:00 to +14:00");
} } else {
else { if ((data.timezoneHr == 14 || data.timezoneHr == -14) && data.timezoneMin != 0) {
if((data.timezoneHr == 14 || data.timezoneHr == -14) && data.timezoneMin != 0)
throw new RuntimeException("Time zone should have range -14:00 to +14:00"); throw new RuntimeException("Time zone should have range -14:00 to +14:00");
else if(data.timezoneMin > 59 || data.timezoneMin < -59) } else if (data.timezoneMin > 59 || data.timezoneMin < -59) {
throw new RuntimeException("Minute must have values 0-59"); throw new RuntimeException("Minute must have values 0-59");
} }
}
} }
@ -500,7 +514,8 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
} }
/** /**
* Returns <code>true</code> if the character at start is 'Z', '+' or '-'. * Returns
* <code>true</code> if the character at start is 'Z', '+' or '-'.
*/ */
protected final boolean isNextCharUTCSign(String buffer, int start, int end) { protected final boolean isNextCharUTCSign(String buffer, int start, int end) {
if (start < end) { if (start < end) {
@ -529,10 +544,16 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
int i = start; int i = start;
do { do {
digit = getDigit(buffer.charAt(i)); digit = getDigit(buffer.charAt(i));
if ( digit < 0 ) throw new NumberFormatException("'" + buffer + "' has wrong format"); if (digit < 0) {
if ( result < multmin ) throw new NumberFormatException("'" + buffer + "' has wrong format"); throw new NumberFormatException("'" + buffer + "' has wrong format");
}
if (result < multmin) {
throw new NumberFormatException("'" + buffer + "' has wrong format");
}
result *= radix; result *= radix;
if ( result < limit + digit ) throw new NumberFormatException("'" + buffer + "' has wrong format"); if (result < limit + digit) {
throw new NumberFormatException("'" + buffer + "' has wrong format");
}
result -= digit; result -= digit;
} while (++i < end); } while (++i < end);
@ -554,32 +575,39 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
limit = Integer.MIN_VALUE; limit = Integer.MIN_VALUE;
i++; i++;
} } else {
else{
limit = -Integer.MAX_VALUE; limit = -Integer.MAX_VALUE;
} }
multmin = limit / radix; multmin = limit / radix;
while (i < end) while (i < end) {
{
digit = getDigit(buffer.charAt(i++)); digit = getDigit(buffer.charAt(i++));
if (digit < 0) throw new NumberFormatException("'" + buffer + "' has wrong format"); if (digit < 0) {
if (result < multmin) throw new NumberFormatException("'" + buffer + "' has wrong format"); throw new NumberFormatException("'" + buffer + "' has wrong format");
}
if (result < multmin) {
throw new NumberFormatException("'" + buffer + "' has wrong format");
}
result *= radix; result *= radix;
if (result < limit + digit) throw new NumberFormatException("'" + buffer + "' has wrong format"); if (result < limit + digit) {
throw new NumberFormatException("'" + buffer + "' has wrong format");
}
result -= digit; result -= digit;
} }
if (negative) if (negative) {
{ if (i > 1) {
if (i > 1) return result; return result;
else throw new NumberFormatException("'" + buffer + "' has wrong format"); } else {
throw new NumberFormatException("'" + buffer + "' has wrong format");
}
} }
return -result; return -result;
} }
/** /**
* If timezone present - normalize dateTime [E Adding durations to dateTimes] * If timezone present - normalize dateTime [E Adding durations to
* dateTimes]
* *
* @param date CCYY-MM-DDThh:mm:ss+03 * @param date CCYY-MM-DDThh:mm:ss+03
*/ */
@ -619,12 +647,10 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
if (date.day < 1) { if (date.day < 1) {
date.day = date.day + maxDayInMonthFor(date.year, date.month - 1); date.day = date.day + maxDayInMonthFor(date.year, date.month - 1);
carry = -1; carry = -1;
} } else if (date.day > temp) {
else if ( date.day>temp ) {
date.day = date.day - temp; date.day = date.day - temp;
carry = 1; carry = 1;
} } else {
else {
break; break;
} }
temp = date.month + carry; temp = date.month + carry;
@ -637,7 +663,6 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
date.utc = 'Z'; date.utc = 'Z';
} }
/** /**
* @param date * @param date
*/ */
@ -668,8 +693,7 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
} }
/** /**
* Given {year,month} computes maximum * Given {year,month} computes maximum number of days for given month
* number of days for given month
* *
* @param year * @param year
* @param month * @param month
@ -679,16 +703,13 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
//validate days //validate days
if (month == 4 || month == 6 || month == 9 || month == 11) { if (month == 4 || month == 6 || month == 9 || month == 11) {
return 30; return 30;
} } else if (month == 2) {
else if ( month==2 ) {
if (isLeapYear(year)) { if (isLeapYear(year)) {
return 29; return 29;
} } else {
else {
return 28; return 28;
} }
} } else {
else {
return 31; return 31;
} }
} }
@ -735,7 +756,6 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
return fQuotient(temp - low, high - low); return fQuotient(temp - low, high - low);
} }
protected String dateToString(DateTimeData date) { protected String dateToString(DateTimeData date) {
StringBuffer message = new StringBuffer(25); StringBuffer message = new StringBuffer(25);
append(message, date.year, 4); append(message, date.year, 4);
@ -763,24 +783,25 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
value = -value; value = -value;
} }
if (nch == 4) { if (nch == 4) {
if (value < 10) if (value < 10) {
message.append("000"); message.append("000");
else if (value < 100) } else if (value < 100) {
message.append("00"); message.append("00");
else if (value < 1000) } else if (value < 1000) {
message.append('0'); message.append('0');
message.append(value);
} }
else if (nch == 2) { message.append(value);
if (value < 10) } else if (nch == 2) {
if (value < 10) {
message.append('0'); message.append('0');
message.append(value);
} }
else { message.append(value);
if (value != 0) } else {
if (value != 0) {
message.append((char) value); message.append((char) value);
} }
} }
}
protected final void append(StringBuffer message, double value) { protected final void append(StringBuffer message, double value) {
if (value < 0) { if (value < 0) {
@ -797,8 +818,7 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
final int intValue = (int) value; final int intValue = (int) value;
if (value == intValue) { if (value == intValue) {
message.append(intValue); message.append(intValue);
} } else {
else {
append3(message, value); append3(message, value);
} }
} }
@ -816,8 +836,7 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
// n.nnn...E-N (N >= 4) to a normal decimal value. // n.nnn...E-N (N >= 4) to a normal decimal value.
try { try {
exp = parseInt(d, eIndex + 2, d.length()); exp = parseInt(d, eIndex + 2, d.length());
} } // This should never happen.
// This should never happen.
// It's only possible if String.valueOf(double) is broken. // It's only possible if String.valueOf(double) is broken.
catch (Exception e) { catch (Exception e) {
message.append(d); message.append(d);
@ -843,14 +862,12 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
message.append(c); message.append(c);
} }
} }
} } else {
else {
// Need to convert from scientific notation of the form // Need to convert from scientific notation of the form
// n.nnn...EN (N >= 7) to a normal decimal value. // n.nnn...EN (N >= 7) to a normal decimal value.
try { try {
exp = parseInt(d, eIndex + 1, d.length()); exp = parseInt(d, eIndex + 1, d.length());
} } // This should never happen.
// This should never happen.
// It's only possible if String.valueOf(double) is broken. // It's only possible if String.valueOf(double) is broken.
catch (Exception e) { catch (Exception e) {
message.append(d); message.append(d);
@ -878,16 +895,17 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
int dot = -1; int dot = -1;
for (int i = start; i < end; i++) { for (int i = start; i < end; i++) {
char ch = buffer.charAt(i); char ch = buffer.charAt(i);
if (ch == '.') if (ch == '.') {
dot = i; dot = i;
else if (ch > '9' || ch < '0') } else if (ch > '9' || ch < '0') {
throw new NumberFormatException("'" + buffer + "' has wrong format"); throw new NumberFormatException("'" + buffer + "' has wrong format");
} }
}
if (dot == -1) { if (dot == -1) {
if (start+2 != end) if (start + 2 != end) {
throw new NumberFormatException("'" + buffer + "' has wrong format"); throw new NumberFormatException("'" + buffer + "' has wrong format");
} }
else if (start+2 != dot || dot+1 == end) { } else if (start + 2 != dot || dot + 1 == end) {
throw new NumberFormatException("'" + buffer + "' has wrong format"); throw new NumberFormatException("'" + buffer + "' has wrong format");
} }
return Double.parseDouble(buffer.substring(start, end)); return Double.parseDouble(buffer.substring(start, end));
@ -896,7 +914,6 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
// //
//Private help functions //Private help functions
// //
private void cloneDate(DateTimeData finalValue, DateTimeData tempDate) { private void cloneDate(DateTimeData finalValue, DateTimeData tempDate) {
tempDate.year = finalValue.year; tempDate.year = finalValue.year;
tempDate.month = finalValue.month; tempDate.month = finalValue.month;
@ -913,19 +930,18 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
* Represents date time data * Represents date time data
*/ */
static final class DateTimeData implements XSDateTime { static final class DateTimeData implements XSDateTime {
int year, month, day, hour, minute, utc; int year, month, day, hour, minute, utc;
double second; double second;
int timezoneHr, timezoneMin; int timezoneHr, timezoneMin;
private String originalValue; private String originalValue;
boolean normalized = true; boolean normalized = true;
int unNormYear; int unNormYear;
int unNormMonth; int unNormMonth;
int unNormDay; int unNormDay;
int unNormHour; int unNormHour;
int unNormMinute; int unNormMinute;
double unNormSecond; double unNormSecond;
// used for comparisons - to decide the 'interesting' portions of // used for comparisons - to decide the 'interesting' portions of
// a date/time based data type. // a date/time based data type.
int position; int position;
@ -933,11 +949,13 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
// note that this is not the actual simple type, but one of the // note that this is not the actual simple type, but one of the
// statically created XXXDV objects, so this won't cause any GC problem. // statically created XXXDV objects, so this won't cause any GC problem.
final AbstractDateTimeDV type; final AbstractDateTimeDV type;
private String canonical; private volatile String canonical;
public DateTimeData(String originalValue, AbstractDateTimeDV type) { public DateTimeData(String originalValue, AbstractDateTimeDV type) {
this.originalValue = originalValue; this.originalValue = originalValue;
this.type = type; this.type = type;
} }
public DateTimeData(int year, int month, int day, int hour, int minute, public DateTimeData(int year, int month, int day, int hour, int minute,
double second, int utc, String originalValue, boolean normalized, AbstractDateTimeDV type) { double second, int utc, String originalValue, boolean normalized, AbstractDateTimeDV type) {
this.year = year; this.year = year;
@ -950,12 +968,31 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
this.type = type; this.type = type;
this.originalValue = originalValue; this.originalValue = originalValue;
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (!(obj instanceof DateTimeData)) if (!(obj instanceof DateTimeData)) {
return false; return false;
}
return type.compareDates(this, (DateTimeData) obj, true) == 0; return type.compareDates(this, (DateTimeData) obj, true) == 0;
} }
public synchronized String toString() {
// If two DateTimeData are equals - then they should have the same
// hashcode. This means we need to convert the date to UTC before
// we return its hashcode.
// The DateTimeData is unfortunately mutable - so we cannot
// cache the result of the conversion...
//
@Override
public int hashCode() {
final DateTimeData tempDate = new DateTimeData(null, type);
type.cloneDate(this, tempDate);
type.normalize(tempDate);
return type.dateToString(tempDate).hashCode();
}
@Override
public String toString() {
if (canonical == null) { if (canonical == null) {
canonical = type.dateToString(this); canonical = type.dateToString(this);
} }
@ -964,14 +1001,19 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getYear() * @see org.apache.xerces.xs.datatypes.XSDateTime#getYear()
*/ */
@Override
public int getYears() { public int getYears() {
if(type instanceof DurationDV) if (type instanceof DurationDV) {
return 0; return 0;
}
return normalized ? year : unNormYear; return normalized ? year : unNormYear;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getMonth() * @see org.apache.xerces.xs.datatypes.XSDateTime#getMonth()
*/ */
@Override
public int getMonths() { public int getMonths() {
if (type instanceof DurationDV) { if (type instanceof DurationDV) {
return year * 12 + month; return year * 12 + month;
@ -981,30 +1023,41 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getDay() * @see org.apache.xerces.xs.datatypes.XSDateTime#getDay()
*/ */
@Override
public int getDays() { public int getDays() {
if(type instanceof DurationDV) if (type instanceof DurationDV) {
return 0; return 0;
}
return normalized ? day : unNormDay; return normalized ? day : unNormDay;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getHour() * @see org.apache.xerces.xs.datatypes.XSDateTime#getHour()
*/ */
@Override
public int getHours() { public int getHours() {
if(type instanceof DurationDV) if (type instanceof DurationDV) {
return 0; return 0;
}
return normalized ? hour : unNormHour; return normalized ? hour : unNormHour;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getMinutes() * @see org.apache.xerces.xs.datatypes.XSDateTime#getMinutes()
*/ */
@Override
public int getMinutes() { public int getMinutes() {
if(type instanceof DurationDV) if (type instanceof DurationDV) {
return 0; return 0;
}
return normalized ? minute : unNormMinute; return normalized ? minute : unNormMinute;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getSeconds() * @see org.apache.xerces.xs.datatypes.XSDateTime#getSeconds()
*/ */
@Override
public double getSeconds() { public double getSeconds() {
if (type instanceof DurationDV) { if (type instanceof DurationDV) {
return day * 24 * 60 * 60 + hour * 60 * 60 + minute * 60 + second; return day * 24 * 60 * 60 + hour * 60 * 60 + minute * 60 + second;
@ -1014,30 +1067,40 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#hasTimeZone() * @see org.apache.xerces.xs.datatypes.XSDateTime#hasTimeZone()
*/ */
@Override
public boolean hasTimeZone() { public boolean hasTimeZone() {
return utc != 0; return utc != 0;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getTimeZoneHours() * @see org.apache.xerces.xs.datatypes.XSDateTime#getTimeZoneHours()
*/ */
@Override
public int getTimeZoneHours() { public int getTimeZoneHours() {
return timezoneHr; return timezoneHr;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getTimeZoneMinutes() * @see org.apache.xerces.xs.datatypes.XSDateTime#getTimeZoneMinutes()
*/ */
@Override
public int getTimeZoneMinutes() { public int getTimeZoneMinutes() {
return timezoneMin; return timezoneMin;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getLexicalValue() * @see org.apache.xerces.xs.datatypes.XSDateTime#getLexicalValue()
*/ */
@Override
public String getLexicalValue() { public String getLexicalValue() {
return originalValue; return originalValue;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#normalize() * @see org.apache.xerces.xs.datatypes.XSDateTime#normalize()
*/ */
@Override
public XSDateTime normalize() { public XSDateTime normalize() {
if (!normalized) { if (!normalized) {
DateTimeData dt = (DateTimeData) this.clone(); DateTimeData dt = (DateTimeData) this.clone();
@ -1049,10 +1112,13 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#isNormalized() * @see org.apache.xerces.xs.datatypes.XSDateTime#isNormalized()
*/ */
@Override
public boolean isNormalized() { public boolean isNormalized() {
return normalized; return normalized;
} }
@Override
public Object clone() { public Object clone() {
DateTimeData dt = new DateTimeData(this.year, this.month, this.day, this.hour, DateTimeData dt = new DateTimeData(this.year, this.month, this.day, this.hour,
this.minute, this.second, this.utc, this.originalValue, this.normalized, this.type); this.minute, this.second, this.utc, this.originalValue, this.normalized, this.type);
@ -1072,12 +1138,15 @@ public abstract class AbstractDateTimeDV extends TypeValidator {
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getXMLGregorianCalendar() * @see org.apache.xerces.xs.datatypes.XSDateTime#getXMLGregorianCalendar()
*/ */
@Override
public XMLGregorianCalendar getXMLGregorianCalendar() { public XMLGregorianCalendar getXMLGregorianCalendar() {
return type.getXMLGregorianCalendar(this); return type.getXMLGregorianCalendar(this);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getDuration() * @see org.apache.xerces.xs.datatypes.XSDateTime#getDuration()
*/ */
@Override
public Duration getDuration() { public Duration getDuration() {
return type.getDuration(this); return type.getDuration(this);
} }

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

View file

@ -32,7 +32,7 @@ import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext;
*/ */
class PrecisionDecimalDV extends TypeValidator { 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) // sign: 0 for absent; 1 for positive values; -1 for negative values (except in case of INF, -INF)
int sign = 1; int sign = 1;
@ -144,7 +144,71 @@ class PrecisionDecimalDV extends TypeValidator {
totalDigits = intDigits + fracDigits; 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) { public boolean equals(Object val) {
if (val == this) if (val == this)
return true; return true;
@ -156,6 +220,20 @@ class PrecisionDecimalDV extends TypeValidator {
return this.compareTo(oval) == EQUAL; 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 * @return
*/ */
@ -295,6 +373,7 @@ class PrecisionDecimalDV extends TypeValidator {
private String canonical; private String canonical;
@Override
public synchronized String toString() { public synchronized String toString() {
if (canonical == null) { if (canonical == null) {
makeCanonical(); makeCanonical();
@ -325,6 +404,7 @@ class PrecisionDecimalDV extends TypeValidator {
/* (non-Javadoc) /* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator#getAllowedFacets() * @see com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator#getAllowedFacets()
*/ */
@Override
public short getAllowedFacets() { 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); 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) /* (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) * @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) public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException { throws InvalidDatatypeValueException {
try { try {
@ -341,18 +422,22 @@ class PrecisionDecimalDV extends TypeValidator {
} }
} }
@Override
public int compare(Object value1, Object value2) { public int compare(Object value1, Object value2) {
return ((XPrecisionDecimal)value1).compareTo((XPrecisionDecimal)value2); return ((XPrecisionDecimal)value1).compareTo((XPrecisionDecimal)value2);
} }
@Override
public int getFractionDigits(Object value) { public int getFractionDigits(Object value) {
return ((XPrecisionDecimal)value).fracDigits; return ((XPrecisionDecimal)value).fracDigits;
} }
@Override
public int getTotalDigits(Object value) { public int getTotalDigits(Object value) {
return ((XPrecisionDecimal)value).totalDigits; return ((XPrecisionDecimal)value).totalDigits;
} }
@Override
public boolean isIdentical(Object value1, Object value2) { public boolean isIdentical(Object value1, Object value2) {
if(!(value2 instanceof XPrecisionDecimal) || !(value1 instanceof XPrecisionDecimal)) if(!(value2 instanceof XPrecisionDecimal) || !(value1 instanceof XPrecisionDecimal))
return false; return false;

View file

@ -22,6 +22,7 @@ package com.sun.org.apache.xerces.internal.util;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects;
/********************************************************************** /**********************************************************************
* A class to represent a Uniform Resource Identifier (URI). This class * 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 * @return the scheme-specific part for this URI
*/ */
public String getSchemeSpecificPart() { public String getSchemeSpecificPart() {
StringBuffer schemespec = new StringBuffer(); final StringBuilder schemespec = new StringBuilder();
if (m_host != null || m_regAuthority != null) { if (m_host != null || m_regAuthority != null) {
schemespec.append("//"); schemespec.append("//");
@ -1297,7 +1298,7 @@ import java.io.Serializable;
* @return the authority * @return the authority
*/ */
public String getAuthority() { public String getAuthority() {
StringBuffer authority = new StringBuffer(); final StringBuilder authority = new StringBuilder();
if (m_host != null || m_regAuthority != null) { if (m_host != null || m_regAuthority != null) {
authority.append("//"); authority.append("//");
@ -1340,7 +1341,7 @@ import java.io.Serializable;
*/ */
public String getPath(boolean p_includeQueryString, public String getPath(boolean p_includeQueryString,
boolean p_includeFragment) { boolean p_includeFragment) {
StringBuffer pathString = new StringBuffer(m_path); final StringBuilder pathString = new StringBuilder(m_path);
if (p_includeQueryString && m_queryString != null) { if (p_includeQueryString && m_queryString != null) {
pathString.append('?'); pathString.append('?');
@ -1683,6 +1684,7 @@ import java.io.Serializable;
* @return true if p_test is a URI with all values equal to this * @return true if p_test is a URI with all values equal to this
* URI, false otherwise * URI, false otherwise
*/ */
@Override
public boolean equals(Object p_test) { public boolean equals(Object p_test) {
if (p_test instanceof URI) { if (p_test instanceof URI) {
URI testURI = (URI) p_test; URI testURI = (URI) p_test;
@ -1711,13 +1713,27 @@ import java.io.Serializable;
return false; 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. * Get the URI as a string specification. See RFC 2396 Section 5.2.
* *
* @return the URI string specification * @return the URI string specification
*/ */
@Override
public String toString() { public String toString() {
StringBuffer uriSpecString = new StringBuffer(); final StringBuilder uriSpecString = new StringBuilder();
if (m_scheme != null) { if (m_scheme != null) {
uriSpecString.append(m_scheme); 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.XPointerHandler;
import com.sun.org.apache.xerces.internal.xpointer.XPointerProcessor; import com.sun.org.apache.xerces.internal.xpointer.XPointerProcessor;
import com.sun.org.apache.xerces.internal.utils.ObjectFactory; import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
import java.util.Objects;
/** /**
* <p> * <p>
@ -390,6 +391,7 @@ public class XIncludeHandler
// XMLComponent methods // XMLComponent methods
@Override
public void reset(XMLComponentManager componentManager) public void reset(XMLComponentManager componentManager)
throws XNIException { throws XNIException {
fNamespaceContext = null; fNamespaceContext = null;
@ -597,6 +599,7 @@ public class XIncludeHandler
* this component. This method may return null if no features * this component. This method may return null if no features
* are recognized by this component. * are recognized by this component.
*/ */
@Override
public String[] getRecognizedFeatures() { public String[] getRecognizedFeatures() {
return (String[])(RECOGNIZED_FEATURES.clone()); return (String[])(RECOGNIZED_FEATURES.clone());
} // getRecognizedFeatures():String[] } // getRecognizedFeatures():String[]
@ -616,6 +619,7 @@ public class XIncludeHandler
* @throws SAXNotSupportedException The component should not throw * @throws SAXNotSupportedException The component should not throw
* this exception. * this exception.
*/ */
@Override
public void setFeature(String featureId, boolean state) public void setFeature(String featureId, boolean state)
throws XMLConfigurationException { throws XMLConfigurationException {
if (featureId.equals(ALLOW_UE_AND_NOTATION_EVENTS)) { 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 * this component. This method may return null if no properties
* are recognized by this component. * are recognized by this component.
*/ */
@Override
public String[] getRecognizedProperties() { public String[] getRecognizedProperties() {
return (String[])(RECOGNIZED_PROPERTIES.clone()); return (String[])(RECOGNIZED_PROPERTIES.clone());
} // getRecognizedProperties():String[] } // getRecognizedProperties():String[]
@ -651,6 +656,7 @@ public class XIncludeHandler
* @throws SAXNotSupportedException The component should not throw * @throws SAXNotSupportedException The component should not throw
* this exception. * this exception.
*/ */
@Override
public void setProperty(String propertyId, Object value) public void setProperty(String propertyId, Object value)
throws XMLConfigurationException { throws XMLConfigurationException {
if (propertyId.equals(SYMBOL_TABLE)) { if (propertyId.equals(SYMBOL_TABLE)) {
@ -719,6 +725,7 @@ public class XIncludeHandler
* *
* @since Xerces 2.2.0 * @since Xerces 2.2.0
*/ */
@Override
public Boolean getFeatureDefault(String featureId) { public Boolean getFeatureDefault(String featureId) {
for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) { for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
if (RECOGNIZED_FEATURES[i].equals(featureId)) { if (RECOGNIZED_FEATURES[i].equals(featureId)) {
@ -737,6 +744,7 @@ public class XIncludeHandler
* *
* @since Xerces 2.2.0 * @since Xerces 2.2.0
*/ */
@Override
public Object getPropertyDefault(String propertyId) { public Object getPropertyDefault(String propertyId) {
for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) { for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) { if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {
@ -746,10 +754,12 @@ public class XIncludeHandler
return null; return null;
} // getPropertyDefault(String):Object } // getPropertyDefault(String):Object
@Override
public void setDocumentHandler(XMLDocumentHandler handler) { public void setDocumentHandler(XMLDocumentHandler handler) {
fDocumentHandler = handler; fDocumentHandler = handler;
} }
@Override
public XMLDocumentHandler getDocumentHandler() { public XMLDocumentHandler getDocumentHandler() {
return fDocumentHandler; 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. * This event is only passed on to the document handler if this is the root document.
*/ */
@Override
public void startDocument( public void startDocument(
XMLLocator locator, XMLLocator locator,
String encoding, String encoding,
@ -811,6 +822,7 @@ public class XIncludeHandler
} }
} }
@Override
public void xmlDecl( public void xmlDecl(
String version, String version,
String encoding, String encoding,
@ -823,6 +835,7 @@ public class XIncludeHandler
} }
} }
@Override
public void doctypeDecl( public void doctypeDecl(
String rootElement, String rootElement,
String publicId, String publicId,
@ -834,6 +847,7 @@ public class XIncludeHandler
} }
} }
@Override
public void comment(XMLString text, Augmentations augs) public void comment(XMLString text, Augmentations augs)
throws XNIException { throws XNIException {
if (!fInDTD) { if (!fInDTD) {
@ -850,6 +864,7 @@ public class XIncludeHandler
} }
} }
@Override
public void processingInstruction( public void processingInstruction(
String target, String target,
XMLString data, XMLString data,
@ -870,6 +885,7 @@ public class XIncludeHandler
} }
} }
@Override
public void startElement( public void startElement(
QName element, QName element,
XMLAttributes attributes, XMLAttributes attributes,
@ -940,6 +956,7 @@ public class XIncludeHandler
} }
} }
@Override
public void emptyElement( public void emptyElement(
QName element, QName element,
XMLAttributes attributes, XMLAttributes attributes,
@ -1021,6 +1038,7 @@ public class XIncludeHandler
fDepth--; fDepth--;
} }
@Override
public void endElement(QName element, Augmentations augs) public void endElement(QName element, Augmentations augs)
throws XNIException { throws XNIException {
@ -1066,6 +1084,7 @@ public class XIncludeHandler
fDepth--; fDepth--;
} }
@Override
public void startGeneralEntity( public void startGeneralEntity(
String name, String name,
XMLResourceIdentifier resId, XMLResourceIdentifier resId,
@ -1084,6 +1103,7 @@ public class XIncludeHandler
} }
} }
@Override
public void textDecl(String version, String encoding, Augmentations augs) public void textDecl(String version, String encoding, Augmentations augs)
throws XNIException { throws XNIException {
if (fDocumentHandler != null if (fDocumentHandler != null
@ -1092,6 +1112,7 @@ public class XIncludeHandler
} }
} }
@Override
public void endGeneralEntity(String name, Augmentations augs) public void endGeneralEntity(String name, Augmentations augs)
throws XNIException { throws XNIException {
if (fDocumentHandler != null if (fDocumentHandler != null
@ -1101,6 +1122,7 @@ public class XIncludeHandler
} }
} }
@Override
public void characters(XMLString text, Augmentations augs) public void characters(XMLString text, Augmentations augs)
throws XNIException { throws XNIException {
if (getState() == STATE_NORMAL_PROCESSING) { if (getState() == STATE_NORMAL_PROCESSING) {
@ -1117,6 +1139,7 @@ public class XIncludeHandler
} }
} }
@Override
public void ignorableWhitespace(XMLString text, Augmentations augs) public void ignorableWhitespace(XMLString text, Augmentations augs)
throws XNIException { throws XNIException {
if (fDocumentHandler != null if (fDocumentHandler != null
@ -1126,6 +1149,7 @@ public class XIncludeHandler
} }
} }
@Override
public void startCDATA(Augmentations augs) throws XNIException { public void startCDATA(Augmentations augs) throws XNIException {
if (fDocumentHandler != null if (fDocumentHandler != null
&& getState() == STATE_NORMAL_PROCESSING && getState() == STATE_NORMAL_PROCESSING
@ -1134,6 +1158,7 @@ public class XIncludeHandler
} }
} }
@Override
public void endCDATA(Augmentations augs) throws XNIException { public void endCDATA(Augmentations augs) throws XNIException {
if (fDocumentHandler != null if (fDocumentHandler != null
&& getState() == STATE_NORMAL_PROCESSING && getState() == STATE_NORMAL_PROCESSING
@ -1142,6 +1167,7 @@ public class XIncludeHandler
} }
} }
@Override
public void endDocument(Augmentations augs) throws XNIException { public void endDocument(Augmentations augs) throws XNIException {
if (isRootDocument()) { if (isRootDocument()) {
if (!fSeenRootElement) { if (!fSeenRootElement) {
@ -1153,10 +1179,12 @@ public class XIncludeHandler
} }
} }
@Override
public void setDocumentSource(XMLDocumentSource source) { public void setDocumentSource(XMLDocumentSource source) {
fDocumentSource = source; fDocumentSource = source;
} }
@Override
public XMLDocumentSource getDocumentSource() { public XMLDocumentSource getDocumentSource() {
return fDocumentSource; return fDocumentSource;
} }
@ -1168,6 +1196,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (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) * @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( public void attributeDecl(
String elementName, String elementName,
String attributeName, String attributeName,
@ -1194,6 +1223,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (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) * @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( public void elementDecl(
String name, String name,
String contentModel, String contentModel,
@ -1207,6 +1237,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endAttlist(com.sun.org.apache.xerces.internal.xni.Augmentations) * @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 { public void endAttlist(Augmentations augmentations) throws XNIException {
if (fDTDHandler != null) { if (fDTDHandler != null) {
fDTDHandler.endAttlist(augmentations); fDTDHandler.endAttlist(augmentations);
@ -1216,6 +1247,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endConditional(com.sun.org.apache.xerces.internal.xni.Augmentations) * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endConditional(com.sun.org.apache.xerces.internal.xni.Augmentations)
*/ */
@Override
public void endConditional(Augmentations augmentations) public void endConditional(Augmentations augmentations)
throws XNIException { throws XNIException {
if (fDTDHandler != null) { if (fDTDHandler != null) {
@ -1226,6 +1258,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endDTD(com.sun.org.apache.xerces.internal.xni.Augmentations) * @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 { public void endDTD(Augmentations augmentations) throws XNIException {
if (fDTDHandler != null) { if (fDTDHandler != null) {
fDTDHandler.endDTD(augmentations); fDTDHandler.endDTD(augmentations);
@ -1236,6 +1269,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endExternalSubset(com.sun.org.apache.xerces.internal.xni.Augmentations) * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endExternalSubset(com.sun.org.apache.xerces.internal.xni.Augmentations)
*/ */
@Override
public void endExternalSubset(Augmentations augmentations) public void endExternalSubset(Augmentations augmentations)
throws XNIException { throws XNIException {
if (fDTDHandler != null) { if (fDTDHandler != null) {
@ -1246,6 +1280,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endParameterEntity(java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations) * @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) public void endParameterEntity(String name, Augmentations augmentations)
throws XNIException { throws XNIException {
if (fDTDHandler != null) { if (fDTDHandler != null) {
@ -1256,6 +1291,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (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) * @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( public void externalEntityDecl(
String name, String name,
XMLResourceIdentifier identifier, XMLResourceIdentifier identifier,
@ -1269,6 +1305,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#getDTDSource() * @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#getDTDSource()
*/ */
@Override
public XMLDTDSource getDTDSource() { public XMLDTDSource getDTDSource() {
return fDTDSource; return fDTDSource;
} }
@ -1276,6 +1313,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (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) * @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) public void ignoredCharacters(XMLString text, Augmentations augmentations)
throws XNIException { throws XNIException {
if (fDTDHandler != null) { if (fDTDHandler != null) {
@ -1286,6 +1324,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (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) * @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( public void internalEntityDecl(
String name, String name,
XMLString text, XMLString text,
@ -1304,6 +1343,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (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) * @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( public void notationDecl(
String name, String name,
XMLResourceIdentifier identifier, XMLResourceIdentifier identifier,
@ -1318,6 +1358,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#setDTDSource(com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource) * @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) { public void setDTDSource(XMLDTDSource source) {
fDTDSource = source; fDTDSource = source;
} }
@ -1325,6 +1366,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startAttlist(java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations) * @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) public void startAttlist(String elementName, Augmentations augmentations)
throws XNIException { throws XNIException {
if (fDTDHandler != null) { if (fDTDHandler != null) {
@ -1335,6 +1377,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startConditional(short, com.sun.org.apache.xerces.internal.xni.Augmentations) * @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) public void startConditional(short type, Augmentations augmentations)
throws XNIException { throws XNIException {
if (fDTDHandler != null) { if (fDTDHandler != null) {
@ -1345,6 +1388,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (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) * @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) public void startDTD(XMLLocator locator, Augmentations augmentations)
throws XNIException { throws XNIException {
fInDTD = true; fInDTD = true;
@ -1356,6 +1400,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (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) * @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( public void startExternalSubset(
XMLResourceIdentifier identifier, XMLResourceIdentifier identifier,
Augmentations augmentations) Augmentations augmentations)
@ -1368,6 +1413,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (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) * @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( public void startParameterEntity(
String name, String name,
XMLResourceIdentifier identifier, XMLResourceIdentifier identifier,
@ -1386,6 +1432,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (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) * @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( public void unparsedEntityDecl(
String name, String name,
XMLResourceIdentifier identifier, XMLResourceIdentifier identifier,
@ -1405,6 +1452,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource#getDTDHandler() * @see com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource#getDTDHandler()
*/ */
@Override
public XMLDTDHandler getDTDHandler() { public XMLDTDHandler getDTDHandler() {
return fDTDHandler; return fDTDHandler;
} }
@ -1412,6 +1460,7 @@ public class XIncludeHandler
/* (non-Javadoc) /* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource#setDTDHandler(com.sun.org.apache.xerces.internal.xni.XMLDTDHandler) * @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) { public void setDTDHandler(XMLDTDHandler handler) {
fDTDHandler = handler; fDTDHandler = handler;
} }
@ -1641,11 +1690,10 @@ public class XIncludeHandler
fNamespaceContext); fNamespaceContext);
((XPointerHandler)fXPtrProcessor).setProperty(XINCLUDE_FIXUP_BASE_URIS, ((XPointerHandler)fXPtrProcessor).setProperty(XINCLUDE_FIXUP_BASE_URIS,
new Boolean(fFixupBaseURIs)); fFixupBaseURIs);
((XPointerHandler)fXPtrProcessor).setProperty( ((XPointerHandler)fXPtrProcessor).setProperty(
XINCLUDE_FIXUP_LANGUAGE, XINCLUDE_FIXUP_LANGUAGE, fFixupLanguage);
new Boolean (fFixupLanguage));
if (fErrorReporter != null) if (fErrorReporter != null)
((XPointerHandler)fXPtrProcessor).setProperty(ERROR_REPORTER, fErrorReporter); ((XPointerHandler)fXPtrProcessor).setProperty(ERROR_REPORTER, fErrorReporter);
@ -2119,14 +2167,14 @@ public class XIncludeHandler
/** Check whether the scheme components are equal. */ /** Check whether the scheme components are equal. */
final String baseScheme = base.getScheme(); final String baseScheme = base.getScheme();
final String literalScheme = uri.getScheme(); final String literalScheme = uri.getScheme();
if (!isEqual(baseScheme, literalScheme)) { if (!Objects.equals(baseScheme, literalScheme)) {
return relativeURI; return relativeURI;
} }
/** Check whether the authority components are equal. */ /** Check whether the authority components are equal. */
final String baseAuthority = base.getAuthority(); final String baseAuthority = base.getAuthority();
final String literalAuthority = uri.getAuthority(); final String literalAuthority = uri.getAuthority();
if (!isEqual(baseAuthority, literalAuthority)) { if (!Objects.equals(baseAuthority, literalAuthority)) {
return uri.getSchemeSpecificPart(); return uri.getSchemeSpecificPart();
} }
@ -2139,7 +2187,7 @@ public class XIncludeHandler
final String literalQuery = uri.getQueryString(); final String literalQuery = uri.getQueryString();
final String literalFragment = uri.getFragment(); final String literalFragment = uri.getFragment();
if (literalQuery != null || literalFragment != null) { if (literalQuery != null || literalFragment != null) {
StringBuffer buffer = new StringBuffer(); final StringBuilder buffer = new StringBuilder();
if (literalPath != null) { if (literalPath != null) {
buffer.append(literalPath); buffer.append(literalPath);
} }
@ -2650,15 +2698,15 @@ public class XIncludeHandler
// equals() returns true if two Notations have the same name. // equals() returns true if two Notations have the same name.
// Useful for searching Vectors for notations with the same name // Useful for searching Vectors for notations with the same name
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { return obj == this || obj instanceof Notation
return false; && Objects.equals(name, ((Notation)obj).name);
} }
if (obj instanceof Notation) {
Notation other = (Notation)obj; @Override
return name.equals(other.name); public int hashCode() {
} return Objects.hashCode(name);
return false;
} }
// from 4.5.2 // from 4.5.2
@ -2671,16 +2719,12 @@ public class XIncludeHandler
public boolean isDuplicate(Object obj) { public boolean isDuplicate(Object obj) {
if (obj != null && obj instanceof Notation) { if (obj != null && obj instanceof Notation) {
Notation other = (Notation)obj; Notation other = (Notation)obj;
return name.equals(other.name) return Objects.equals(name, other.name)
&& isEqual(publicId, other.publicId) && Objects.equals(publicId, other.publicId)
&& isEqual(expandedSystemId, other.expandedSystemId); && Objects.equals(expandedSystemId, other.expandedSystemId);
} }
return false; 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. // 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. // equals() returns true if two UnparsedEntities have the same name.
// Useful for searching Vectors for entities with the same name // Useful for searching Vectors for entities with the same name
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { return obj == this || obj instanceof UnparsedEntity
return false; && Objects.equals(name, ((UnparsedEntity)obj).name);
} }
if (obj instanceof UnparsedEntity) {
UnparsedEntity other = (UnparsedEntity)obj; @Override
return name.equals(other.name); public int hashCode() {
} return Objects.hashCode(name);
return false;
} }
// from 4.5.1: // from 4.5.1:
@ -2717,17 +2761,13 @@ public class XIncludeHandler
public boolean isDuplicate(Object obj) { public boolean isDuplicate(Object obj) {
if (obj != null && obj instanceof UnparsedEntity) { if (obj != null && obj instanceof UnparsedEntity) {
UnparsedEntity other = (UnparsedEntity)obj; UnparsedEntity other = (UnparsedEntity)obj;
return name.equals(other.name) return Objects.equals(name, other.name)
&& isEqual(publicId, other.publicId) && Objects.equals(publicId, other.publicId)
&& isEqual(expandedSystemId, other.expandedSystemId) && Objects.equals(expandedSystemId, other.expandedSystemId)
&& isEqual(notation, other.notation); && Objects.equals(notation, other.notation);
} }
return false; 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 // The following methods are used for XML Base processing
@ -2917,17 +2957,13 @@ public class XIncludeHandler
return httpSource; return httpSource;
} }
private boolean isEqual(String one, String two) {
return (one == two || (one != null && one.equals(two)));
}
// which ASCII characters need to be escaped // 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 // 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 // the second hex character if a character needs to be escaped
private static char gAfterEscaping2[] = new char[128]; private static final char gAfterEscaping2[] = new char[128];
private static char[] gHexChs = {'0', '1', '2', '3', '4', '5', '6', '7', private static final char[] gHexChs = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
// initialize the above 3 arrays // initialize the above 3 arrays
static { static {
@ -2957,7 +2993,7 @@ public class XIncludeHandler
private String escapeHref(String href) { private String escapeHref(String href) {
int len = href.length(); int len = href.length();
int ch; int ch;
StringBuffer buffer = new StringBuffer(len*3); final StringBuilder buffer = new StringBuilder(len*3);
// for each character in the href // for each character in the href
int i = 0; 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.DTM;
import com.sun.org.apache.xml.internal.dtm.DTMDOMException; import com.sun.org.apache.xml.internal.dtm.DTMDOMException;
import com.sun.org.apache.xpath.internal.NodeSet; import com.sun.org.apache.xpath.internal.NodeSet;
import java.util.Objects;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection; 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. * @return true if the given node has the same handle as this node.
*/ */
@Override
public final boolean equals(Object node) public final boolean equals(Object node)
{ {
try
{
// DTMNodeProxy dtmp = (DTMNodeProxy)node; // DTMNodeProxy dtmp = (DTMNodeProxy)node;
// return (dtmp.node == this.node); // return (dtmp.node == this.node);
// Patch attributed to Gary L Peskin <garyp@firstech.com> // Patch attributed to Gary L Peskin <garyp@firstech.com>
return equals((Node) node); return node instanceof Node && equals((Node) node);
}
catch (ClassCastException cce)
{
return false;
} }
@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 * @see org.w3c.dom.Node
*/ */
@Override
public final String getNodeName() public final String getNodeName()
{ {
return dtm.getNodeName(node); return dtm.getNodeName(node);
@ -199,6 +201,7 @@ public class DTMNodeProxy
* *
* *
*/ */
@Override
public final String getTarget() public final String getTarget()
{ {
return dtm.getNodeName(node); return dtm.getNodeName(node);
@ -209,6 +212,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Node as of DOM Level 2 * @see org.w3c.dom.Node as of DOM Level 2
*/ */
@Override
public final String getLocalName() public final String getLocalName()
{ {
return dtm.getLocalName(node); return dtm.getLocalName(node);
@ -218,6 +222,7 @@ public class DTMNodeProxy
* @return The prefix for this node. * @return The prefix for this node.
* @see org.w3c.dom.Node as of DOM Level 2 * @see org.w3c.dom.Node as of DOM Level 2
*/ */
@Override
public final String getPrefix() public final String getPrefix()
{ {
return dtm.getPrefix(node); return dtm.getPrefix(node);
@ -230,6 +235,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Node as of DOM Level 2 -- DTMNodeProxy is read-only * @see org.w3c.dom.Node as of DOM Level 2 -- DTMNodeProxy is read-only
*/ */
@Override
public final void setPrefix(String prefix) throws DOMException public final void setPrefix(String prefix) throws DOMException
{ {
throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); 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 * @see org.w3c.dom.Node as of DOM Level 2
*/ */
@Override
public final String getNamespaceURI() public final String getNamespaceURI()
{ {
return dtm.getNamespaceURI(node); return dtm.getNamespaceURI(node);
@ -277,6 +284,7 @@ public class DTMNodeProxy
* @return false * @return false
* @see org.w3c.dom.Node as of DOM Level 2 * @see org.w3c.dom.Node as of DOM Level 2
*/ */
@Override
public final boolean isSupported(String feature, String version) public final boolean isSupported(String feature, String version)
{ {
return implementation.hasFeature(feature,version); return implementation.hasFeature(feature,version);
@ -290,6 +298,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Node * @see org.w3c.dom.Node
*/ */
@Override
public final String getNodeValue() throws DOMException public final String getNodeValue() throws DOMException
{ {
return dtm.getNodeValue(node); return dtm.getNodeValue(node);
@ -312,6 +321,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Node -- DTMNodeProxy is read-only * @see org.w3c.dom.Node -- DTMNodeProxy is read-only
*/ */
@Override
public final void setNodeValue(String nodeValue) throws DOMException public final void setNodeValue(String nodeValue) throws DOMException
{ {
throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
@ -322,6 +332,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Node * @see org.w3c.dom.Node
*/ */
@Override
public final short getNodeType() public final short getNodeType()
{ {
return (short) dtm.getNodeType(node); return (short) dtm.getNodeType(node);
@ -332,6 +343,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Node * @see org.w3c.dom.Node
*/ */
@Override
public final Node getParentNode() public final Node getParentNode()
{ {
@ -361,6 +373,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Node * @see org.w3c.dom.Node
*/ */
@Override
public final NodeList getChildNodes() public final NodeList getChildNodes()
{ {
@ -377,6 +390,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Node * @see org.w3c.dom.Node
*/ */
@Override
public final Node getFirstChild() public final Node getFirstChild()
{ {
@ -390,6 +404,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Node * @see org.w3c.dom.Node
*/ */
@Override
public final Node getLastChild() public final Node getLastChild()
{ {
@ -403,6 +418,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Node * @see org.w3c.dom.Node
*/ */
@Override
public final Node getPreviousSibling() public final Node getPreviousSibling()
{ {
@ -416,6 +432,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Node * @see org.w3c.dom.Node
*/ */
@Override
public final Node getNextSibling() public final Node getNextSibling()
{ {
@ -435,6 +452,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Node * @see org.w3c.dom.Node
*/ */
@Override
public final NamedNodeMap getAttributes() public final NamedNodeMap getAttributes()
{ {
@ -448,6 +466,7 @@ public class DTMNodeProxy
* @param name * @param name
* *
*/ */
@Override
public boolean hasAttribute(String name) public boolean hasAttribute(String name)
{ {
return DTM.NULL != dtm.getAttributeNode(node,null,name); return DTM.NULL != dtm.getAttributeNode(node,null,name);
@ -462,6 +481,7 @@ public class DTMNodeProxy
* *
* *
*/ */
@Override
public boolean hasAttributeNS(String namespaceURI, String localName) public boolean hasAttributeNS(String namespaceURI, String localName)
{ {
return DTM.NULL != dtm.getAttributeNode(node,namespaceURI,localName); return DTM.NULL != dtm.getAttributeNode(node,namespaceURI,localName);
@ -472,6 +492,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Node * @see org.w3c.dom.Node
*/ */
@Override
public final Document getOwnerDocument() public final Document getOwnerDocument()
{ {
// Note that this uses the DOM-compatable version of the call // Note that this uses the DOM-compatable version of the call
@ -488,6 +509,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Node -- DTMNodeProxy is read-only * @see org.w3c.dom.Node -- DTMNodeProxy is read-only
*/ */
@Override
public final Node insertBefore(Node newChild, Node refChild) public final Node insertBefore(Node newChild, Node refChild)
throws DOMException throws DOMException
{ {
@ -504,6 +526,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Node -- DTMNodeProxy is read-only * @see org.w3c.dom.Node -- DTMNodeProxy is read-only
*/ */
@Override
public final Node replaceChild(Node newChild, Node oldChild) public final Node replaceChild(Node newChild, Node oldChild)
throws DOMException throws DOMException
{ {
@ -519,6 +542,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Node -- DTMNodeProxy is read-only * @see org.w3c.dom.Node -- DTMNodeProxy is read-only
*/ */
@Override
public final Node removeChild(Node oldChild) throws DOMException public final Node removeChild(Node oldChild) throws DOMException
{ {
throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
@ -533,6 +557,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Node -- DTMNodeProxy is read-only * @see org.w3c.dom.Node -- DTMNodeProxy is read-only
*/ */
@Override
public final Node appendChild(Node newChild) throws DOMException public final Node appendChild(Node newChild) throws DOMException
{ {
throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR); throw new DTMDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR);
@ -543,6 +568,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Node * @see org.w3c.dom.Node
*/ */
@Override
public final boolean hasChildNodes() public final boolean hasChildNodes()
{ {
return (DTM.NULL != dtm.getFirstChild(node)); return (DTM.NULL != dtm.getFirstChild(node));
@ -555,6 +581,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Node -- DTMNodeProxy is read-only * @see org.w3c.dom.Node -- DTMNodeProxy is read-only
*/ */
@Override
public final Node cloneNode(boolean deep) public final Node cloneNode(boolean deep)
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -565,6 +592,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Document * @see org.w3c.dom.Document
*/ */
@Override
public final DocumentType getDoctype() public final DocumentType getDoctype()
{ {
return null; return null;
@ -575,6 +603,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Document * @see org.w3c.dom.Document
*/ */
@Override
public final DOMImplementation getImplementation() public final DOMImplementation getImplementation()
{ {
return implementation; return implementation;
@ -587,6 +616,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Document * @see org.w3c.dom.Document
*/ */
@Override
public final Element getDocumentElement() public final Element getDocumentElement()
{ {
int dochandle=dtm.getDocument(); int dochandle=dtm.getDocument();
@ -634,6 +664,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Document * @see org.w3c.dom.Document
*/ */
@Override
public final Element createElement(String tagName) throws DOMException public final Element createElement(String tagName) throws DOMException
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -644,6 +675,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Document * @see org.w3c.dom.Document
*/ */
@Override
public final DocumentFragment createDocumentFragment() public final DocumentFragment createDocumentFragment()
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -656,6 +688,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Document * @see org.w3c.dom.Document
*/ */
@Override
public final Text createTextNode(String data) public final Text createTextNode(String data)
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -668,6 +701,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Document * @see org.w3c.dom.Document
*/ */
@Override
public final Comment createComment(String data) public final Comment createComment(String data)
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -682,6 +716,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Document * @see org.w3c.dom.Document
*/ */
@Override
public final CDATASection createCDATASection(String data) public final CDATASection createCDATASection(String data)
throws DOMException throws DOMException
{ {
@ -698,6 +733,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Document * @see org.w3c.dom.Document
*/ */
@Override
public final ProcessingInstruction createProcessingInstruction( public final ProcessingInstruction createProcessingInstruction(
String target, String data) throws DOMException String target, String data) throws DOMException
{ {
@ -713,6 +749,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Document * @see org.w3c.dom.Document
*/ */
@Override
public final Attr createAttribute(String name) throws DOMException public final Attr createAttribute(String name) throws DOMException
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -727,6 +764,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Document * @see org.w3c.dom.Document
*/ */
@Override
public final EntityReference createEntityReference(String name) public final EntityReference createEntityReference(String name)
throws DOMException throws DOMException
{ {
@ -739,6 +777,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Document * @see org.w3c.dom.Document
*/ */
@Override
public final NodeList getElementsByTagName(String tagname) public final NodeList getElementsByTagName(String tagname)
{ {
Vector listVector = new Vector(); Vector listVector = new Vector();
@ -819,6 +858,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Document as of DOM Level 2 -- DTMNodeProxy is read-only * @see org.w3c.dom.Document as of DOM Level 2 -- DTMNodeProxy is read-only
*/ */
@Override
public final Node importNode(Node importedNode, boolean deep) public final Node importNode(Node importedNode, boolean deep)
throws DOMException throws DOMException
{ {
@ -835,6 +875,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Document as of DOM Level 2 * @see org.w3c.dom.Document as of DOM Level 2
*/ */
@Override
public final Element createElementNS( public final Element createElementNS(
String namespaceURI, String qualifiedName) throws DOMException String namespaceURI, String qualifiedName) throws DOMException
{ {
@ -851,6 +892,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Document as of DOM Level 2 * @see org.w3c.dom.Document as of DOM Level 2
*/ */
@Override
public final Attr createAttributeNS( public final Attr createAttributeNS(
String namespaceURI, String qualifiedName) throws DOMException String namespaceURI, String qualifiedName) throws DOMException
{ {
@ -865,6 +907,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Document as of DOM Level 2 * @see org.w3c.dom.Document as of DOM Level 2
*/ */
@Override
public final NodeList getElementsByTagNameNS(String namespaceURI, public final NodeList getElementsByTagNameNS(String namespaceURI,
String localName) String localName)
{ {
@ -952,6 +995,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Document as of DOM Level 2 * @see org.w3c.dom.Document as of DOM Level 2
*/ */
@Override
public final Element getElementById(String elementId) public final Element getElementById(String elementId)
{ {
return (Element) dtm.getNode(dtm.getElementById(elementId)); return (Element) dtm.getNode(dtm.getElementById(elementId));
@ -966,6 +1010,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Text * @see org.w3c.dom.Text
*/ */
@Override
public final Text splitText(int offset) throws DOMException public final Text splitText(int offset) throws DOMException
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -978,6 +1023,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.CharacterData * @see org.w3c.dom.CharacterData
*/ */
@Override
public final String getData() throws DOMException public final String getData() throws DOMException
{ {
return dtm.getNodeValue(node); return dtm.getNodeValue(node);
@ -990,6 +1036,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.CharacterData * @see org.w3c.dom.CharacterData
*/ */
@Override
public final void setData(String data) throws DOMException public final void setData(String data) throws DOMException
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1000,6 +1047,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.CharacterData * @see org.w3c.dom.CharacterData
*/ */
@Override
public final int getLength() public final int getLength()
{ {
// %OPT% This should do something smarter? // %OPT% This should do something smarter?
@ -1016,6 +1064,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.CharacterData * @see org.w3c.dom.CharacterData
*/ */
@Override
public final String substringData(int offset, int count) throws DOMException public final String substringData(int offset, int count) throws DOMException
{ {
return getData().substring(offset,offset+count); return getData().substring(offset,offset+count);
@ -1028,6 +1077,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.CharacterData * @see org.w3c.dom.CharacterData
*/ */
@Override
public final void appendData(String arg) throws DOMException public final void appendData(String arg) throws DOMException
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1041,6 +1091,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.CharacterData * @see org.w3c.dom.CharacterData
*/ */
@Override
public final void insertData(int offset, String arg) throws DOMException public final void insertData(int offset, String arg) throws DOMException
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1054,6 +1105,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.CharacterData * @see org.w3c.dom.CharacterData
*/ */
@Override
public final void deleteData(int offset, int count) throws DOMException public final void deleteData(int offset, int count) throws DOMException
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1068,6 +1120,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.CharacterData * @see org.w3c.dom.CharacterData
*/ */
@Override
public final void replaceData(int offset, int count, String arg) public final void replaceData(int offset, int count, String arg)
throws DOMException throws DOMException
{ {
@ -1079,6 +1132,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Element * @see org.w3c.dom.Element
*/ */
@Override
public final String getTagName() public final String getTagName()
{ {
return dtm.getNodeName(node); return dtm.getNodeName(node);
@ -1091,12 +1145,13 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Element * @see org.w3c.dom.Element
*/ */
@Override
public final String getAttribute(String name) public final String getAttribute(String name)
{ {
DTMNamedNodeMap map = new DTMNamedNodeMap(dtm, node); DTMNamedNodeMap map = new DTMNamedNodeMap(dtm, node);
Node node = map.getNamedItem(name); Node n = map.getNamedItem(name);
return (null == node) ? EMPTYSTRING : node.getNodeValue(); } return (null == n) ? EMPTYSTRING : n.getNodeValue();
}
/** /**
* *
@ -1106,6 +1161,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Element * @see org.w3c.dom.Element
*/ */
@Override
public final void setAttribute(String name, String value) public final void setAttribute(String name, String value)
throws DOMException throws DOMException
{ {
@ -1119,6 +1175,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Element * @see org.w3c.dom.Element
*/ */
@Override
public final void removeAttribute(String name) throws DOMException public final void removeAttribute(String name) throws DOMException
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1131,9 +1188,9 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Element * @see org.w3c.dom.Element
*/ */
@Override
public final Attr getAttributeNode(String name) public final Attr getAttributeNode(String name)
{ {
DTMNamedNodeMap map = new DTMNamedNodeMap(dtm, node); DTMNamedNodeMap map = new DTMNamedNodeMap(dtm, node);
return (Attr)map.getNamedItem(name); return (Attr)map.getNamedItem(name);
} }
@ -1147,6 +1204,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Element * @see org.w3c.dom.Element
*/ */
@Override
public final Attr setAttributeNode(Attr newAttr) throws DOMException public final Attr setAttributeNode(Attr newAttr) throws DOMException
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1161,6 +1219,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Element * @see org.w3c.dom.Element
*/ */
@Override
public final Attr removeAttributeNode(Attr oldAttr) throws DOMException public final Attr removeAttributeNode(Attr oldAttr) throws DOMException
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1171,12 +1230,14 @@ public class DTMNodeProxy
* *
* *
*/ */
@Override
public boolean hasAttributes() public boolean hasAttributes()
{ {
return DTM.NULL != dtm.getFirstAttribute(node); return DTM.NULL != dtm.getFirstAttribute(node);
} }
/** @see org.w3c.dom.Element */ /** @see org.w3c.dom.Element */
@Override
public final void normalize() public final void normalize()
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1190,6 +1251,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Element * @see org.w3c.dom.Element
*/ */
@Override
public final String getAttributeNS(String namespaceURI, String localName) public final String getAttributeNS(String namespaceURI, String localName)
{ {
Node retNode = null; Node retNode = null;
@ -1208,6 +1270,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Element * @see org.w3c.dom.Element
*/ */
@Override
public final void setAttributeNS( public final void setAttributeNS(
String namespaceURI, String qualifiedName, String value) String namespaceURI, String qualifiedName, String value)
throws DOMException throws DOMException
@ -1223,6 +1286,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Element * @see org.w3c.dom.Element
*/ */
@Override
public final void removeAttributeNS(String namespaceURI, String localName) public final void removeAttributeNS(String namespaceURI, String localName)
throws DOMException throws DOMException
{ {
@ -1237,6 +1301,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Element * @see org.w3c.dom.Element
*/ */
@Override
public final Attr getAttributeNodeNS(String namespaceURI, String localName) public final Attr getAttributeNodeNS(String namespaceURI, String localName)
{ {
Attr retAttr = null; Attr retAttr = null;
@ -1256,6 +1321,7 @@ public class DTMNodeProxy
* @throws DOMException * @throws DOMException
* @see org.w3c.dom.Element * @see org.w3c.dom.Element
*/ */
@Override
public final Attr setAttributeNodeNS(Attr newAttr) throws DOMException public final Attr setAttributeNodeNS(Attr newAttr) throws DOMException
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1266,6 +1332,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Attr * @see org.w3c.dom.Attr
*/ */
@Override
public final String getName() public final String getName()
{ {
return dtm.getNodeName(node); return dtm.getNodeName(node);
@ -1276,6 +1343,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Attr * @see org.w3c.dom.Attr
*/ */
@Override
public final boolean getSpecified() public final boolean getSpecified()
{ {
// We really don't know which attributes might have come from the // We really don't know which attributes might have come from the
@ -1290,6 +1358,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Attr * @see org.w3c.dom.Attr
*/ */
@Override
public final String getValue() public final String getValue()
{ {
return dtm.getNodeValue(node); return dtm.getNodeValue(node);
@ -1300,6 +1369,7 @@ public class DTMNodeProxy
* @param value * @param value
* @see org.w3c.dom.Attr * @see org.w3c.dom.Attr
*/ */
@Override
public final void setValue(String value) public final void setValue(String value)
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1311,6 +1381,7 @@ public class DTMNodeProxy
* *
* @see org.w3c.dom.Attr as of DOM Level 2 * @see org.w3c.dom.Attr as of DOM Level 2
*/ */
@Override
public final Element getOwnerElement() public final Element getOwnerElement()
{ {
if (getNodeType() != Node.ATTRIBUTE_NODE) if (getNodeType() != Node.ATTRIBUTE_NODE)
@ -1331,9 +1402,9 @@ public class DTMNodeProxy
* *
* @throws DOMException * @throws DOMException
*/ */
@Override
public Node adoptNode(Node source) throws DOMException public Node adoptNode(Node source) throws DOMException
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
} }
@ -1348,9 +1419,9 @@ public class DTMNodeProxy
* *
* NEEDSDOC ($objectName$) @return * NEEDSDOC ($objectName$) @return
*/ */
@Override
public String getInputEncoding() public String getInputEncoding()
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
} }
@ -1383,7 +1454,6 @@ public class DTMNodeProxy
*/ */
public boolean getStandalone() public boolean getStandalone()
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
} }
@ -1418,9 +1488,9 @@ public class DTMNodeProxy
* *
* NEEDSDOC ($objectName$) @return * NEEDSDOC ($objectName$) @return
*/ */
@Override
public boolean getStrictErrorChecking() public boolean getStrictErrorChecking()
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
} }
@ -1439,6 +1509,7 @@ public class DTMNodeProxy
* *
* NEEDSDOC @param strictErrorChecking * NEEDSDOC @param strictErrorChecking
*/ */
@Override
public void setStrictErrorChecking(boolean strictErrorChecking) public void setStrictErrorChecking(boolean strictErrorChecking)
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
@ -1457,7 +1528,6 @@ public class DTMNodeProxy
*/ */
public String getVersion() public String getVersion()
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
} }
@ -1482,10 +1552,12 @@ public class DTMNodeProxy
*/ */
static class DTMNodeProxyImplementation implements DOMImplementation static class DTMNodeProxyImplementation implements DOMImplementation
{ {
@Override
public DocumentType createDocumentType(String qualifiedName,String publicId, String systemId) public DocumentType createDocumentType(String qualifiedName,String publicId, String systemId)
{ {
throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR); throw new DTMDOMException(DOMException.NOT_SUPPORTED_ERR);
} }
@Override
public Document createDocument(String namespaceURI,String qualfiedName,DocumentType doctype) public Document createDocument(String namespaceURI,String qualfiedName,DocumentType doctype)
{ {
// Could create a DTM... but why, when it'd have to be permanantly empty? // 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 * methods we can't support. I'm not sure which would be more useful
* to the caller. * to the caller.
*/ */
@Override
public boolean hasFeature(String feature,String version) public boolean hasFeature(String feature,String version)
{ {
if( ("CORE".equals(feature.toUpperCase()) || "XML".equals(feature.toUpperCase())) if( ("CORE".equals(feature.toUpperCase()) || "XML".equals(feature.toUpperCase()))
@ -1530,6 +1603,7 @@ public class DTMNodeProxy
* childNodes, etc. * childNodes, etc.
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public Object getFeature(String feature, String version) { public Object getFeature(String feature, String version) {
// we don't have any alternate node, either this node does the job // we don't have any alternate node, either this node does the job
// or we don't have anything that does // or we don't have anything that does
@ -1542,6 +1616,7 @@ public class DTMNodeProxy
//RAMESH : Pending proper implementation of DOM Level 3 //RAMESH : Pending proper implementation of DOM Level 3
@Override
public Object setUserData(String key, public Object setUserData(String key,
Object data, Object data,
UserDataHandler handler) { UserDataHandler handler) {
@ -1557,6 +1632,7 @@ public class DTMNodeProxy
* on this node, or <code>null</code> if there was none. * on this node, or <code>null</code> if there was none.
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public Object getUserData(String key) { public Object getUserData(String key) {
return getOwnerDocument().getUserData( key); return getOwnerDocument().getUserData( key);
} }
@ -1581,6 +1657,7 @@ public class DTMNodeProxy
* childNodes, etc. * childNodes, etc.
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public Object getFeature(String feature, String version) { public Object getFeature(String feature, String version) {
// we don't have any alternate node, either this node does the job // we don't have any alternate node, either this node does the job
// or we don't have anything that does // or we don't have anything that does
@ -1629,6 +1706,7 @@ public class DTMNodeProxy
* <code>true</code> otherwise <code>false</code>. * <code>true</code> otherwise <code>false</code>.
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public boolean isEqualNode(Node arg) { public boolean isEqualNode(Node arg) {
if (arg == this) { if (arg == this) {
return true; return true;
@ -1705,6 +1783,7 @@ public class DTMNodeProxy
* @return th URI for the namespace * @return th URI for the namespace
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public String lookupNamespaceURI(String specifiedPrefix) { public String lookupNamespaceURI(String specifiedPrefix) {
short type = this.getNodeType(); short type = this.getNodeType();
switch (type) { switch (type) {
@ -1797,6 +1876,7 @@ public class DTMNodeProxy
* is the default namespace, <code>false</code> otherwise. * is the default namespace, <code>false</code> otherwise.
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public boolean isDefaultNamespace(String namespaceURI){ public boolean isDefaultNamespace(String namespaceURI){
/* /*
// REVISIT: remove casts when DOM L3 becomes REC. // REVISIT: remove casts when DOM L3 becomes REC.
@ -1871,6 +1951,7 @@ public class DTMNodeProxy
* @param namespaceURI * @param namespaceURI
* @return the prefix for the namespace * @return the prefix for the namespace
*/ */
@Override
public String lookupPrefix(String namespaceURI){ public String lookupPrefix(String namespaceURI){
// REVISIT: When Namespaces 1.1 comes out this may not be true // REVISIT: When Namespaces 1.1 comes out this may not be true
@ -1932,6 +2013,7 @@ public class DTMNodeProxy
* <code>false</code> otherwise. * <code>false</code> otherwise.
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public boolean isSameNode(Node other) { public boolean isSameNode(Node other) {
// we do not use any wrapper so the answer is obvious // we do not use any wrapper so the answer is obvious
return this == other; return this == other;
@ -1982,6 +2064,7 @@ public class DTMNodeProxy
* platform. * platform.
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public void setTextContent(String textContent) public void setTextContent(String textContent)
throws DOMException { throws DOMException {
setNodeValue(textContent); setNodeValue(textContent);
@ -2031,6 +2114,7 @@ public class DTMNodeProxy
* platform. * platform.
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public String getTextContent() throws DOMException { public String getTextContent() throws DOMException {
return getNodeValue(); // overriden in some subclasses return getNodeValue(); // overriden in some subclasses
} }
@ -2043,6 +2127,7 @@ public class DTMNodeProxy
* node. * node.
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public short compareDocumentPosition(Node other) throws DOMException { public short compareDocumentPosition(Node other) throws DOMException {
return 0; return 0;
} }
@ -2071,6 +2156,7 @@ public class DTMNodeProxy
* Yes. (F2F 26 Sep 2001) * Yes. (F2F 26 Sep 2001)
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public String getBaseURI() { public String getBaseURI() {
return null; return null;
} }
@ -2079,6 +2165,7 @@ public class DTMNodeProxy
* DOM Level 3 * DOM Level 3
* Renaming node * Renaming node
*/ */
@Override
public Node renameNode(Node n, public Node renameNode(Node n,
String namespaceURI, String namespaceURI,
String name) String name)
@ -2091,6 +2178,7 @@ public class DTMNodeProxy
* DOM Level 3 * DOM Level 3
* Normalize document. * Normalize document.
*/ */
@Override
public void normalizeDocument(){ public void normalizeDocument(){
} }
@ -2099,6 +2187,7 @@ public class DTMNodeProxy
* invoked. * invoked.
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public DOMConfiguration getDomConfig(){ public DOMConfiguration getDomConfig(){
return null; return null;
} }
@ -2110,8 +2199,8 @@ public class DTMNodeProxy
/** /**
* DOM Level 3 * DOM Level 3
*/ */
@Override
public void setDocumentURI(String documentURI){ public void setDocumentURI(String documentURI){
fDocumentURI= documentURI; fDocumentURI= documentURI;
} }
@ -2123,6 +2212,7 @@ public class DTMNodeProxy
* over this attribute. * over this attribute.
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public String getDocumentURI(){ public String getDocumentURI(){
return fDocumentURI; return fDocumentURI;
} }
@ -2157,6 +2247,7 @@ public class DTMNodeProxy
/** /**
* DOM Level 3 * DOM Level 3
*/ */
@Override
public Text replaceWholeText(String content) public Text replaceWholeText(String content)
throws DOMException{ throws DOMException{
/* /*
@ -2210,6 +2301,7 @@ public class DTMNodeProxy
* nodes to this node, concatenated in document order. * nodes to this node, concatenated in document order.
* @since DOM Level 3 * @since DOM Level 3
*/ */
@Override
public String getWholeText(){ public String getWholeText(){
/* /*
@ -2235,13 +2327,11 @@ public class DTMNodeProxy
* Returns whether this text node contains whitespace in element content, * Returns whether this text node contains whitespace in element content,
* often abusively called "ignorable whitespace". * often abusively called "ignorable whitespace".
*/ */
@Override
public boolean isElementContentWhitespace(){ public boolean isElementContentWhitespace(){
return false; return false;
} }
/** /**
* NON-DOM: set the type of this attribute to be ID type. * 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 * DOM Level 3: register the given attribute node as an ID attribute
*/ */
@Override
public void setIdAttribute(String name, boolean makeId) { public void setIdAttribute(String name, boolean makeId) {
//PENDING //PENDING
} }
@ -2262,6 +2353,7 @@ public class DTMNodeProxy
/** /**
* DOM Level 3: register the given attribute node as an ID attribute * DOM Level 3: register the given attribute node as an ID attribute
*/ */
@Override
public void setIdAttributeNode(Attr at, boolean makeId) { public void setIdAttributeNode(Attr at, boolean makeId) {
//PENDING //PENDING
} }
@ -2269,6 +2361,7 @@ public class DTMNodeProxy
/** /**
* DOM Level 3: register the given attribute node as an ID attribute * DOM Level 3: register the given attribute node as an ID attribute
*/ */
@Override
public void setIdAttributeNS(String namespaceURI, String localName, public void setIdAttributeNS(String namespaceURI, String localName,
boolean makeId) { boolean makeId) {
//PENDING //PENDING
@ -2277,16 +2370,19 @@ public class DTMNodeProxy
* Method getSchemaTypeInfo. * Method getSchemaTypeInfo.
* @return TypeInfo * @return TypeInfo
*/ */
@Override
public TypeInfo getSchemaTypeInfo(){ public TypeInfo getSchemaTypeInfo(){
return null; //PENDING return null; //PENDING
} }
@Override
public boolean isId() { public boolean isId() {
return false; //PENDING return false; //PENDING
} }
private String xmlEncoding; private String xmlEncoding;
@Override
public String getXmlEncoding( ) { public String getXmlEncoding( ) {
return xmlEncoding; return xmlEncoding;
} }
@ -2295,23 +2391,25 @@ public class DTMNodeProxy
} }
private boolean xmlStandalone; private boolean xmlStandalone;
@Override
public boolean getXmlStandalone() { public boolean getXmlStandalone() {
return xmlStandalone; return xmlStandalone;
} }
@Override
public void setXmlStandalone(boolean xmlStandalone) throws DOMException { public void setXmlStandalone(boolean xmlStandalone) throws DOMException {
this.xmlStandalone = xmlStandalone; this.xmlStandalone = xmlStandalone;
} }
private String xmlVersion; private String xmlVersion;
@Override
public String getXmlVersion() { public String getXmlVersion() {
return xmlVersion; return xmlVersion;
} }
@Override
public void setXmlVersion(String xmlVersion) throws DOMException { public void setXmlVersion(String xmlVersion) throws DOMException {
this.xmlVersion = xmlVersion; this.xmlVersion = xmlVersion;
} }
} }

View file

@ -23,7 +23,7 @@
package com.sun.org.apache.xml.internal.serializer.utils; package com.sun.org.apache.xml.internal.serializer.utils;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.util.Objects;
/** /**
@ -863,7 +863,7 @@ final class URI
public String getSchemeSpecificPart() public String getSchemeSpecificPart()
{ {
StringBuffer schemespec = new StringBuffer(); final StringBuilder schemespec = new StringBuilder();
if (m_userinfo != null || m_host != null || m_port != -1) if (m_userinfo != null || m_host != null || m_port != -1)
{ {
@ -955,7 +955,7 @@ final class URI
boolean p_includeFragment) boolean p_includeFragment)
{ {
StringBuffer pathString = new StringBuffer(m_path); final StringBuilder pathString = new StringBuilder(m_path);
if (p_includeQueryString && m_queryString != null) 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 * @return true if p_test is a URI with all values equal to this
* URI, false otherwise * URI, false otherwise
*/ */
@Override
public boolean equals(Object p_test) public boolean equals(Object p_test)
{ {
@ -1343,15 +1344,29 @@ final class URI
return false; 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. * Get the URI as a string specification. See RFC 2396 Section 5.2.
* *
* @return the URI string specification * @return the URI string specification
*/ */
@Override
public String toString() public String toString()
{ {
StringBuffer uriSpecString = new StringBuffer(); final StringBuilder uriSpecString = new StringBuilder();
if (m_scheme != null) if (m_scheme != null)
{ {
@ -1543,7 +1558,7 @@ final class URI
* *
* *
* @param p_char the character to check * @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 * or 'A' and 'F', false otherwise
*/ */
private static boolean isHex(char p_char) 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.XMLErrorResources;
import com.sun.org.apache.xml.internal.res.XMLMessages; import com.sun.org.apache.xml.internal.res.XMLMessages;
import java.util.Objects;
/** /**
* A class to represent a Uniform Resource Identifier (URI). This class * A class to represent a Uniform Resource Identifier (URI). This class
@ -883,7 +884,7 @@ public class URI implements Serializable
public String getSchemeSpecificPart() public String getSchemeSpecificPart()
{ {
StringBuffer schemespec = new StringBuffer(); final StringBuilder schemespec = new StringBuilder();
if (m_userinfo != null || m_host != null || m_port != -1) if (m_userinfo != null || m_host != null || m_port != -1)
{ {
@ -975,7 +976,7 @@ public class URI implements Serializable
boolean p_includeFragment) boolean p_includeFragment)
{ {
StringBuffer pathString = new StringBuffer(m_path); final StringBuilder pathString = new StringBuilder(m_path);
if (p_includeQueryString && m_queryString != null) 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 * @return true if p_test is a URI with all values equal to this
* URI, false otherwise * URI, false otherwise
*/ */
@Override
public boolean equals(Object p_test) public boolean equals(Object p_test)
{ {
@ -1363,15 +1365,29 @@ public class URI implements Serializable
return false; 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. * Get the URI as a string specification. See RFC 2396 Section 5.2.
* *
* @return the URI string specification * @return the URI string specification
*/ */
@Override
public String toString() public String toString()
{ {
StringBuffer uriSpecString = new StringBuffer(); final StringBuilder uriSpecString = new StringBuilder();
if (m_scheme != null) 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.xml.internal.utils.QName;
import com.sun.org.apache.xpath.internal.objects.XObject; import com.sun.org.apache.xpath.internal.objects.XObject;
import java.util.Objects;
/** /**
* This class holds an instance of an argument on * This class holds an instance of an argument on
@ -182,7 +183,7 @@ public class Arg
{ {
m_qname = new QName(""); m_qname = new QName("");
; // so that string compares can be done. // so that string compares can be done.
m_val = null; m_val = null;
m_expression = null; m_expression = null;
m_isVisible = true; m_isVisible = true;
@ -223,6 +224,11 @@ public class Arg
m_expression = null; m_expression = null;
} }
@Override
public int hashCode() {
return Objects.hashCode(this.m_qname);
}
/** /**
* Equality function specialized for the variable name. If the argument * Equality function specialized for the variable name. If the argument
* is not a qname, it will deligate to the super class. * 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 * @return <code>true</code> if this object is the same as the obj
* argument; <code>false</code> otherwise. * argument; <code>false</code> otherwise.
*/ */
@Override
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
if(obj instanceof QName) if(obj instanceof QName)