jaxp/src/com/sun/org/apache/xerces/internal/impl/xpath/regex/RangeToken.java
Print this page
*** 1,15 ****
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
! * Copyright 1999-2002,2004,2005 The Apache Software Foundation.
! *
! * Licensed under the Apache License, Version 2.0 (the "License");
! * you may not use this file except in compliance with the License.
! * You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
--- 1,16 ----
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
! * Licensed to the Apache Software Foundation (ASF) under one or more
! * contributor license agreements. See the NOTICE file distributed with
! * this work for additional information regarding copyright ownership.
! * The ASF licenses this file to You under the Apache License, Version 2.0
! * (the "License"); you may not use this file except in compliance with
! * the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
*** 349,359 ****
// src1: o--------o
// src2: o----o
// src2: o----o
// src2: o----o
// src2: o------------o
! if (src2begin <= src2begin && src1end <= src2end) {
// src1: o--------o
// src2: o------------o
// res: o--------o
// Reuse src2
result[wp++] = src1begin;
--- 350,360 ----
// src1: o--------o
// src2: o----o
// src2: o----o
// src2: o----o
// src2: o------------o
! if (src2begin <= src1begin && src1end <= src2end) {
// src1: o--------o
// src2: o------------o
// res: o--------o
// Reuse src2
result[wp++] = src1begin;
*** 382,391 ****
--- 383,393 ----
// res: o----o
// Reuse the rest of src1
result[wp++] = src2begin;
result[wp++] = src2end;
this.ranges[src1] = src2end+1;
+ src2 += 2;
}
} else if (src2end < src1begin) {
// Not overlapped
// src1: o-----o
// src2: o----o
*** 397,410 ****
+"] & ["+tok.ranges[src2]
+","+tok.ranges[src2+1]
+"]");
}
}
- while (src1 < this.ranges.length) {
- result[wp++] = this.ranges[src1++];
- result[wp++] = this.ranges[src1++];
- }
this.ranges = new int[wp];
System.arraycopy(result, 0, this.ranges, 0, wp);
// this.ranges is sorted and compacted.
}
--- 399,408 ----
*** 462,473 ****
for (int i = 0; i < uppers.ranges.length; i += 2) {
for (int ch = uppers.ranges[i]; ch <= uppers.ranges[i+1]; ch ++) {
if (ch > 0xffff)
lowers.addRange(ch, ch);
else {
! char uch = Character.toUpperCase((char)ch);
! lowers.addRange(uch, uch);
}
}
}
lowers.mergeRanges(uppers);
lowers.mergeRanges(this);
--- 460,471 ----
for (int i = 0; i < uppers.ranges.length; i += 2) {
for (int ch = uppers.ranges[i]; ch <= uppers.ranges[i+1]; ch ++) {
if (ch > 0xffff)
lowers.addRange(ch, ch);
else {
! char lch = Character.toLowerCase((char)ch);
! lowers.addRange(lch, lch);
}
}
}
lowers.mergeRanges(uppers);
lowers.mergeRanges(this);
*** 477,488 ****
return lowers;
}
void dumpRanges() {
System.err.print("RANGE: ");
! if (this.ranges == null)
System.err.println(" NULL");
for (int i = 0; i < this.ranges.length; i += 2) {
System.err.print("["+this.ranges[i]+","+this.ranges[i+1]+"] ");
}
System.err.println("");
}
--- 475,488 ----
return lowers;
}
void dumpRanges() {
System.err.print("RANGE: ");
! if (this.ranges == null) {
System.err.println(" NULL");
+ return;
+ }
for (int i = 0; i < this.ranges.length; i += 2) {
System.err.print("["+this.ranges[i]+","+this.ranges[i+1]+"] ");
}
System.err.println("");
}
*** 550,572 ****
else if (this == Token.token_wordchars)
ret = "\\w";
else if (this == Token.token_spaces)
ret = "\\s";
else {
! StringBuffer sb = new StringBuffer();
! sb.append("[");
for (int i = 0; i < this.ranges.length; i += 2) {
! if ((options & RegularExpression.SPECIAL_COMMA) != 0 && i > 0) sb.append(",");
if (this.ranges[i] == this.ranges[i+1]) {
sb.append(escapeCharInCharClass(this.ranges[i]));
} else {
sb.append(escapeCharInCharClass(this.ranges[i]));
sb.append((char)'-');
sb.append(escapeCharInCharClass(this.ranges[i+1]));
}
}
! sb.append("]");
ret = sb.toString();
}
} else {
if (this == Token.token_not_0to9)
ret = "\\D";
--- 550,572 ----
else if (this == Token.token_wordchars)
ret = "\\w";
else if (this == Token.token_spaces)
ret = "\\s";
else {
! StringBuilder sb = new StringBuilder();
! sb.append('[');
for (int i = 0; i < this.ranges.length; i += 2) {
! if ((options & RegularExpression.SPECIAL_COMMA) != 0 && i > 0) sb.append(',');
if (this.ranges[i] == this.ranges[i+1]) {
sb.append(escapeCharInCharClass(this.ranges[i]));
} else {
sb.append(escapeCharInCharClass(this.ranges[i]));
sb.append((char)'-');
sb.append(escapeCharInCharClass(this.ranges[i+1]));
}
}
! sb.append(']');
ret = sb.toString();
}
} else {
if (this == Token.token_not_0to9)
ret = "\\D";
*** 576,595 ****
ret = "\\S";
else {
StringBuffer sb = new StringBuffer();
sb.append("[^");
for (int i = 0; i < this.ranges.length; i += 2) {
! if ((options & RegularExpression.SPECIAL_COMMA) != 0 && i > 0) sb.append(",");
if (this.ranges[i] == this.ranges[i+1]) {
sb.append(escapeCharInCharClass(this.ranges[i]));
} else {
sb.append(escapeCharInCharClass(this.ranges[i]));
sb.append('-');
sb.append(escapeCharInCharClass(this.ranges[i+1]));
}
}
! sb.append("]");
ret = sb.toString();
}
}
return ret;
}
--- 576,595 ----
ret = "\\S";
else {
StringBuffer sb = new StringBuffer();
sb.append("[^");
for (int i = 0; i < this.ranges.length; i += 2) {
! if ((options & RegularExpression.SPECIAL_COMMA) != 0 && i > 0) sb.append(',');
if (this.ranges[i] == this.ranges[i+1]) {
sb.append(escapeCharInCharClass(this.ranges[i]));
} else {
sb.append(escapeCharInCharClass(this.ranges[i]));
sb.append('-');
sb.append(escapeCharInCharClass(this.ranges[i+1]));
}
}
! sb.append(']');
ret = sb.toString();
}
}
return ret;
}