summaryrefslogtreecommitdiff
path: root/gnu/java/util/regex/RE.java
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/java/util/regex/RE.java')
-rw-r--r--gnu/java/util/regex/RE.java57
1 files changed, 28 insertions, 29 deletions
diff --git a/gnu/java/util/regex/RE.java b/gnu/java/util/regex/RE.java
index 2b0348848..7e59208c7 100644
--- a/gnu/java/util/regex/RE.java
+++ b/gnu/java/util/regex/RE.java
@@ -41,10 +41,12 @@ import gnu.java.lang.CPStringBuilder;
import java.io.InputStream;
import java.io.Serializable;
+
+import java.util.ArrayList;
+import java.util.List;
import java.util.Locale;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
-import java.util.Vector;
/**
* RE provides the user interface for compiling and matching regular
@@ -364,7 +366,7 @@ public class RE extends REToken {
int pLength = pattern.length;
numSubs = 0; // Number of subexpressions in this token.
- Vector branches = null;
+ ArrayList<REToken> branches = null;
// linked list of tokens (sort of -- some closed loops can exist)
firstToken = lastToken = null;
@@ -388,7 +390,6 @@ public class RE extends REToken {
// Buffer a token so we can create a TokenRepeated, etc.
REToken currentToken = null;
- char ch;
boolean quot = false;
// Saved syntax and flags.
@@ -451,9 +452,9 @@ public class RE extends REToken {
minimumLength = 0;
maximumLength = 0;
if (branches == null) {
- branches = new Vector();
+ branches = new ArrayList<REToken>();
}
- branches.addElement(theBranch);
+ branches.add(theBranch);
firstToken = lastToken = currentToken = null;
}
@@ -1105,7 +1106,7 @@ public class RE extends REToken {
addToken(currentToken);
if (branches != null) {
- branches.addElement(new RE(firstToken,lastToken,numSubs,subIndex,minimumLength, maximumLength));
+ branches.add(new RE(firstToken,lastToken,numSubs,subIndex,minimumLength, maximumLength));
branches.trimToSize(); // compact the Vector
minimumLength = 0;
maximumLength = 0;
@@ -1139,8 +1140,8 @@ public class RE extends REToken {
boolean insens = ((cflags & REG_ICASE) > 0);
boolean insensUSASCII = ((cflags & REG_ICASE_USASCII) > 0);
- Vector options = new Vector();
- Vector addition = new Vector();
+ final ArrayList<REToken> options = new ArrayList<REToken>();
+ ArrayList<Object> addition = new ArrayList<Object>();
boolean additionAndAppeared = false;
final int RETURN_AT_AND = 0x01;
boolean returnAtAndOperator = ((pflags & RETURN_AT_AND) != 0);
@@ -1170,7 +1171,7 @@ public class RE extends REToken {
if ((ch = pattern[index]) == ']') {
RETokenChar t = new RETokenChar(subIndex,lastChar,insens);
if (insensUSASCII) t.unicodeAware = false;
- options.addElement(t);
+ options.add(t);
lastChar = '-';
} else {
if ((ch == '\\') && syntax.get(RESyntax.RE_BACKSLASH_ESCAPE_IN_LISTS)) {
@@ -1182,7 +1183,7 @@ public class RE extends REToken {
}
RETokenRange t = new RETokenRange(subIndex,lastChar,ch,insens);
if (insensUSASCII) t.unicodeAware = false;
- options.addElement(t);
+ options.add(t);
lastChar = 0; lastCharIsSet = false;
index++;
}
@@ -1228,17 +1229,17 @@ public class RE extends REToken {
if (lastCharIsSet) {
RETokenChar t = new RETokenChar(subIndex,lastChar,insens);
if (insensUSASCII) t.unicodeAware = false;
- options.addElement(t);
+ options.add(t);
}
if (posixID != -1) {
RETokenPOSIX t = new RETokenPOSIX(subIndex,posixID,insens,negate);
if (insensUSASCII) t.unicodeAware = false;
- options.addElement(t);
+ options.add(t);
} else if (np != null) {
RETokenNamedProperty t = getRETokenNamedProperty(subIndex,np,insens,index);
if (insensUSASCII) t.unicodeAware = false;
- options.addElement(t);
+ options.add(t);
} else if (asciiEscIsSet) {
lastChar = asciiEsc; lastCharIsSet = true;
} else {
@@ -1252,13 +1253,13 @@ public class RE extends REToken {
if (posixId != -1) {
RETokenPOSIX t = new RETokenPOSIX(subIndex,posixId,insens,false);
if (insensUSASCII) t.unicodeAware = false;
- options.addElement(t);
+ options.add(t);
}
} else if ((ch == '[') && (syntax.get(RESyntax.RE_NESTED_CHARCLASS))) {
ParseCharClassResult result = parseCharClass(
subIndex, pattern, index, pLength, cflags, syntax, 0);
- addition.addElement(result.token);
- addition.addElement("|");
+ addition.add(result.token);
+ addition.add("|");
index = result.index;
} else if ((ch == '&') &&
(syntax.get(RESyntax.RE_NESTED_CHARCLASS)) &&
@@ -1266,7 +1267,7 @@ public class RE extends REToken {
if (returnAtAndOperator) {
ParseCharClassResult result = new ParseCharClassResult();
options.trimToSize();
- if (additionAndAppeared) addition.addElement("&");
+ if (additionAndAppeared) addition.add("&");
if (addition.size() == 0) addition = null;
result.token = new RETokenOneOf(subIndex,
options, addition, negative);
@@ -1281,8 +1282,8 @@ public class RE extends REToken {
// So, "&&[a-b][k-m]" will be stored in the Vecter
// addition in this order:
// Boolean.FALSE, [a-b], "|", [k-m], "|", "&"
- if (additionAndAppeared) addition.addElement("&");
- addition.addElement(Boolean.FALSE);
+ if (additionAndAppeared) addition.add("&");
+ addition.add(Boolean.FALSE);
additionAndAppeared = true;
// The part on which "&&" operates may be either
@@ -1296,8 +1297,8 @@ public class RE extends REToken {
ParseCharClassResult result = parseCharClass(
subIndex, pattern, index+1, pLength, cflags, syntax,
RETURN_AT_AND);
- addition.addElement(result.token);
- addition.addElement("|");
+ addition.add(result.token);
+ addition.add("|");
// If the method returned at the next "&&", it is OK.
// Otherwise we have eaten the mark of the end of this
// character list "]". In this case we must give back
@@ -1309,7 +1310,7 @@ public class RE extends REToken {
if (lastCharIsSet) {
RETokenChar t = new RETokenChar(subIndex,lastChar,insens);
if (insensUSASCII) t.unicodeAware = false;
- options.addElement(t);
+ options.add(t);
}
lastChar = ch; lastCharIsSet = true;
}
@@ -1320,13 +1321,13 @@ public class RE extends REToken {
if (lastCharIsSet) {
RETokenChar t = new RETokenChar(subIndex,lastChar,insens);
if (insensUSASCII) t.unicodeAware = false;
- options.addElement(t);
+ options.add(t);
}
ParseCharClassResult result = new ParseCharClassResult();
// Create a new RETokenOneOf
options.trimToSize();
- if (additionAndAppeared) addition.addElement("&");
+ if (additionAndAppeared) addition.add("&");
if (addition.size() == 0) addition = null;
result.token = new RETokenOneOf(subIndex,options, addition, negative);
result.index = index;
@@ -1644,10 +1645,10 @@ public class RE extends REToken {
// this has been changed since 1.03 to be non-overlapping matches
private REMatch[] getAllMatchesImpl(CharIndexed input, int index, int eflags) {
- Vector all = new Vector();
+ List<REMatch> all = new ArrayList<REMatch>();
REMatch m = null;
while ((m = getMatchImpl(input,index,eflags,null)) != null) {
- all.addElement(m);
+ all.add(m);
index = m.getEndIndex();
if (m.end[0] == 0) { // handle pathological case of zero-length match
index++;
@@ -1657,9 +1658,7 @@ public class RE extends REToken {
}
if (!input.isValid()) break;
}
- REMatch[] mset = new REMatch[all.size()];
- all.copyInto(mset);
- return mset;
+ return all.toArray(new REMatch[all.size()]);
}
/* Implements abstract method REToken.match() */