mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-09 11:34:55 +00:00
Reapplying more of Oliver's checkstyle fixes from r1083211
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1089733 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3b180e56c3
commit
5a7b17cf3e
@ -634,7 +634,8 @@ public static String stripAccents(String input) {
|
|||||||
} else if (sunAvailable) {
|
} else if (sunAvailable) {
|
||||||
result = removeAccentsSUN(input);
|
result = removeAccentsSUN(input);
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("The stripAccents(CharSequence) method requires at least Java 1.6 or a Sun JVM");
|
throw new UnsupportedOperationException("The stripAccents(CharSequence) method requires at least "
|
||||||
|
+ "Java 1.6 or a Sun JVM");
|
||||||
}
|
}
|
||||||
// Note that none of the above methods correctly remove ligatures...
|
// Note that none of the above methods correctly remove ligatures...
|
||||||
return result;
|
return result;
|
||||||
@ -652,9 +653,15 @@ public static String stripAccents(String input) {
|
|||||||
/**
|
/**
|
||||||
* Use {@code java.text.Normalizer#normalize(CharSequence, Normalizer.Form)}
|
* Use {@code java.text.Normalizer#normalize(CharSequence, Normalizer.Form)}
|
||||||
* (but be careful, this classe exists in Java 1.3, with an entirely different meaning!)
|
* (but be careful, this classe exists in Java 1.3, with an entirely different meaning!)
|
||||||
* @param text
|
*
|
||||||
|
* @param text the text to be processed
|
||||||
|
* @return the processed string
|
||||||
|
* @throws IllegalAccessException may be thrown by a reflection call
|
||||||
|
* @throws InvocationTargetException if a reflection call throws an exception
|
||||||
|
* @throws IllegalStateException if the {@code Normalizer} class is not available
|
||||||
*/
|
*/
|
||||||
private static String removeAccentsJava6(CharSequence text) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
private static String removeAccentsJava6(CharSequence text)
|
||||||
|
throws IllegalAccessException, InvocationTargetException {
|
||||||
/*
|
/*
|
||||||
String decomposed = java.text.Normalizer.normalize(CharSequence, Normalizer.Form.NFD);
|
String decomposed = java.text.Normalizer.normalize(CharSequence, Normalizer.Form.NFD);
|
||||||
return java6Pattern.matcher(decomposed).replaceAll("");//$NON-NLS-1$
|
return java6Pattern.matcher(decomposed).replaceAll("");//$NON-NLS-1$
|
||||||
@ -670,8 +677,15 @@ private static String removeAccentsJava6(CharSequence text) throws IllegalArgume
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Use {@code sun.text.Normalizer#decompose(String, boolean, int)}
|
* Use {@code sun.text.Normalizer#decompose(String, boolean, int)}
|
||||||
|
*
|
||||||
|
* @param text the text to be processed
|
||||||
|
* @return the processed string
|
||||||
|
* @throws IllegalAccessException may be thrown by a reflection call
|
||||||
|
* @throws InvocationTargetException if a reflection call throws an exception
|
||||||
|
* @throws IllegalStateException if the {@code Normalizer} class is not available
|
||||||
*/
|
*/
|
||||||
private static String removeAccentsSUN(CharSequence text) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
private static String removeAccentsSUN(CharSequence text)
|
||||||
|
throws IllegalAccessException, InvocationTargetException {
|
||||||
/*
|
/*
|
||||||
String decomposed = sun.text.Normalizer.decompose(text, false, 0);
|
String decomposed = sun.text.Normalizer.decompose(text, false, 0);
|
||||||
return sunPattern.matcher(decomposed).replaceAll("");//$NON-NLS-1$
|
return sunPattern.matcher(decomposed).replaceAll("");//$NON-NLS-1$
|
||||||
@ -699,10 +713,13 @@ private static String removeAccentsSUN(CharSequence text) throws IllegalArgument
|
|||||||
try {
|
try {
|
||||||
// java.text.Normalizer.normalize(CharSequence, Normalizer.Form.NFD);
|
// java.text.Normalizer.normalize(CharSequence, Normalizer.Form.NFD);
|
||||||
// Be careful not to get Java 1.3 java.text.Normalizer!
|
// Be careful not to get Java 1.3 java.text.Normalizer!
|
||||||
Class<?> normalizerFormClass = Thread.currentThread().getContextClassLoader().loadClass("java.text.Normalizer$Form");//$NON-NLS-1$
|
Class<?> normalizerFormClass = Thread.currentThread().getContextClassLoader()
|
||||||
|
.loadClass("java.text.Normalizer$Form");//$NON-NLS-1$
|
||||||
java6NormalizerFormNFD = normalizerFormClass.getField("NFD").get(null);//$NON-NLS-1$
|
java6NormalizerFormNFD = normalizerFormClass.getField("NFD").get(null);//$NON-NLS-1$
|
||||||
Class<?> normalizerClass = Thread.currentThread().getContextClassLoader().loadClass("java.text.Normalizer");//$NON-NLS-1$
|
Class<?> normalizerClass = Thread.currentThread().getContextClassLoader()
|
||||||
java6NormalizeMethod = normalizerClass.getMethod("normalize", new Class[] {CharSequence.class, normalizerFormClass});//$NON-NLS-1$
|
.loadClass("java.text.Normalizer");//$NON-NLS-1$
|
||||||
|
java6NormalizeMethod = normalizerClass.getMethod("normalize",
|
||||||
|
new Class[] {CharSequence.class, normalizerFormClass});//$NON-NLS-1$
|
||||||
java6Available = true;
|
java6Available = true;
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
java6Available = false;
|
java6Available = false;
|
||||||
@ -716,8 +733,10 @@ private static String removeAccentsSUN(CharSequence text) throws IllegalArgument
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// sun.text.Normalizer.decompose(text, false, 0);
|
// sun.text.Normalizer.decompose(text, false, 0);
|
||||||
Class<?> normalizerClass = Thread.currentThread().getContextClassLoader().loadClass("sun.text.Normalizer");//$NON-NLS-1$
|
Class<?> normalizerClass = Thread.currentThread().getContextClassLoader()
|
||||||
sunDecomposeMethod = normalizerClass.getMethod("decompose", new Class[] {String.class, Boolean.TYPE, Integer.TYPE});//$NON-NLS-1$
|
.loadClass("sun.text.Normalizer");//$NON-NLS-1$
|
||||||
|
sunDecomposeMethod = normalizerClass.getMethod("decompose",
|
||||||
|
new Class[] {String.class, Boolean.TYPE, Integer.TYPE});//$NON-NLS-1$
|
||||||
sunAvailable = true;
|
sunAvailable = true;
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
sunAvailable = false;
|
sunAvailable = false;
|
||||||
@ -5824,7 +5843,8 @@ public static String difference(String str1, String str2) {
|
|||||||
* @param cs2 the second CharSequence, may be null
|
* @param cs2 the second CharSequence, may be null
|
||||||
* @return the index where cs1 and cs2 begin to differ; -1 if they are equal
|
* @return the index where cs1 and cs2 begin to differ; -1 if they are equal
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @since 3.0 Changed signature from indexOfDifference(String, String) to indexOfDifference(CharSequence, CharSequence)
|
* @since 3.0 Changed signature from indexOfDifference(String, String) to
|
||||||
|
* indexOfDifference(CharSequence, CharSequence)
|
||||||
*/
|
*/
|
||||||
public static int indexOfDifference(CharSequence cs1, CharSequence cs2) {
|
public static int indexOfDifference(CharSequence cs1, CharSequence cs2) {
|
||||||
if (cs1 == cs2) {
|
if (cs1 == cs2) {
|
||||||
@ -6023,7 +6043,8 @@ public static String getCommonPrefix(String... strs) {
|
|||||||
* @param t the second String, must not be null
|
* @param t the second String, must not be null
|
||||||
* @return result distance
|
* @return result distance
|
||||||
* @throws IllegalArgumentException if either String input {@code null}
|
* @throws IllegalArgumentException if either String input {@code null}
|
||||||
* @since 3.0 Changed signature from getLevenshteinDistance(String, String) to getLevenshteinDistance(CharSequence, CharSequence)
|
* @since 3.0 Changed signature from getLevenshteinDistance(String, String) to
|
||||||
|
* getLevenshteinDistance(CharSequence, CharSequence)
|
||||||
*/
|
*/
|
||||||
public static int getLevenshteinDistance(CharSequence s, CharSequence t) {
|
public static int getLevenshteinDistance(CharSequence s, CharSequence t) {
|
||||||
if (s == null || t == null) {
|
if (s == null || t == null) {
|
||||||
@ -6367,7 +6388,7 @@ public static boolean endsWithAny(CharSequence string, CharSequence... searchStr
|
|||||||
/**
|
/**
|
||||||
* <p>Returns a new {@code CharSequence} that is a subsequence of this
|
* <p>Returns a new {@code CharSequence} that is a subsequence of this
|
||||||
* sequence starting with the {@code char} value at the specified index.</p>
|
* sequence starting with the {@code char} value at the specified index.</p>
|
||||||
*
|
*
|
||||||
* <p>This provides the {@code CharSequence} equivalent to {@link String#substring(int)}.
|
* <p>This provides the {@code CharSequence} equivalent to {@link String#substring(int)}.
|
||||||
* The length (in {@code char}) of the returned sequence is {@code length() - start},
|
* The length (in {@code char}) of the returned sequence is {@code length() - start},
|
||||||
* so if {@code start == end} then an empty sequence is returned.</p>
|
* so if {@code start == end} then an empty sequence is returned.</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user