947 |
* @param offset the beginning offset from where to write |
* @param offset the beginning offset from where to write |
948 |
* @param len the length of the fragment to write |
* @param len the length of the fragment to write |
949 |
* |
* |
950 |
* @throws BadLocationException if <code>offset</code> or |
* @throws BadLocationException if <code>offset</code> is an |
951 |
* <code>offset + len</code>is an invalid location inside |
* invalid location inside <code>document</code>. |
|
* <code>document</code> |
|
952 |
* @throws IOException if something goes wrong while writing to |
* @throws IOException if something goes wrong while writing to |
953 |
* <code>out</code> |
* <code>out</code> |
954 |
*/ |
*/ |
955 |
public void write(Writer out, Document document, int offset, int len) |
public void write(Writer out, Document document, int offset, int len) |
956 |
throws BadLocationException, IOException |
throws BadLocationException, IOException |
957 |
{ |
{ |
958 |
// TODO: Implement this properly. |
// Throw a BLE if offset is invalid |
959 |
|
if (offset < 0 || offset > document.getLength()) |
960 |
|
throw new BadLocationException("Tried to write to invalid location", |
961 |
|
offset); |
962 |
|
|
963 |
|
// If they gave an overly large len, just adjust it |
964 |
|
if (offset + len > document.getLength()) |
965 |
|
len = document.getLength() - offset; |
966 |
|
|
967 |
|
out.write(document.getText(offset, len)); |
968 |
} |
} |
969 |
} |
} |