true
if the character at start is 'Z', '+' or '-'.
+ * Return index of UTC char: 'Z', '+', '-'
+ *
+ * @param start
+ * @param end
+ * @return index of the UTC character that was found
+ */
+ protected int findUTCSign(String buffer, int start, int end) {
+ int c;
+ for (int i = start; i < end; i++) {
+ c = buffer.charAt(i);
+ if (c == 'Z' || c == '+' || c == '-') {
+ return i;
+ }
+
+ }
+ return -1;
+ }
+
+ /**
+ * Returns
+ * true
if the character at start is 'Z', '+' or '-'.
*/
protected final boolean isNextCharUTCSign(String buffer, int start, int end) {
if (start < end) {
@@ -510,135 +525,145 @@
return false;
}
- /**
- * Given start and end position, parses string value
- *
- * @param buffer string to parse
- * @param start start position
- * @param end end position
- * @return return integer representation of characters
- */
- protected int parseInt (String buffer, int start, int end)
- throws NumberFormatException{
- //REVISIT: more testing on this parsing needs to be done.
- int radix=10;
- int result = 0;
- int digit=0;
- int limit = -Integer.MAX_VALUE;
- int multmin = limit / radix;
- int i = start;
- do {
- digit = getDigit(buffer.charAt(i));
- if ( digit < 0 ) throw new NumberFormatException("'" + buffer + "' has wrong format");
- if ( result < multmin ) throw new NumberFormatException("'" + buffer + "' has wrong format");
- result *= radix;
- if ( result < limit + digit ) throw new NumberFormatException("'" + buffer + "' has wrong format");
- result -= digit;
+ /**
+ * Given start and end position, parses string value
+ *
+ * @param buffer string to parse
+ * @param start start position
+ * @param end end position
+ * @return return integer representation of characters
+ */
+ protected int parseInt(String buffer, int start, int end)
+ throws NumberFormatException {
+ //REVISIT: more testing on this parsing needs to be done.
+ int radix = 10;
+ int result = 0;
+ int digit = 0;
+ int limit = -Integer.MAX_VALUE;
+ int multmin = limit / radix;
+ int i = start;
+ do {
+ digit = getDigit(buffer.charAt(i));
+ if (digit < 0) {
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ if (result < multmin) {
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ result *= radix;
+ if (result < limit + digit) {
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ result -= digit;
- }while ( ++i < end );
- return -result;
+ } while (++i < end);
+ return -result;
+ }
+
+ // parse Year differently to support negative value.
+ protected int parseIntYear(String buffer, int end) {
+ int radix = 10;
+ int result = 0;
+ boolean negative = false;
+ int i = 0;
+ int limit;
+ int multmin;
+ int digit = 0;
+
+ if (buffer.charAt(0) == '-') {
+ negative = true;
+ limit = Integer.MIN_VALUE;
+ i++;
+
+ } else {
+ limit = -Integer.MAX_VALUE;
+ }
+ multmin = limit / radix;
+ while (i < end) {
+ digit = getDigit(buffer.charAt(i++));
+ if (digit < 0) {
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ if (result < multmin) {
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ result *= radix;
+ if (result < limit + digit) {
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ result -= digit;
}
- // parse Year differently to support negative value.
- protected int parseIntYear (String buffer, int end){
- int radix=10;
- int result = 0;
- boolean negative = false;
- int i=0;
- int limit;
- int multmin;
- int digit=0;
+ if (negative) {
+ if (i > 1) {
+ return result;
+ } else {
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ }
+ return -result;
- if (buffer.charAt(0) == '-'){
- negative = true;
- limit = Integer.MIN_VALUE;
- i++;
+ }
+
+ /**
+ * If timezone present - normalize dateTime [E Adding durations to
+ * dateTimes]
+ *
+ * @param date CCYY-MM-DDThh:mm:ss+03
+ */
+ protected void normalize(DateTimeData date) {
- }
- else{
- limit = -Integer.MAX_VALUE;
- }
- multmin = limit / radix;
- while (i < end)
- {
- digit = getDigit(buffer.charAt(i++));
- if (digit < 0) throw new NumberFormatException("'" + buffer + "' has wrong format");
- if (result < multmin) throw new NumberFormatException("'" + buffer + "' has wrong format");
- result *= radix;
- if (result < limit + digit) throw new NumberFormatException("'" + buffer + "' has wrong format");
- result -= digit;
- }
+ // REVISIT: we have common code in addDuration() for durations
+ // should consider reorganizing it.
+ //
+
+ //add minutes (from time zone)
+ int negate = -1;
- if (negative)
- {
- if (i > 1) return result;
- else throw new NumberFormatException("'" + buffer + "' has wrong format");
- }
- return -result;
+ if (DEBUG) {
+ System.out.println("==>date.minute" + date.minute);
+ System.out.println("==>date.timezoneMin" + date.timezoneMin);
+ }
+ int temp = date.minute + negate * date.timezoneMin;
+ int carry = fQuotient(temp, 60);
+ date.minute = mod(temp, 60, carry);
+ if (DEBUG) {
+ System.out.println("==>carry: " + carry);
+ }
+ //add hours
+ temp = date.hour + negate * date.timezoneHr + carry;
+ carry = fQuotient(temp, 24);
+ date.hour = mod(temp, 24, carry);
+ if (DEBUG) {
+ System.out.println("==>date.hour" + date.hour);
+ System.out.println("==>carry: " + carry);
}
- /**
- * If timezone present - normalize dateTime [E Adding durations to dateTimes]
- *
- * @param date CCYY-MM-DDThh:mm:ss+03
- */
- protected void normalize(DateTimeData date) {
-
- // REVISIT: we have common code in addDuration() for durations
- // should consider reorganizing it.
- //
-
- //add minutes (from time zone)
- int negate = -1;
-
- if ( DEBUG ) {
- System.out.println("==>date.minute"+date.minute);
- System.out.println("==>date.timezoneMin" +date.timezoneMin);
- }
- int temp = date.minute + negate * date.timezoneMin;
- int carry = fQuotient (temp, 60);
- date.minute= mod(temp, 60, carry);
+ date.day = date.day + carry;
- if ( DEBUG ) {
- System.out.println("==>carry: " + carry);
- }
- //add hours
- temp = date.hour + negate * date.timezoneHr + carry;
- carry = fQuotient(temp, 24);
- date.hour=mod(temp, 24, carry);
- if ( DEBUG ) {
- System.out.println("==>date.hour"+date.hour);
- System.out.println("==>carry: " + carry);
- }
-
- date.day=date.day+carry;
+ while (true) {
+ temp = maxDayInMonthFor(date.year, date.month);
+ if (date.day < 1) {
+ date.day = date.day + maxDayInMonthFor(date.year, date.month - 1);
+ carry = -1;
+ } else if (date.day > temp) {
+ date.day = date.day - temp;
+ carry = 1;
+ } else {
+ break;
+ }
+ temp = date.month + carry;
+ date.month = modulo(temp, 1, 13);
+ date.year = date.year + fQuotient(temp, 1, 13);
+ if (date.year == 0 && !Constants.SCHEMA_1_1_SUPPORT) {
+ date.year = (date.timezoneHr < 0 || date.timezoneMin < 0) ? 1 : -1;
+ }
+ }
+ date.utc = 'Z';
+ }
- while ( true ) {
- temp=maxDayInMonthFor(date.year, date.month);
- if (date.day<1) {
- date.day = date.day + maxDayInMonthFor(date.year, date.month-1);
- carry=-1;
- }
- else if ( date.day>temp ) {
- date.day=date.day-temp;
- carry=1;
- }
- else {
- break;
- }
- temp=date.month+carry;
- date.month=modulo(temp, 1, 13);
- date.year=date.year+fQuotient(temp, 1, 13);
- if(date.year == 0 && !Constants.SCHEMA_1_1_SUPPORT) {
- date.year = (date.timezoneHr < 0 || date.timezoneMin < 0)?1:-1;
- }
- }
- date.utc='Z';
- }
-
-
- /**
+ /**
* @param date
*/
protected void saveUnnormalized(DateTimeData date) {
@@ -651,154 +676,149 @@
}
/**
- * Resets object representation of date/time
- *
- * @param data date/time object
- */
- protected void resetDateObj(DateTimeData data) {
- data.year = 0;
- data.month = 0;
- data.day = 0;
- data.hour = 0;
- data.minute = 0;
- data.second = 0;
- data.utc = 0;
- data.timezoneHr = 0;
- data.timezoneMin = 0;
- }
+ * Resets object representation of date/time
+ *
+ * @param data date/time object
+ */
+ protected void resetDateObj(DateTimeData data) {
+ data.year = 0;
+ data.month = 0;
+ data.day = 0;
+ data.hour = 0;
+ data.minute = 0;
+ data.second = 0;
+ data.utc = 0;
+ data.timezoneHr = 0;
+ data.timezoneMin = 0;
+ }
- /**
- * Given {year,month} computes maximum
- * number of days for given month
- *
- * @param year
- * @param month
- * @return integer containg the number of days in a given month
- */
- protected int maxDayInMonthFor(int year, int month) {
- //validate days
- if ( month==4 || month==6 || month==9 || month==11 ) {
- return 30;
- }
- else if ( month==2 ) {
- if ( isLeapYear(year) ) {
- return 29;
- }
- else {
- return 28;
- }
- }
- else {
- return 31;
- }
+ /**
+ * Given {year,month} computes maximum number of days for given month
+ *
+ * @param year
+ * @param month
+ * @return integer containg the number of days in a given month
+ */
+ protected int maxDayInMonthFor(int year, int month) {
+ //validate days
+ if (month == 4 || month == 6 || month == 9 || month == 11) {
+ return 30;
+ } else if (month == 2) {
+ if (isLeapYear(year)) {
+ return 29;
+ } else {
+ return 28;
+ }
+ } else {
+ return 31;
}
+ }
- private boolean isLeapYear(int year) {
+ private boolean isLeapYear(int year) {
- //REVISIT: should we take care about Julian calendar?
- return((year%4 == 0) && ((year%100 != 0) || (year%400 == 0)));
- }
+ //REVISIT: should we take care about Julian calendar?
+ return ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)));
+ }
- //
- // help function described in W3C PR Schema [E Adding durations to dateTimes]
- //
- protected int mod (int a, int b, int quotient) {
- //modulo(a, b) = a - fQuotient(a,b)*b
- return (a - quotient*b) ;
- }
+ //
+ // help function described in W3C PR Schema [E Adding durations to dateTimes]
+ //
+ protected int mod(int a, int b, int quotient) {
+ //modulo(a, b) = a - fQuotient(a,b)*b
+ return (a - quotient * b);
+ }
- //
- // help function described in W3C PR Schema [E Adding durations to dateTimes]
- //
- protected int fQuotient (int a, int b) {
+ //
+ // help function described in W3C PR Schema [E Adding durations to dateTimes]
+ //
+ protected int fQuotient(int a, int b) {
- //fQuotient(a, b) = the greatest integer less than or equal to a/b
- return (int)Math.floor((float)a/b);
- }
+ //fQuotient(a, b) = the greatest integer less than or equal to a/b
+ return (int) Math.floor((float) a / b);
+ }
- //
- // help function described in W3C PR Schema [E Adding durations to dateTimes]
- //
- protected int modulo (int temp, int low, int high) {
- //modulo(a - low, high - low) + low
- int a = temp - low;
- int b = high - low;
- return (mod (a, b, fQuotient(a, b)) + low) ;
- }
+ //
+ // help function described in W3C PR Schema [E Adding durations to dateTimes]
+ //
+ protected int modulo(int temp, int low, int high) {
+ //modulo(a - low, high - low) + low
+ int a = temp - low;
+ int b = high - low;
+ return (mod(a, b, fQuotient(a, b)) + low);
+ }
- //
- // help function described in W3C PR Schema [E Adding durations to dateTimes]
- //
- protected int fQuotient (int temp, int low, int high) {
- //fQuotient(a - low, high - low)
+ //
+ // help function described in W3C PR Schema [E Adding durations to dateTimes]
+ //
+ protected int fQuotient(int temp, int low, int high) {
+ //fQuotient(a - low, high - low)
- return fQuotient(temp - low, high - low);
- }
-
+ return fQuotient(temp - low, high - low);
+ }
- protected String dateToString(DateTimeData date) {
- StringBuffer message = new StringBuffer(25);
- append(message, date.year, 4);
- message.append('-');
- append(message, date.month, 2);
- message.append('-');
- append(message, date.day, 2);
- message.append('T');
- append(message, date.hour, 2);
- message.append(':');
- append(message, date.minute, 2);
- message.append(':');
- append(message, date.second);
- append(message, (char)date.utc, 0);
- return message.toString();
- }
+ protected String dateToString(DateTimeData date) {
+ StringBuffer message = new StringBuffer(25);
+ append(message, date.year, 4);
+ message.append('-');
+ append(message, date.month, 2);
+ message.append('-');
+ append(message, date.day, 2);
+ message.append('T');
+ append(message, date.hour, 2);
+ message.append(':');
+ append(message, date.minute, 2);
+ message.append(':');
+ append(message, date.second);
+ append(message, (char) date.utc, 0);
+ return message.toString();
+ }
- protected final void append(StringBuffer message, int value, int nch) {
+ protected final void append(StringBuffer message, int value, int nch) {
if (value == Integer.MIN_VALUE) {
message.append(value);
return;
}
- if (value < 0) {
- message.append('-');
- value = -value;
- }
- if (nch == 4) {
- if (value < 10)
- message.append("000");
- else if (value < 100)
- message.append("00");
- else if (value < 1000)
- message.append('0');
- message.append(value);
- }
- else if (nch == 2) {
- if (value < 10)
- message.append('0');
- message.append(value);
- }
- else {
- if (value != 0)
- message.append((char)value);
- }
+ if (value < 0) {
+ message.append('-');
+ value = -value;
}
-
- protected final void append(StringBuffer message, double value) {
- if (value < 0) {
- message.append('-');
- value = -value;
+ if (nch == 4) {
+ if (value < 10) {
+ message.append("000");
+ } else if (value < 100) {
+ message.append("00");
+ } else if (value < 1000) {
+ message.append('0');
}
+ message.append(value);
+ } else if (nch == 2) {
if (value < 10) {
message.append('0');
}
- append2(message, value);
+ message.append(value);
+ } else {
+ if (value != 0) {
+ message.append((char) value);
+ }
}
+ }
+
+ protected final void append(StringBuffer message, double value) {
+ if (value < 0) {
+ message.append('-');
+ value = -value;
+ }
+ if (value < 10) {
+ message.append('0');
+ }
+ append2(message, value);
+ }
protected final void append2(StringBuffer message, double value) {
final int intValue = (int) value;
if (value == intValue) {
message.append(intValue);
- }
- else {
+ } else {
append3(message, value);
}
}
@@ -815,9 +835,8 @@
// Need to convert from scientific notation of the form
// n.nnn...E-N (N >= 4) to a normal decimal value.
try {
- exp = parseInt(d, eIndex+2, d.length());
- }
- // This should never happen.
+ exp = parseInt(d, eIndex + 2, d.length());
+ } // This should never happen.
// It's only possible if String.valueOf(double) is broken.
catch (Exception e) {
message.append(d);
@@ -843,14 +862,12 @@
message.append(c);
}
}
- }
- else {
+ } else {
// Need to convert from scientific notation of the form
// n.nnn...EN (N >= 7) to a normal decimal value.
try {
- exp = parseInt(d, eIndex+1, d.length());
- }
- // This should never happen.
+ exp = parseInt(d, eIndex + 1, d.length());
+ } // This should never happen.
// It's only possible if String.valueOf(double) is broken.
catch (Exception e) {
message.append(d);
@@ -873,174 +890,220 @@
}
}
- protected double parseSecond(String buffer, int start, int end)
- throws NumberFormatException {
- int dot = -1;
- for (int i = start; i < end; i++) {
- char ch = buffer.charAt(i);
- if (ch == '.')
- dot = i;
- else if (ch > '9' || ch < '0')
- throw new NumberFormatException("'" + buffer + "' has wrong format");
- }
- if (dot == -1) {
- if (start+2 != end)
- throw new NumberFormatException("'" + buffer + "' has wrong format");
- }
- else if (start+2 != dot || dot+1 == end) {
- throw new NumberFormatException("'" + buffer + "' has wrong format");
- }
- return Double.parseDouble(buffer.substring(start, end));
+ protected double parseSecond(String buffer, int start, int end)
+ throws NumberFormatException {
+ int dot = -1;
+ for (int i = start; i < end; i++) {
+ char ch = buffer.charAt(i);
+ if (ch == '.') {
+ dot = i;
+ } else if (ch > '9' || ch < '0') {
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
}
+ if (dot == -1) {
+ if (start + 2 != end) {
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ } else if (start + 2 != dot || dot + 1 == end) {
+ throw new NumberFormatException("'" + buffer + "' has wrong format");
+ }
+ return Double.parseDouble(buffer.substring(start, end));
+ }
- //
- //Private help functions
- //
+ //
+ //Private help functions
+ //
+ private void cloneDate(DateTimeData finalValue, DateTimeData tempDate) {
+ tempDate.year = finalValue.year;
+ tempDate.month = finalValue.month;
+ tempDate.day = finalValue.day;
+ tempDate.hour = finalValue.hour;
+ tempDate.minute = finalValue.minute;
+ tempDate.second = finalValue.second;
+ tempDate.utc = finalValue.utc;
+ tempDate.timezoneHr = finalValue.timezoneHr;
+ tempDate.timezoneMin = finalValue.timezoneMin;
+ }
- private void cloneDate (DateTimeData finalValue, DateTimeData tempDate) {
- tempDate.year = finalValue.year;
- tempDate.month = finalValue.month;
- tempDate.day = finalValue.day;
- tempDate.hour = finalValue.hour;
- tempDate.minute = finalValue.minute;
- tempDate.second = finalValue.second;
- tempDate.utc = finalValue.utc;
- tempDate.timezoneHr = finalValue.timezoneHr;
- tempDate.timezoneMin = finalValue.timezoneMin;
- }
+ /**
+ * Represents date time data
+ */
+ static final class DateTimeData implements XSDateTime {
- /**
- * Represents date time data
- */
- static final class DateTimeData implements XSDateTime {
- int year, month, day, hour, minute, utc;
- double second;
- int timezoneHr, timezoneMin;
+ int year, month, day, hour, minute, utc;
+ double second;
+ int timezoneHr, timezoneMin;
private String originalValue;
boolean normalized = true;
-
int unNormYear;
int unNormMonth;
int unNormDay;
int unNormHour;
int unNormMinute;
double unNormSecond;
+ // used for comparisons - to decide the 'interesting' portions of
+ // a date/time based data type.
+ int position;
+ // a pointer to the type that was used go generate this data
+ // 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.
+ final AbstractDateTimeDV type;
+ private volatile String canonical;
- // used for comparisons - to decide the 'interesting' portions of
- // a date/time based data type.
- int position;
- // a pointer to the type that was used go generate this data
- // 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.
- final AbstractDateTimeDV type;
- private String canonical;
- public DateTimeData(String originalValue, AbstractDateTimeDV type) {
+ public DateTimeData(String originalValue, AbstractDateTimeDV type) {
this.originalValue = originalValue;
- this.type = type;
- }
- public DateTimeData(int year, int month, int day, int hour, int minute,
- double second, int utc, String originalValue, boolean normalized, AbstractDateTimeDV type) {
- this.year = year;
- this.month = month;
- this.day = day;
- this.hour = hour;
- this.minute = minute;
- this.second = second;
- this.utc = utc;
- this.type = type;
+ this.type = type;
+ }
+
+ public DateTimeData(int year, int month, int day, int hour, int minute,
+ double second, int utc, String originalValue, boolean normalized, AbstractDateTimeDV type) {
+ this.year = year;
+ this.month = month;
+ this.day = day;
+ this.hour = hour;
+ this.minute = minute;
+ this.second = second;
+ this.utc = utc;
+ this.type = type;
this.originalValue = originalValue;
- }
- public boolean equals(Object obj) {
- if (!(obj instanceof DateTimeData))
- return false;
- return type.compareDates(this, (DateTimeData)obj, true)==0;
- }
- public synchronized String toString() {
- if (canonical == null) {
- canonical = type.dateToString(this);
- }
- return canonical;
- }
- /* (non-Javadoc)
- * @see org.apache.xerces.xs.datatypes.XSDateTime#getYear()
- */
- public int getYears() {
- if(type instanceof DurationDV)
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof DateTimeData)) {
+ return false;
+ }
+ return type.compareDates(this, (DateTimeData) obj, true) == 0;
+ }
+
+ // 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) {
+ canonical = type.dateToString(this);
+ }
+ return canonical;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getYear()
+ */
+
+ @Override
+ public int getYears() {
+ if (type instanceof DurationDV) {
return 0;
- return normalized?year:unNormYear;
- }
- /* (non-Javadoc)
- * @see org.apache.xerces.xs.datatypes.XSDateTime#getMonth()
- */
- public int getMonths() {
- if(type instanceof DurationDV) {
- return year*12 + month;
}
- return normalized?month:unNormMonth;
- }
- /* (non-Javadoc)
- * @see org.apache.xerces.xs.datatypes.XSDateTime#getDay()
- */
- public int getDays() {
- if(type instanceof DurationDV)
+ return normalized ? year : unNormYear;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getMonth()
+ */
+
+ @Override
+ public int getMonths() {
+ if (type instanceof DurationDV) {
+ return year * 12 + month;
+ }
+ return normalized ? month : unNormMonth;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getDay()
+ */
+
+ @Override
+ public int getDays() {
+ if (type instanceof DurationDV) {
return 0;
- return normalized?day:unNormDay;
- }
- /* (non-Javadoc)
- * @see org.apache.xerces.xs.datatypes.XSDateTime#getHour()
- */
- public int getHours() {
- if(type instanceof DurationDV)
- return 0;
- return normalized?hour:unNormHour;
- }
- /* (non-Javadoc)
- * @see org.apache.xerces.xs.datatypes.XSDateTime#getMinutes()
- */
- public int getMinutes() {
- if(type instanceof DurationDV)
+ }
+ return normalized ? day : unNormDay;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getHour()
+ */
+
+ @Override
+ public int getHours() {
+ if (type instanceof DurationDV) {
return 0;
- return normalized?minute:unNormMinute;
- }
- /* (non-Javadoc)
- * @see org.apache.xerces.xs.datatypes.XSDateTime#getSeconds()
- */
- public double getSeconds() {
- if(type instanceof DurationDV) {
- return day*24*60*60 + hour*60*60 + minute*60 + second;
+ }
+ return normalized ? hour : unNormHour;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getMinutes()
+ */
+
+ @Override
+ public int getMinutes() {
+ if (type instanceof DurationDV) {
+ return 0;
+ }
+ return normalized ? minute : unNormMinute;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getSeconds()
+ */
+
+ @Override
+ public double getSeconds() {
+ if (type instanceof DurationDV) {
+ return day * 24 * 60 * 60 + hour * 60 * 60 + minute * 60 + second;
}
- return normalized?second:unNormSecond;
- }
- /* (non-Javadoc)
- * @see org.apache.xerces.xs.datatypes.XSDateTime#hasTimeZone()
- */
- public boolean hasTimeZone() {
- return utc != 0;
- }
- /* (non-Javadoc)
- * @see org.apache.xerces.xs.datatypes.XSDateTime#getTimeZoneHours()
- */
- public int getTimeZoneHours() {
- return timezoneHr;
- }
- /* (non-Javadoc)
- * @see org.apache.xerces.xs.datatypes.XSDateTime#getTimeZoneMinutes()
- */
- public int getTimeZoneMinutes() {
- return timezoneMin;
- }
+ return normalized ? second : unNormSecond;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#hasTimeZone()
+ */
+
+ @Override
+ public boolean hasTimeZone() {
+ return utc != 0;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getTimeZoneHours()
+ */
+
+ @Override
+ public int getTimeZoneHours() {
+ return timezoneHr;
+ }
+ /* (non-Javadoc)
+ * @see org.apache.xerces.xs.datatypes.XSDateTime#getTimeZoneMinutes()
+ */
+
+ @Override
+ public int getTimeZoneMinutes() {
+ return timezoneMin;
+ }
/* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getLexicalValue()
*/
+
+ @Override
public String getLexicalValue() {
return originalValue;
}
/* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#normalize()
*/
+
+ @Override
public XSDateTime normalize() {
- if(!normalized) {
- DateTimeData dt = (DateTimeData)this.clone();
+ if (!normalized) {
+ DateTimeData dt = (DateTimeData) this.clone();
dt.normalized = true;
return dt;
}
@@ -1049,13 +1112,16 @@
/* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#isNormalized()
*/
+
+ @Override
public boolean isNormalized() {
return normalized;
}
+ @Override
public Object clone() {
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);
dt.canonical = this.canonical;
dt.position = position;
dt.timezoneHr = this.timezoneHr;
@@ -1072,16 +1138,19 @@
/* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getXMLGregorianCalendar()
*/
+ @Override
public XMLGregorianCalendar getXMLGregorianCalendar() {
return type.getXMLGregorianCalendar(this);
}
/* (non-Javadoc)
* @see org.apache.xerces.xs.datatypes.XSDateTime#getDuration()
*/
+
+ @Override
public Duration getDuration() {
return type.getDuration(this);
}
- }
+ }
protected XMLGregorianCalendar getXMLGregorianCalendar(DateTimeData data) {
return null;
diff -r 50528ec0ea37 -r d8d911c4e5d4 jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DecimalDV.java
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DecimalDV.java Fri May 10 09:23:22 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/DecimalDV.java Fri May 17 10:40:21 2013 +0200
@@ -26,6 +26,7 @@
import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException;
import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext;
import com.sun.org.apache.xerces.internal.xs.datatypes.XSDecimal;
+import java.util.Objects;
/**
* Represent the schema type "decimal"
@@ -38,10 +39,12 @@
*/
public class DecimalDV extends TypeValidator {
+ @Override
public final short getAllowedFacets(){
return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE | XSSimpleTypeDecl.FACET_MINEXCLUSIVE | XSSimpleTypeDecl.FACET_TOTALDIGITS | XSSimpleTypeDecl.FACET_FRACTIONDIGITS);
}
+ @Override
public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException {
try {
return new XDecimal(content);
@@ -50,20 +53,23 @@
}
}
+ @Override
public final int compare(Object value1, Object value2){
return ((XDecimal)value1).compareTo((XDecimal)value2);
}
+ @Override
public final int getTotalDigits(Object value){
return ((XDecimal)value).totalDigits;
}
+ @Override
public final int getFractionDigits(Object value){
return ((XDecimal)value).fracDigits;
}
// Avoid using the heavy-weight java.math.BigDecimal
- static class XDecimal implements XSDecimal {
+ static final class XDecimal implements XSDecimal {
// sign: 0 for vlaue 0; 1 for positive values; -1 for negative values
int sign = 1;
// total digits. >= 1
@@ -216,6 +222,8 @@
integer = true;
}
+
+ @Override
public boolean equals(Object val) {
if (val == this)
return true;
@@ -232,6 +240,19 @@
return intDigits == oval.intDigits && fracDigits == oval.fracDigits &&
ivalue.equals(oval.ivalue) && fvalue.equals(oval.fvalue);
}
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 17 * hash + this.sign;
+ if (this.sign == 0) return hash;
+ hash = 17 * hash + this.intDigits;
+ hash = 17 * hash + this.fracDigits;
+ hash = 17 * hash + Objects.hashCode(this.ivalue);
+ hash = 17 * hash + Objects.hashCode(this.fvalue);
+ return hash;
+ }
+
public int compareTo(XDecimal val) {
if (sign != val.sign)
return sign > val.sign ? 1 : -1;
@@ -248,7 +269,9 @@
ret = fvalue.compareTo(val.fvalue);
return ret == 0 ? 0 : (ret > 0 ? 1 : -1);
}
+
private String canonical;
+ @Override
public synchronized String toString() {
if (canonical == null) {
makeCanonical();
@@ -269,7 +292,7 @@
return;
}
// for -0.1, total digits is 1, so we need 3 extra spots
- StringBuffer buffer = new StringBuffer(totalDigits+3);
+ final StringBuilder buffer = new StringBuilder(totalDigits+3);
if (sign == -1)
buffer.append('-');
if (intDigits != 0)
@@ -288,6 +311,7 @@
canonical = buffer.toString();
}
+ @Override
public BigDecimal getBigDecimal() {
if (sign == 0) {
return new BigDecimal(BigInteger.ZERO);
@@ -295,6 +319,7 @@
return new BigDecimal(toString());
}
+ @Override
public BigInteger getBigInteger() throws NumberFormatException {
if (fracDigits != 0) {
throw new NumberFormatException();
@@ -308,6 +333,7 @@
return new BigInteger("-" + ivalue);
}
+ @Override
public long getLong() throws NumberFormatException {
if (fracDigits != 0) {
throw new NumberFormatException();
@@ -321,6 +347,7 @@
return Long.parseLong("-" + ivalue);
}
+ @Override
public int getInt() throws NumberFormatException {
if (fracDigits != 0) {
throw new NumberFormatException();
@@ -334,6 +361,7 @@
return Integer.parseInt("-" + ivalue);
}
+ @Override
public short getShort() throws NumberFormatException {
if (fracDigits != 0) {
throw new NumberFormatException();
@@ -347,6 +375,7 @@
return Short.parseShort("-" + ivalue);
}
+ @Override
public byte getByte() throws NumberFormatException {
if (fracDigits != 0) {
throw new NumberFormatException();
diff -r 50528ec0ea37 -r d8d911c4e5d4 jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/PrecisionDecimalDV.java
--- a/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/PrecisionDecimalDV.java Fri May 10 09:23:22 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/impl/dv/xs/PrecisionDecimalDV.java Fri May 17 10:40:21 2013 +0200
@@ -32,7 +32,7 @@
*/
class PrecisionDecimalDV extends TypeValidator {
- static class XPrecisionDecimal {
+ static final class XPrecisionDecimal {
// sign: 0 for absent; 1 for positive values; -1 for negative values (except in case of INF, -INF)
int sign = 1;
@@ -144,7 +144,71 @@
totalDigits = intDigits + fracDigits;
}
+ // Construct a canonical String representation of this number
+ // for the purpose of deriving a hashCode value compliant with
+ // equals.
+ // The toString representation will be:
+ // NaN for NaN, INF for +infinity, -INF for -infinity, 0 for zero,
+ // and [1-9].[0-9]*[1-9]?(E[1-9][0-9]*)? for other numbers.
+ private static String canonicalToStringForHashCode(String ivalue, String fvalue, int sign, int pvalue) {
+ if ("NaN".equals(ivalue)) {
+ return "NaN";
+ }
+ if ("INF".equals(ivalue)) {
+ return sign < 0 ? "-INF" : "INF";
+ }
+ final StringBuilder builder = new StringBuilder();
+ final int ilen = ivalue.length();
+ final int flen0 = fvalue.length();
+ int lastNonZero;
+ for (lastNonZero = flen0; lastNonZero > 0 ; lastNonZero--) {
+ if (fvalue.charAt(lastNonZero -1 ) != '0') break;
+ }
+ final int flen = lastNonZero;
+ int iStart;
+ int exponent = pvalue;
+ for (iStart = 0; iStart < ilen; iStart++) {
+ if (ivalue.charAt(iStart) != '0') break;
+ }
+ int fStart = 0;
+ if (iStart < ivalue.length()) {
+ builder.append(sign == -1 ? "-" : "");
+ builder.append(ivalue.charAt(iStart));
+ iStart++;
+ } else {
+ if (flen > 0) {
+ for (fStart = 0; fStart < flen; fStart++) {
+ if (fvalue.charAt(fStart) != '0') break;
+ }
+ if (fStart < flen) {
+ builder.append(sign == -1 ? "-" : "");
+ builder.append(fvalue.charAt(fStart));
+ exponent -= ++fStart;
+ } else {
+ return "0";
+ }
+ } else {
+ return "0";
+ }
+ }
+ if (iStart < ilen || fStart < flen) {
+ builder.append('.');
+ }
+ while (iStart < ilen) {
+ builder.append(ivalue.charAt(iStart++));
+ exponent++;
+ }
+ while (fStart < flen) {
+ builder.append(fvalue.charAt(fStart++));
+ }
+ if (exponent != 0) {
+ builder.append("E").append(exponent);
+ }
+ return builder.toString();
+ }
+
+ @Override
public boolean equals(Object val) {
if (val == this)
return true;
@@ -156,6 +220,20 @@
return this.compareTo(oval) == EQUAL;
}
+ @Override
+ public int hashCode() {
+ // There's nothing else we can use easily, because equals could
+ // return true for widely different representation of the
+ // same number - and we don't have any canonical representation.
+ // The problem here is that we must ensure that if two numbers
+ // are equals then their hash code must also be equals.
+ // hashCode for 1.01E1 should be the same as hashCode for 0.101E2
+ // So we call cannonicalToStringForHashCode - which implements an
+ // algorithm that invents a normalized string representation
+ // for this number, and we return a hash for that.
+ return canonicalToStringForHashCode(ivalue, fvalue, sign, pvalue).hashCode();
+ }
+
/**
* @return
*/
@@ -295,6 +373,7 @@
private String canonical;
+ @Override
public synchronized String toString() {
if (canonical == null) {
makeCanonical();
@@ -325,6 +404,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator#getAllowedFacets()
*/
+ @Override
public short getAllowedFacets() {
return ( XSSimpleTypeDecl.FACET_PATTERN | XSSimpleTypeDecl.FACET_WHITESPACE | XSSimpleTypeDecl.FACET_ENUMERATION |XSSimpleTypeDecl.FACET_MAXINCLUSIVE |XSSimpleTypeDecl.FACET_MININCLUSIVE | XSSimpleTypeDecl.FACET_MAXEXCLUSIVE | XSSimpleTypeDecl.FACET_MINEXCLUSIVE | XSSimpleTypeDecl.FACET_TOTALDIGITS | XSSimpleTypeDecl.FACET_FRACTIONDIGITS);
}
@@ -332,6 +412,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.impl.dv.xs.TypeValidator#getActualValue(java.lang.String, com.sun.org.apache.xerces.internal.impl.dv.ValidationContext)
*/
+ @Override
public Object getActualValue(String content, ValidationContext context)
throws InvalidDatatypeValueException {
try {
@@ -341,18 +422,22 @@
}
}
+ @Override
public int compare(Object value1, Object value2) {
return ((XPrecisionDecimal)value1).compareTo((XPrecisionDecimal)value2);
}
+ @Override
public int getFractionDigits(Object value) {
return ((XPrecisionDecimal)value).fracDigits;
}
+ @Override
public int getTotalDigits(Object value) {
return ((XPrecisionDecimal)value).totalDigits;
}
+ @Override
public boolean isIdentical(Object value1, Object value2) {
if(!(value2 instanceof XPrecisionDecimal) || !(value1 instanceof XPrecisionDecimal))
return false;
diff -r 50528ec0ea37 -r d8d911c4e5d4 jaxp/src/com/sun/org/apache/xerces/internal/util/URI.java
--- a/jaxp/src/com/sun/org/apache/xerces/internal/util/URI.java Fri May 10 09:23:22 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/util/URI.java Fri May 17 10:40:21 2013 +0200
@@ -22,6 +22,7 @@
import java.io.IOException;
import java.io.Serializable;
+import java.util.Objects;
/**********************************************************************
* A class to represent a Uniform Resource Identifier (URI). This class
@@ -1212,7 +1213,7 @@
* @return the scheme-specific part for this URI
*/
public String getSchemeSpecificPart() {
- StringBuffer schemespec = new StringBuffer();
+ final StringBuilder schemespec = new StringBuilder();
if (m_host != null || m_regAuthority != null) {
schemespec.append("//");
@@ -1297,7 +1298,7 @@
* @return the authority
*/
public String getAuthority() {
- StringBuffer authority = new StringBuffer();
+ final StringBuilder authority = new StringBuilder();
if (m_host != null || m_regAuthority != null) {
authority.append("//");
@@ -1340,7 +1341,7 @@
*/
public String getPath(boolean p_includeQueryString,
boolean p_includeFragment) {
- StringBuffer pathString = new StringBuffer(m_path);
+ final StringBuilder pathString = new StringBuilder(m_path);
if (p_includeQueryString && m_queryString != null) {
pathString.append('?');
@@ -1683,6 +1684,7 @@
* @return true if p_test is a URI with all values equal to this
* URI, false otherwise
*/
+ @Override
public boolean equals(Object p_test) {
if (p_test instanceof URI) {
URI testURI = (URI) p_test;
@@ -1711,13 +1713,27 @@
return false;
}
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 47 * hash + Objects.hashCode(this.m_scheme);
+ hash = 47 * hash + Objects.hashCode(this.m_userinfo);
+ hash = 47 * hash + Objects.hashCode(this.m_host);
+ hash = 47 * hash + this.m_port;
+ hash = 47 * hash + Objects.hashCode(this.m_path);
+ hash = 47 * hash + Objects.hashCode(this.m_queryString);
+ hash = 47 * hash + Objects.hashCode(this.m_fragment);
+ return hash;
+ }
+
/**
* Get the URI as a string specification. See RFC 2396 Section 5.2.
*
* @return the URI string specification
*/
+ @Override
public String toString() {
- StringBuffer uriSpecString = new StringBuffer();
+ final StringBuilder uriSpecString = new StringBuilder();
if (m_scheme != null) {
uriSpecString.append(m_scheme);
diff -r 50528ec0ea37 -r d8d911c4e5d4 jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java
--- a/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java Fri May 10 09:23:22 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java Fri May 17 10:40:21 2013 +0200
@@ -68,6 +68,7 @@
import com.sun.org.apache.xerces.internal.xpointer.XPointerHandler;
import com.sun.org.apache.xerces.internal.xpointer.XPointerProcessor;
import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
+import java.util.Objects;
/**
*
@@ -390,6 +391,7 @@
// XMLComponent methods
+ @Override
public void reset(XMLComponentManager componentManager)
throws XNIException {
fNamespaceContext = null;
@@ -597,6 +599,7 @@
* this component. This method may return null if no features
* are recognized by this component.
*/
+ @Override
public String[] getRecognizedFeatures() {
return (String[])(RECOGNIZED_FEATURES.clone());
} // getRecognizedFeatures():String[]
@@ -616,6 +619,7 @@
* @throws SAXNotSupportedException The component should not throw
* this exception.
*/
+ @Override
public void setFeature(String featureId, boolean state)
throws XMLConfigurationException {
if (featureId.equals(ALLOW_UE_AND_NOTATION_EVENTS)) {
@@ -632,6 +636,7 @@
* this component. This method may return null if no properties
* are recognized by this component.
*/
+ @Override
public String[] getRecognizedProperties() {
return (String[])(RECOGNIZED_PROPERTIES.clone());
} // getRecognizedProperties():String[]
@@ -651,6 +656,7 @@
* @throws SAXNotSupportedException The component should not throw
* this exception.
*/
+ @Override
public void setProperty(String propertyId, Object value)
throws XMLConfigurationException {
if (propertyId.equals(SYMBOL_TABLE)) {
@@ -719,6 +725,7 @@
*
* @since Xerces 2.2.0
*/
+ @Override
public Boolean getFeatureDefault(String featureId) {
for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
if (RECOGNIZED_FEATURES[i].equals(featureId)) {
@@ -737,6 +744,7 @@
*
* @since Xerces 2.2.0
*/
+ @Override
public Object getPropertyDefault(String propertyId) {
for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {
@@ -746,10 +754,12 @@
return null;
} // getPropertyDefault(String):Object
+ @Override
public void setDocumentHandler(XMLDocumentHandler handler) {
fDocumentHandler = handler;
}
+ @Override
public XMLDocumentHandler getDocumentHandler() {
return fDocumentHandler;
}
@@ -764,6 +774,7 @@
*
* This event is only passed on to the document handler if this is the root document.
*/
+ @Override
public void startDocument(
XMLLocator locator,
String encoding,
@@ -811,6 +822,7 @@
}
}
+ @Override
public void xmlDecl(
String version,
String encoding,
@@ -823,6 +835,7 @@
}
}
+ @Override
public void doctypeDecl(
String rootElement,
String publicId,
@@ -834,6 +847,7 @@
}
}
+ @Override
public void comment(XMLString text, Augmentations augs)
throws XNIException {
if (!fInDTD) {
@@ -850,6 +864,7 @@
}
}
+ @Override
public void processingInstruction(
String target,
XMLString data,
@@ -870,6 +885,7 @@
}
}
+ @Override
public void startElement(
QName element,
XMLAttributes attributes,
@@ -940,6 +956,7 @@
}
}
+ @Override
public void emptyElement(
QName element,
XMLAttributes attributes,
@@ -1021,6 +1038,7 @@
fDepth--;
}
+ @Override
public void endElement(QName element, Augmentations augs)
throws XNIException {
@@ -1066,6 +1084,7 @@
fDepth--;
}
+ @Override
public void startGeneralEntity(
String name,
XMLResourceIdentifier resId,
@@ -1084,6 +1103,7 @@
}
}
+ @Override
public void textDecl(String version, String encoding, Augmentations augs)
throws XNIException {
if (fDocumentHandler != null
@@ -1092,6 +1112,7 @@
}
}
+ @Override
public void endGeneralEntity(String name, Augmentations augs)
throws XNIException {
if (fDocumentHandler != null
@@ -1101,6 +1122,7 @@
}
}
+ @Override
public void characters(XMLString text, Augmentations augs)
throws XNIException {
if (getState() == STATE_NORMAL_PROCESSING) {
@@ -1117,6 +1139,7 @@
}
}
+ @Override
public void ignorableWhitespace(XMLString text, Augmentations augs)
throws XNIException {
if (fDocumentHandler != null
@@ -1126,6 +1149,7 @@
}
}
+ @Override
public void startCDATA(Augmentations augs) throws XNIException {
if (fDocumentHandler != null
&& getState() == STATE_NORMAL_PROCESSING
@@ -1134,6 +1158,7 @@
}
}
+ @Override
public void endCDATA(Augmentations augs) throws XNIException {
if (fDocumentHandler != null
&& getState() == STATE_NORMAL_PROCESSING
@@ -1142,6 +1167,7 @@
}
}
+ @Override
public void endDocument(Augmentations augs) throws XNIException {
if (isRootDocument()) {
if (!fSeenRootElement) {
@@ -1153,10 +1179,12 @@
}
}
+ @Override
public void setDocumentSource(XMLDocumentSource source) {
fDocumentSource = source;
}
+ @Override
public XMLDocumentSource getDocumentSource() {
return fDocumentSource;
}
@@ -1168,6 +1196,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String[], java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void attributeDecl(
String elementName,
String attributeName,
@@ -1194,6 +1223,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#elementDecl(java.lang.String, java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void elementDecl(
String name,
String contentModel,
@@ -1207,6 +1237,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endAttlist(com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void endAttlist(Augmentations augmentations) throws XNIException {
if (fDTDHandler != null) {
fDTDHandler.endAttlist(augmentations);
@@ -1216,6 +1247,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endConditional(com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void endConditional(Augmentations augmentations)
throws XNIException {
if (fDTDHandler != null) {
@@ -1226,6 +1258,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endDTD(com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void endDTD(Augmentations augmentations) throws XNIException {
if (fDTDHandler != null) {
fDTDHandler.endDTD(augmentations);
@@ -1236,6 +1269,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endExternalSubset(com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void endExternalSubset(Augmentations augmentations)
throws XNIException {
if (fDTDHandler != null) {
@@ -1246,6 +1280,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#endParameterEntity(java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void endParameterEntity(String name, Augmentations augmentations)
throws XNIException {
if (fDTDHandler != null) {
@@ -1256,6 +1291,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#externalEntityDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void externalEntityDecl(
String name,
XMLResourceIdentifier identifier,
@@ -1269,6 +1305,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#getDTDSource()
*/
+ @Override
public XMLDTDSource getDTDSource() {
return fDTDSource;
}
@@ -1276,6 +1313,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#ignoredCharacters(com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void ignoredCharacters(XMLString text, Augmentations augmentations)
throws XNIException {
if (fDTDHandler != null) {
@@ -1286,6 +1324,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#internalEntityDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.XMLString, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void internalEntityDecl(
String name,
XMLString text,
@@ -1304,6 +1343,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#notationDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void notationDecl(
String name,
XMLResourceIdentifier identifier,
@@ -1318,6 +1358,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#setDTDSource(com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource)
*/
+ @Override
public void setDTDSource(XMLDTDSource source) {
fDTDSource = source;
}
@@ -1325,6 +1366,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startAttlist(java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void startAttlist(String elementName, Augmentations augmentations)
throws XNIException {
if (fDTDHandler != null) {
@@ -1335,6 +1377,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startConditional(short, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void startConditional(short type, Augmentations augmentations)
throws XNIException {
if (fDTDHandler != null) {
@@ -1345,6 +1388,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startDTD(com.sun.org.apache.xerces.internal.xni.XMLLocator, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void startDTD(XMLLocator locator, Augmentations augmentations)
throws XNIException {
fInDTD = true;
@@ -1356,6 +1400,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startExternalSubset(com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void startExternalSubset(
XMLResourceIdentifier identifier,
Augmentations augmentations)
@@ -1368,6 +1413,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#startParameterEntity(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void startParameterEntity(
String name,
XMLResourceIdentifier identifier,
@@ -1386,6 +1432,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.XMLDTDHandler#unparsedEntityDecl(java.lang.String, com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier, java.lang.String, com.sun.org.apache.xerces.internal.xni.Augmentations)
*/
+ @Override
public void unparsedEntityDecl(
String name,
XMLResourceIdentifier identifier,
@@ -1405,6 +1452,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource#getDTDHandler()
*/
+ @Override
public XMLDTDHandler getDTDHandler() {
return fDTDHandler;
}
@@ -1412,6 +1460,7 @@
/* (non-Javadoc)
* @see com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource#setDTDHandler(com.sun.org.apache.xerces.internal.xni.XMLDTDHandler)
*/
+ @Override
public void setDTDHandler(XMLDTDHandler handler) {
fDTDHandler = handler;
}
@@ -1641,11 +1690,10 @@
fNamespaceContext);
((XPointerHandler)fXPtrProcessor).setProperty(XINCLUDE_FIXUP_BASE_URIS,
- new Boolean(fFixupBaseURIs));
+ fFixupBaseURIs);
((XPointerHandler)fXPtrProcessor).setProperty(
- XINCLUDE_FIXUP_LANGUAGE,
- new Boolean (fFixupLanguage));
+ XINCLUDE_FIXUP_LANGUAGE, fFixupLanguage);
if (fErrorReporter != null)
((XPointerHandler)fXPtrProcessor).setProperty(ERROR_REPORTER, fErrorReporter);
@@ -2119,14 +2167,14 @@
/** Check whether the scheme components are equal. */
final String baseScheme = base.getScheme();
final String literalScheme = uri.getScheme();
- if (!isEqual(baseScheme, literalScheme)) {
+ if (!Objects.equals(baseScheme, literalScheme)) {
return relativeURI;
}
/** Check whether the authority components are equal. */
final String baseAuthority = base.getAuthority();
final String literalAuthority = uri.getAuthority();
- if (!isEqual(baseAuthority, literalAuthority)) {
+ if (!Objects.equals(baseAuthority, literalAuthority)) {
return uri.getSchemeSpecificPart();
}
@@ -2139,7 +2187,7 @@
final String literalQuery = uri.getQueryString();
final String literalFragment = uri.getFragment();
if (literalQuery != null || literalFragment != null) {
- StringBuffer buffer = new StringBuffer();
+ final StringBuilder buffer = new StringBuilder();
if (literalPath != null) {
buffer.append(literalPath);
}
@@ -2650,15 +2698,15 @@
// equals() returns true if two Notations have the same name.
// Useful for searching Vectors for notations with the same name
+ @Override
public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj instanceof Notation) {
- Notation other = (Notation)obj;
- return name.equals(other.name);
- }
- return false;
+ return obj == this || obj instanceof Notation
+ && Objects.equals(name, ((Notation)obj).name);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name);
}
// from 4.5.2
@@ -2671,16 +2719,12 @@
public boolean isDuplicate(Object obj) {
if (obj != null && obj instanceof Notation) {
Notation other = (Notation)obj;
- return name.equals(other.name)
- && isEqual(publicId, other.publicId)
- && isEqual(expandedSystemId, other.expandedSystemId);
+ return Objects.equals(name, other.name)
+ && Objects.equals(publicId, other.publicId)
+ && Objects.equals(expandedSystemId, other.expandedSystemId);
}
return false;
}
-
- private boolean isEqual(String one, String two) {
- return (one == two || (one != null && one.equals(two)));
- }
}
// This is a storage class to hold information about the unparsed entities.
@@ -2696,15 +2740,15 @@
// equals() returns true if two UnparsedEntities have the same name.
// Useful for searching Vectors for entities with the same name
+ @Override
public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj instanceof UnparsedEntity) {
- UnparsedEntity other = (UnparsedEntity)obj;
- return name.equals(other.name);
- }
- return false;
+ return obj == this || obj instanceof UnparsedEntity
+ && Objects.equals(name, ((UnparsedEntity)obj).name);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name);
}
// from 4.5.1:
@@ -2717,17 +2761,13 @@
public boolean isDuplicate(Object obj) {
if (obj != null && obj instanceof UnparsedEntity) {
UnparsedEntity other = (UnparsedEntity)obj;
- return name.equals(other.name)
- && isEqual(publicId, other.publicId)
- && isEqual(expandedSystemId, other.expandedSystemId)
- && isEqual(notation, other.notation);
+ return Objects.equals(name, other.name)
+ && Objects.equals(publicId, other.publicId)
+ && Objects.equals(expandedSystemId, other.expandedSystemId)
+ && Objects.equals(notation, other.notation);
}
return false;
}
-
- private boolean isEqual(String one, String two) {
- return (one == two || (one != null && one.equals(two)));
- }
}
// The following methods are used for XML Base processing
@@ -2917,17 +2957,13 @@
return httpSource;
}
- private boolean isEqual(String one, String two) {
- return (one == two || (one != null && one.equals(two)));
- }
-
// which ASCII characters need to be escaped
- private static boolean gNeedEscaping[] = new boolean[128];
+ private static final boolean gNeedEscaping[] = new boolean[128];
// the first hex character if a character needs to be escaped
- private static char gAfterEscaping1[] = new char[128];
+ private static final char gAfterEscaping1[] = new char[128];
// the second hex character if a character needs to be escaped
- private static char gAfterEscaping2[] = new char[128];
- private static char[] gHexChs = {'0', '1', '2', '3', '4', '5', '6', '7',
+ private static final char gAfterEscaping2[] = new char[128];
+ private static final char[] gHexChs = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
// initialize the above 3 arrays
static {
@@ -2957,7 +2993,7 @@
private String escapeHref(String href) {
int len = href.length();
int ch;
- StringBuffer buffer = new StringBuffer(len*3);
+ final StringBuilder buffer = new StringBuilder(len*3);
// for each character in the href
int i = 0;
diff -r 50528ec0ea37 -r d8d911c4e5d4 jaxp/src/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeProxy.java
--- a/jaxp/src/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeProxy.java Fri May 10 09:23:22 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/dtm/ref/DTMNodeProxy.java Fri May 17 10:40:21 2013 +0200
@@ -27,6 +27,7 @@
import com.sun.org.apache.xml.internal.dtm.DTM;
import com.sun.org.apache.xml.internal.dtm.DTMDOMException;
import com.sun.org.apache.xpath.internal.NodeSet;
+import java.util.Objects;
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
@@ -141,21 +142,21 @@
*
* @return true if the given node has the same handle as this node.
*/
+ @Override
public final boolean equals(Object node)
{
-
- try
- {
-
// DTMNodeProxy dtmp = (DTMNodeProxy)node;
// return (dtmp.node == this.node);
// Patch attributed to Gary L Peskin null
if there was none.
* @since DOM Level 3
*/
+ @Override
public Object getUserData(String key) {
return getOwnerDocument().getUserData( key);
}
@@ -1581,6 +1657,7 @@
* childNodes, etc.
* @since DOM Level 3
*/
+ @Override
public Object getFeature(String feature, String version) {
// we don't have any alternate node, either this node does the job
// or we don't have anything that does
@@ -1629,6 +1706,7 @@
* true
otherwise false
.
* @since DOM Level 3
*/
+ @Override
public boolean isEqualNode(Node arg) {
if (arg == this) {
return true;
@@ -1705,6 +1783,7 @@
* @return th URI for the namespace
* @since DOM Level 3
*/
+ @Override
public String lookupNamespaceURI(String specifiedPrefix) {
short type = this.getNodeType();
switch (type) {
@@ -1797,6 +1876,7 @@
* is the default namespace, false
otherwise.
* @since DOM Level 3
*/
+ @Override
public boolean isDefaultNamespace(String namespaceURI){
/*
// REVISIT: remove casts when DOM L3 becomes REC.
@@ -1871,6 +1951,7 @@
* @param namespaceURI
* @return the prefix for the namespace
*/
+ @Override
public String lookupPrefix(String namespaceURI){
// REVISIT: When Namespaces 1.1 comes out this may not be true
@@ -1932,6 +2013,7 @@
* false
otherwise.
* @since DOM Level 3
*/
+ @Override
public boolean isSameNode(Node other) {
// we do not use any wrapper so the answer is obvious
return this == other;
@@ -1980,8 +2062,9 @@
* DOMSTRING_SIZE_ERR: Raised when it would return more characters than
* fit in a DOMString
variable on the implementation
* platform.
- * @since DOM Level 3
+ * @since DOM Level 3
*/
+ @Override
public void setTextContent(String textContent)
throws DOMException {
setNodeValue(textContent);
@@ -2031,6 +2114,7 @@
* platform.
* @since DOM Level 3
*/
+ @Override
public String getTextContent() throws DOMException {
return getNodeValue(); // overriden in some subclasses
}
@@ -2043,6 +2127,7 @@
* node.
* @since DOM Level 3
*/
+ @Override
public short compareDocumentPosition(Node other) throws DOMException {
return 0;
}
@@ -2071,14 +2156,16 @@
* Yes. (F2F 26 Sep 2001)
* @since DOM Level 3
*/
+ @Override
public String getBaseURI() {
return null;
}
- /**
+ /**
* DOM Level 3
* Renaming node
*/
+ @Override
public Node renameNode(Node n,
String namespaceURI,
String name)
@@ -2091,14 +2178,16 @@
* DOM Level 3
* Normalize document.
*/
+ @Override
public void normalizeDocument(){
}
/**
- * The configuration used when Document.normalizeDocument
is
+ * The configuration used when Document.normalizeDocument
is
* invoked.
* @since DOM Level 3
*/
+ @Override
public DOMConfiguration getDomConfig(){
return null;
}
@@ -2110,8 +2199,8 @@
/**
* DOM Level 3
*/
+ @Override
public void setDocumentURI(String documentURI){
-
fDocumentURI= documentURI;
}
@@ -2123,6 +2212,7 @@
* over this attribute.
* @since DOM Level 3
*/
+ @Override
public String getDocumentURI(){
return fDocumentURI;
}
@@ -2154,9 +2244,10 @@
actualEncoding = value;
}
- /**
+ /**
* DOM Level 3
*/
+ @Override
public Text replaceWholeText(String content)
throws DOMException{
/*
@@ -2210,6 +2301,7 @@
* nodes to this node, concatenated in document order.
* @since DOM Level 3
*/
+ @Override
public String getWholeText(){
/*
@@ -2235,13 +2327,11 @@
* Returns whether this text node contains whitespace in element content,
* often abusively called "ignorable whitespace".
*/
+ @Override
public boolean isElementContentWhitespace(){
return false;
}
-
-
-
/**
* NON-DOM: set the type of this attribute to be ID type.
*
@@ -2254,6 +2344,7 @@
/**
* DOM Level 3: register the given attribute node as an ID attribute
*/
+ @Override
public void setIdAttribute(String name, boolean makeId) {
//PENDING
}
@@ -2262,6 +2353,7 @@
/**
* DOM Level 3: register the given attribute node as an ID attribute
*/
+ @Override
public void setIdAttributeNode(Attr at, boolean makeId) {
//PENDING
}
@@ -2269,6 +2361,7 @@
/**
* DOM Level 3: register the given attribute node as an ID attribute
*/
+ @Override
public void setIdAttributeNS(String namespaceURI, String localName,
boolean makeId) {
//PENDING
@@ -2277,16 +2370,19 @@
* Method getSchemaTypeInfo.
* @return TypeInfo
*/
+ @Override
public TypeInfo getSchemaTypeInfo(){
return null; //PENDING
}
+ @Override
public boolean isId() {
return false; //PENDING
}
private String xmlEncoding;
+ @Override
public String getXmlEncoding( ) {
return xmlEncoding;
}
@@ -2295,23 +2391,25 @@
}
private boolean xmlStandalone;
+ @Override
public boolean getXmlStandalone() {
return xmlStandalone;
}
+ @Override
public void setXmlStandalone(boolean xmlStandalone) throws DOMException {
this.xmlStandalone = xmlStandalone;
}
private String xmlVersion;
+ @Override
public String getXmlVersion() {
return xmlVersion;
}
+ @Override
public void setXmlVersion(String xmlVersion) throws DOMException {
this.xmlVersion = xmlVersion;
}
-
-
}
diff -r 50528ec0ea37 -r d8d911c4e5d4 jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/URI.java
--- a/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/URI.java Fri May 10 09:23:22 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/serializer/utils/URI.java Fri May 17 10:40:21 2013 +0200
@@ -23,7 +23,7 @@
package com.sun.org.apache.xml.internal.serializer.utils;
import java.io.IOException;
-import java.io.Serializable;
+import java.util.Objects;
/**
@@ -863,7 +863,7 @@
public String getSchemeSpecificPart()
{
- StringBuffer schemespec = new StringBuffer();
+ final StringBuilder schemespec = new StringBuilder();
if (m_userinfo != null || m_host != null || m_port != -1)
{
@@ -955,7 +955,7 @@
boolean p_includeFragment)
{
- StringBuffer pathString = new StringBuffer(m_path);
+ final StringBuilder pathString = new StringBuilder(m_path);
if (p_includeQueryString && m_queryString != null)
{
@@ -1321,6 +1321,7 @@
* @return true if p_test is a URI with all values equal to this
* URI, false otherwise
*/
+ @Override
public boolean equals(Object p_test)
{
@@ -1343,15 +1344,29 @@
return false;
}
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 41 * hash + Objects.hashCode(this.m_scheme);
+ hash = 41 * hash + Objects.hashCode(this.m_userinfo);
+ hash = 41 * hash + Objects.hashCode(this.m_host);
+ hash = 41 * hash + this.m_port;
+ hash = 41 * hash + Objects.hashCode(this.m_path);
+ hash = 41 * hash + Objects.hashCode(this.m_queryString);
+ hash = 41 * hash + Objects.hashCode(this.m_fragment);
+ return hash;
+ }
+
/**
* Get the URI as a string specification. See RFC 2396 Section 5.2.
*
* @return the URI string specification
*/
+ @Override
public String toString()
{
- StringBuffer uriSpecString = new StringBuffer();
+ final StringBuilder uriSpecString = new StringBuilder();
if (m_scheme != null)
{
@@ -1543,7 +1558,7 @@
*
*
* @param p_char the character to check
- * @return true if the char is betweeen '0' and '9', 'a' and 'f'
+ * @return true if the char is between '0' and '9', 'a' and 'f'
* or 'A' and 'F', false otherwise
*/
private static boolean isHex(char p_char)
diff -r 50528ec0ea37 -r d8d911c4e5d4 jaxp/src/com/sun/org/apache/xml/internal/utils/URI.java
--- a/jaxp/src/com/sun/org/apache/xml/internal/utils/URI.java Fri May 10 09:23:22 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xml/internal/utils/URI.java Fri May 17 10:40:21 2013 +0200
@@ -27,6 +27,7 @@
import com.sun.org.apache.xml.internal.res.XMLErrorResources;
import com.sun.org.apache.xml.internal.res.XMLMessages;
+import java.util.Objects;
/**
* A class to represent a Uniform Resource Identifier (URI). This class
@@ -883,7 +884,7 @@
public String getSchemeSpecificPart()
{
- StringBuffer schemespec = new StringBuffer();
+ final StringBuilder schemespec = new StringBuilder();
if (m_userinfo != null || m_host != null || m_port != -1)
{
@@ -975,7 +976,7 @@
boolean p_includeFragment)
{
- StringBuffer pathString = new StringBuffer(m_path);
+ final StringBuilder pathString = new StringBuilder(m_path);
if (p_includeQueryString && m_queryString != null)
{
@@ -1341,6 +1342,7 @@
* @return true if p_test is a URI with all values equal to this
* URI, false otherwise
*/
+ @Override
public boolean equals(Object p_test)
{
@@ -1363,15 +1365,29 @@
return false;
}
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 59 * hash + Objects.hashCode(this.m_scheme);
+ hash = 59 * hash + Objects.hashCode(this.m_userinfo);
+ hash = 59 * hash + Objects.hashCode(this.m_host);
+ hash = 59 * hash + this.m_port;
+ hash = 59 * hash + Objects.hashCode(this.m_path);
+ hash = 59 * hash + Objects.hashCode(this.m_queryString);
+ hash = 59 * hash + Objects.hashCode(this.m_fragment);
+ return hash;
+ }
+
/**
* Get the URI as a string specification. See RFC 2396 Section 5.2.
*
* @return the URI string specification
*/
+ @Override
public String toString()
{
- StringBuffer uriSpecString = new StringBuffer();
+ final StringBuilder uriSpecString = new StringBuilder();
if (m_scheme != null)
{
diff -r 50528ec0ea37 -r d8d911c4e5d4 jaxp/src/com/sun/org/apache/xpath/internal/Arg.java
--- a/jaxp/src/com/sun/org/apache/xpath/internal/Arg.java Fri May 10 09:23:22 2013 -0700
+++ b/jaxp/src/com/sun/org/apache/xpath/internal/Arg.java Fri May 17 10:40:21 2013 +0200
@@ -24,6 +24,7 @@
import com.sun.org.apache.xml.internal.utils.QName;
import com.sun.org.apache.xpath.internal.objects.XObject;
+import java.util.Objects;
/**
* This class holds an instance of an argument on
@@ -182,7 +183,7 @@
{
m_qname = new QName("");
- ; // so that string compares can be done.
+ // so that string compares can be done.
m_val = null;
m_expression = null;
m_isVisible = true;
@@ -223,6 +224,11 @@
m_expression = null;
}
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(this.m_qname);
+ }
+
/**
* Equality function specialized for the variable name. If the argument
* is not a qname, it will deligate to the super class.
@@ -231,6 +237,7 @@
* @return true
if this object is the same as the obj
* argument; false
otherwise.
*/
+ @Override
public boolean equals(Object obj)
{
if(obj instanceof QName)