75 * Create a scanner from the input array. This method might |
75 * Create a scanner from the input array. This method might |
76 * modify the array. To avoid copying the input array, ensure |
76 * modify the array. To avoid copying the input array, ensure |
77 * that {@code inputLength < input.length} or |
77 * that {@code inputLength < input.length} or |
78 * {@code input[input.length -1]} is a white space character. |
78 * {@code input[input.length -1]} is a white space character. |
79 * |
79 * |
80 * @param fac the factory which created this Scanner |
80 * @param sf the factory which created this Scanner |
81 * @param input the input, might be modified |
81 * @param buffer the input, might be modified |
82 * @param inputLength the size of the input. |
|
83 * Must be positive and less than or equal to input.length. |
82 * Must be positive and less than or equal to input.length. |
84 */ |
83 */ |
85 protected UnicodeReader(ScannerFactory sf, CharBuffer buffer) { |
84 protected UnicodeReader(ScannerFactory sf, CharBuffer buffer) { |
86 this(sf, JavacFileManager.toArray(buffer), buffer.limit()); |
85 this(sf, JavacFileManager.toArray(buffer), buffer.limit()); |
87 } |
86 } |
253 return chars; |
252 return chars; |
254 } |
253 } |
255 |
254 |
256 /** |
255 /** |
257 * Returns a copy of a character array subset of the input buffer. |
256 * Returns a copy of a character array subset of the input buffer. |
258 * The returned array begins at the <code>beginIndex</code> and |
257 * The returned array begins at the {@code beginIndex} and |
259 * extends to the character at index <code>endIndex - 1</code>. |
258 * extends to the character at index {@code endIndex - 1}. |
260 * Thus the length of the substring is <code>endIndex-beginIndex</code>. |
259 * Thus the length of the substring is {@code endIndex-beginIndex}. |
261 * This behavior is like |
260 * This behavior is like |
262 * <code>String.substring(beginIndex, endIndex)</code>. |
261 * {@code String.substring(beginIndex, endIndex)}. |
263 * Unicode escape sequences are not translated. |
262 * Unicode escape sequences are not translated. |
264 * |
263 * |
265 * @param beginIndex the beginning index, inclusive. |
264 * @param beginIndex the beginning index, inclusive. |
266 * @param endIndex the ending index, exclusive. |
265 * @param endIndex the ending index, exclusive. |
267 * @throws IndexOutOfBounds if either offset is outside of the |
266 * @throws ArrayIndexOutOfBoundsException if either offset is outside of the |
268 * array bounds |
267 * array bounds |
269 */ |
268 */ |
270 public char[] getRawCharacters(int beginIndex, int endIndex) { |
269 public char[] getRawCharacters(int beginIndex, int endIndex) { |
271 int length = endIndex - beginIndex; |
270 int length = endIndex - beginIndex; |
272 char[] chars = new char[length]; |
271 char[] chars = new char[length]; |