ICU-8491 remove Utility.skipWhitespace(c)
X-SVN-Rev: 29899
This commit is contained in:
parent
3962c68aa2
commit
6ecb5efc59
@ -1097,46 +1097,6 @@ public final class Utility {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip over a sequence of zero or more white space characters
|
||||
* at pos. Return the index of the first non-white-space character
|
||||
* at or after pos, or str.length(), if there is none.
|
||||
*/
|
||||
public static int skipWhitespace(String str, int pos) {
|
||||
while (pos < str.length()) {
|
||||
int c = Character.codePointAt(str, pos);
|
||||
if (!PatternProps.isWhiteSpace(c)) {
|
||||
break;
|
||||
}
|
||||
pos += UTF16.getCharCount(c);
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip over a sequence of zero or more white space characters
|
||||
* at pos[0], advancing it.
|
||||
*/
|
||||
public static void skipWhitespace(String str, int[] pos) {
|
||||
pos[0] = skipWhitespace(str, pos[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all Pattern_White_Space from a string.
|
||||
*/
|
||||
public static String deletePatternWhiteSpace(String str) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (int i=0; i<str.length(); ) {
|
||||
int ch = Character.codePointAt(str, i);
|
||||
i += UTF16.getCharCount(ch);
|
||||
if (PatternProps.isWhiteSpace(ch)) {
|
||||
continue;
|
||||
}
|
||||
buf.appendCodePoint(ch);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a single non-whitespace character 'ch', optionally
|
||||
* preceded by whitespace.
|
||||
@ -1151,7 +1111,7 @@ public final class Utility {
|
||||
*/
|
||||
public static boolean parseChar(String id, int[] pos, char ch) {
|
||||
int start = pos[0];
|
||||
skipWhitespace(id, pos);
|
||||
pos[0] = PatternProps.skipWhiteSpace(id, pos[0]);
|
||||
if (pos[0] == id.length() ||
|
||||
id.charAt(pos[0]) != ch) {
|
||||
pos[0] = start;
|
||||
@ -1200,7 +1160,7 @@ public final class Utility {
|
||||
}
|
||||
// FALL THROUGH to skipWhitespace
|
||||
case '~':
|
||||
pos = skipWhitespace(rule, pos);
|
||||
pos = PatternProps.skipWhiteSpace(rule, pos);
|
||||
break;
|
||||
case '#':
|
||||
p[0] = pos;
|
||||
@ -1806,7 +1766,7 @@ public final class Utility {
|
||||
* Parse a list of hex numbers and return a string
|
||||
* @param string String of hex numbers.
|
||||
* @param minLength Minimal length.
|
||||
* @param separator Seperator.
|
||||
* @param separator Separator.
|
||||
* @return A string from hex numbers.
|
||||
*/
|
||||
public static String fromHex(String string, int minLength, String separator) {
|
||||
@ -1817,7 +1777,7 @@ public final class Utility {
|
||||
* Parse a list of hex numbers and return a string
|
||||
* @param string String of hex numbers.
|
||||
* @param minLength Minimal length.
|
||||
* @param separator Seperator.
|
||||
* @param separator Separator.
|
||||
* @return A string from hex numbers.
|
||||
*/
|
||||
public static String fromHex(String string, int minLength, Pattern separator) {
|
||||
|
@ -14,7 +14,7 @@ import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import com.ibm.icu.impl.ICUData;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.impl.PatternProps;
|
||||
|
||||
/**
|
||||
* A reader for text resource data in the current package or the package
|
||||
@ -166,7 +166,7 @@ public class ResourceReader {
|
||||
return line;
|
||||
}
|
||||
// Skip over white space
|
||||
int pos = Utility.skipWhitespace(line, 0);
|
||||
int pos = PatternProps.skipWhiteSpace(line, 0);
|
||||
// Ignore blank lines and comment lines
|
||||
if (pos == line.length() || line.charAt(pos) == '#') {
|
||||
continue;
|
||||
|
@ -105,7 +105,7 @@ public class TokenIterator {
|
||||
* -1
|
||||
*/
|
||||
private int nextToken(int position) {
|
||||
position = Utility.skipWhitespace(line, position);
|
||||
position = PatternProps.skipWhiteSpace(line, position);
|
||||
if (position == line.length()) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*********************************************************************
|
||||
* Copyright (C) 2000-2010, International Business Machines Corporation and
|
||||
* Copyright (C) 2000-2011, International Business Machines Corporation and
|
||||
* others. All Rights Reserved.
|
||||
*********************************************************************
|
||||
*/
|
||||
@ -10,7 +10,7 @@ import java.text.FieldPosition;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.impl.PatternProps;
|
||||
import com.ibm.icu.util.Calendar;
|
||||
import com.ibm.icu.util.ChineseCalendar;
|
||||
import com.ibm.icu.util.TimeZone;
|
||||
@ -152,7 +152,7 @@ public class ChineseDateFormat extends SimpleDateFormat {
|
||||
}
|
||||
|
||||
// Skip whitespace
|
||||
start = Utility.skipWhitespace(text, start);
|
||||
start = PatternProps.skipWhiteSpace(text, start);
|
||||
|
||||
ParsePosition pos = new ParsePosition(start);
|
||||
|
||||
|
@ -2340,7 +2340,7 @@ public class UnicodeSet extends UnicodeFilter implements Iterable<String>, Compa
|
||||
|
||||
// Skip over trailing whitespace
|
||||
if ((options & IGNORE_SPACE) != 0) {
|
||||
i = Utility.skipWhitespace(pattern, i);
|
||||
i = PatternProps.skipWhiteSpace(pattern, i);
|
||||
}
|
||||
|
||||
if (i != pattern.length()) {
|
||||
@ -3325,7 +3325,7 @@ public class UnicodeSet extends UnicodeFilter implements Iterable<String>, Compa
|
||||
if (p == UProperty.CANONICAL_COMBINING_CLASS ||
|
||||
p == UProperty.LEAD_CANONICAL_COMBINING_CLASS ||
|
||||
p == UProperty.TRAIL_CANONICAL_COMBINING_CLASS) {
|
||||
v = Integer.parseInt(Utility.deletePatternWhiteSpace(valueAlias));
|
||||
v = Integer.parseInt(PatternProps.trimWhiteSpace(valueAlias));
|
||||
// If the resultant set is empty then the numeric value
|
||||
// was invalid.
|
||||
//mustNotBeEmpty = true;
|
||||
@ -3341,7 +3341,7 @@ public class UnicodeSet extends UnicodeFilter implements Iterable<String>, Compa
|
||||
switch (p) {
|
||||
case UProperty.NUMERIC_VALUE:
|
||||
{
|
||||
double value = Double.parseDouble(Utility.deletePatternWhiteSpace(valueAlias));
|
||||
double value = Double.parseDouble(PatternProps.trimWhiteSpace(valueAlias));
|
||||
applyFilter(new NumericValueFilter(value), UCharacterProperty.SRC_CHAR);
|
||||
return this;
|
||||
}
|
||||
@ -3504,7 +3504,7 @@ public class UnicodeSet extends UnicodeFilter implements Iterable<String>, Compa
|
||||
// Look for an opening [:, [:^, \p, or \P
|
||||
if (pattern.regionMatches(pos, "[:", 0, 2)) {
|
||||
posix = true;
|
||||
pos = Utility.skipWhitespace(pattern, pos+2);
|
||||
pos = PatternProps.skipWhiteSpace(pattern, (pos+2));
|
||||
if (pos < pattern.length() && pattern.charAt(pos) == '^') {
|
||||
++pos;
|
||||
invert = true;
|
||||
@ -3514,7 +3514,7 @@ public class UnicodeSet extends UnicodeFilter implements Iterable<String>, Compa
|
||||
char c = pattern.charAt(pos+1);
|
||||
invert = (c == 'P');
|
||||
isName = (c == 'N');
|
||||
pos = Utility.skipWhitespace(pattern, pos+2);
|
||||
pos = PatternProps.skipWhiteSpace(pattern, (pos+2));
|
||||
if (pos == pattern.length() || pattern.charAt(pos++) != '{') {
|
||||
// Syntax error; "\p" or "\P" not followed by "{"
|
||||
return null;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
**********************************************************************
|
||||
* Copyright (c) 2002-2010, International Business Machines Corporation
|
||||
* Copyright (c) 2002-2011, International Business Machines Corporation
|
||||
* and others. All Rights Reserved.
|
||||
**********************************************************************
|
||||
* Date Name Description
|
||||
@ -17,6 +17,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.icu.impl.PatternProps;
|
||||
import com.ibm.icu.impl.Utility;
|
||||
import com.ibm.icu.util.CaseInsensitiveString;
|
||||
|
||||
@ -276,7 +277,7 @@ class TransliteratorIDParser {
|
||||
}
|
||||
}
|
||||
|
||||
Utility.skipWhitespace(id, pos);
|
||||
pos[0] = PatternProps.skipWhiteSpace(id, pos[0]);
|
||||
|
||||
if (UnicodeSet.resemblesPattern(id, pos[0])) {
|
||||
ParsePosition ppos = new ParsePosition(pos[0]);
|
||||
@ -409,7 +410,7 @@ class TransliteratorIDParser {
|
||||
}
|
||||
|
||||
// Trailing unparsed text is a syntax error
|
||||
Utility.skipWhitespace(id, pos[0]);
|
||||
pos[0] = PatternProps.skipWhiteSpace(id, pos[0]);
|
||||
if (pos[0] != id.length()) {
|
||||
return false;
|
||||
}
|
||||
@ -601,7 +602,7 @@ class TransliteratorIDParser {
|
||||
// pass: a filter, a delimiter character (either '-' or '/'),
|
||||
// or a spec (source, target, or variant).
|
||||
for (;;) {
|
||||
Utility.skipWhitespace(id, pos);
|
||||
pos[0] = PatternProps.skipWhiteSpace(id, pos[0]);
|
||||
if (pos[0] == id.length()) {
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user