equal
deleted
inserted
replaced
662 * |
662 * |
663 * @return the length of the sequence of characters represented by this |
663 * @return the length of the sequence of characters represented by this |
664 * object. |
664 * object. |
665 */ |
665 */ |
666 public int length() { |
666 public int length() { |
667 return value.length >> coder(); |
667 return isLatin1() ? value.length : value.length >> UTF16; |
668 } |
668 } |
669 |
669 |
670 /** |
670 /** |
671 * Returns {@code true} if, and only if, {@link #length()} is {@code 0}. |
671 * Returns {@code true} if, and only if, {@link #length()} is {@code 0}. |
672 * |
672 * |
1941 * of this {@code String}. |
1941 * of this {@code String}. |
1942 * @return a string that represents the concatenation of this object's |
1942 * @return a string that represents the concatenation of this object's |
1943 * characters followed by the string argument's characters. |
1943 * characters followed by the string argument's characters. |
1944 */ |
1944 */ |
1945 public String concat(String str) { |
1945 public String concat(String str) { |
1946 int olen = str.length(); |
1946 if (str.isEmpty()) { |
1947 if (olen == 0) { |
|
1948 return this; |
1947 return this; |
1949 } |
1948 } |
1950 if (coder() == str.coder()) { |
1949 if (coder() == str.coder()) { |
1951 byte[] val = this.value; |
1950 byte[] val = this.value; |
1952 byte[] oval = str.value; |
1951 byte[] oval = str.value; |
1954 byte[] buf = Arrays.copyOf(val, len); |
1953 byte[] buf = Arrays.copyOf(val, len); |
1955 System.arraycopy(oval, 0, buf, val.length, oval.length); |
1954 System.arraycopy(oval, 0, buf, val.length, oval.length); |
1956 return new String(buf, coder); |
1955 return new String(buf, coder); |
1957 } |
1956 } |
1958 int len = length(); |
1957 int len = length(); |
|
1958 int olen = str.length(); |
1959 byte[] buf = StringUTF16.newBytesFor(len + olen); |
1959 byte[] buf = StringUTF16.newBytesFor(len + olen); |
1960 getBytes(buf, 0, UTF16); |
1960 getBytes(buf, 0, UTF16); |
1961 str.getBytes(buf, len, UTF16); |
1961 str.getBytes(buf, len, UTF16); |
1962 return new String(buf, UTF16); |
1962 return new String(buf, UTF16); |
1963 } |
1963 } |
2314 list.add(substring(off, length())); |
2314 list.add(substring(off, length())); |
2315 |
2315 |
2316 // Construct result |
2316 // Construct result |
2317 int resultSize = list.size(); |
2317 int resultSize = list.size(); |
2318 if (limit == 0) { |
2318 if (limit == 0) { |
2319 while (resultSize > 0 && list.get(resultSize - 1).length() == 0) { |
2319 while (resultSize > 0 && list.get(resultSize - 1).isEmpty()) { |
2320 resultSize--; |
2320 resultSize--; |
2321 } |
2321 } |
2322 } |
2322 } |
2323 String[] result = new String[resultSize]; |
2323 String[] result = new String[resultSize]; |
2324 return list.subList(0, resultSize).toArray(result); |
2324 return list.subList(0, resultSize).toArray(result); |