X-Git-Url: http://git.megacz.com/?p=org.ibex.tool.git;a=blobdiff_plain;f=src%2Forg%2Feclipse%2Fjdt%2Fcore%2Fcompiler%2FCharOperation.java;fp=src%2Forg%2Feclipse%2Fjdt%2Fcore%2Fcompiler%2FCharOperation.java;h=b21cdf4d7986c7a0950206b8efec4445260c6984;hp=07d23e3b877bd2d81745a1b1a93eb2e2a7d56dcc;hb=c17753cd9e62cd1a71df3d88af908de0425ac33d;hpb=040fa5af2cd00017cf3575950cdaade34a6d7f6c
diff --git a/src/org/eclipse/jdt/core/compiler/CharOperation.java b/src/org/eclipse/jdt/core/compiler/CharOperation.java
index 07d23e3..b21cdf4 100644
--- a/src/org/eclipse/jdt/core/compiler/CharOperation.java
+++ b/src/org/eclipse/jdt/core/compiler/CharOperation.java
@@ -28,6 +28,12 @@ public final class CharOperation {
public static final char[][] NO_CHAR_CHAR = new char[0][];
/**
+ * Constant for an empty String array.
+ * @since 3.1
+ */
+ public static final String[] NO_STRINGS = new String[0];
+
+ /**
* Answers a new array with appending the suffix character at the end of the array.
*
*
@@ -171,13 +177,14 @@ public final class CharOperation {
* @since 3.0
*/
public static String[] charArrayToStringArray(char[][] charArrays) {
- if (charArrays == null) {
+ if (charArrays == null)
return null;
- }
- String[] strings= new String[charArrays.length];
- for (int i= 0; i < charArrays.length; i++) {
+ int length = charArrays.length;
+ if (length == 0)
+ return NO_STRINGS;
+ String[] strings= new String[length];
+ for (int i= 0; i < length; i++)
strings[i]= new String(charArrays[i]);
- }
return strings;
}
/**
@@ -490,7 +497,7 @@ public final class CharOperation {
/**
* Answers the concatenation of the three arrays inserting the sep1 character between the
- * two arrays and sep2 between the last two.
+ * first two arrays and sep2 between the last two.
* It answers null if the three arrays are null.
* If the first array is null, then it answers the concatenation of second and third inserting
* the sep2 character between them.
@@ -867,6 +874,40 @@ public final class CharOperation {
return true;
return false;
}
+
+ /**
+ * Answers true if the array contains an occurrence of one of the characters, false otherwise.
+ *
+ *
+ *
+ * For example:
+ *
+ * characters = { 'c', 'd' } + * array = { 'a', ' b' } + * result => false + *+ *
+ * characters = { 'c', 'd' } + * array = { 'a', ' b', 'c' } + * result => true + *+ *
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' } + * toBeReplaced = 'b' + * replacementChar = 'a' + * result => A new array that is equals to { 'a' , 'a', 'a', 'a', 'a', 'a' } + *+ *
+ * array = { 'a' , 'b', 'b', 'a', 'b', 'a' } + * toBeReplaced = 'c' + * replacementChar = 'a' + * result => The original array that remains unchanged. + *+ *