< prev index next >
src/java.desktop/share/classes/javax/swing/text/AbstractWriter.java
Print this page
*** 85,97 ****
* Used when writing out a string.
*/
private char[] tempChars;
/**
! * This is used in <code>writeLineSeparator</code> instead of
* tempChars. If tempChars were used it would mean write couldn't invoke
! * <code>writeLineSeparator</code> as it might have been passed
* tempChars.
*/
private char[] newlineChars;
/**
--- 85,97 ----
* Used when writing out a string.
*/
private char[] tempChars;
/**
! * This is used in {@code writeLineSeparator} instead of
* tempChars. If tempChars were used it would mean write couldn't invoke
! * {@code writeLineSeparator} as it might have been passed
* tempChars.
*/
private char[] newlineChars;
/**
*** 267,280 ****
* Returns the text associated with the element.
* The assumption here is that the element is a
* leaf element. Throws a BadLocationException
* when encountered.
*
! * @param elem an <code>Element</code>
* @exception BadLocationException if pos represents an invalid
* location within the document
! * @return the text as a <code>String</code>
*/
protected String getText(Element elem) throws BadLocationException {
return doc.getText(elem.getStartOffset(),
elem.getEndOffset() - elem.getStartOffset());
}
--- 267,280 ----
* Returns the text associated with the element.
* The assumption here is that the element is a
* leaf element. Throws a BadLocationException
* when encountered.
*
! * @param elem an {@code Element}
* @exception BadLocationException if pos represents an invalid
* location within the document
! * @return the text as a {@code String}
*/
protected String getText(Element elem) throws BadLocationException {
return doc.getText(elem.getStartOffset(),
elem.getEndOffset() - elem.getStartOffset());
}
*** 343,354 ****
return currLength;
}
/**
* Returns true if the current line should be considered empty. This
! * is true when <code>getCurrentLineLength</code> == 0 ||
! * <code>indent</code> has been invoked on an empty line.
* @return true if the current line should be considered empty
* @since 1.3
*/
protected boolean isLineEmpty() {
return isLineEmpty;
--- 343,354 ----
return currLength;
}
/**
* Returns true if the current line should be considered empty. This
! * is true when {@code getCurrentLineLength} == 0 ||
! * {@code indent} has been invoked on an empty line.
* @return true if the current line should be considered empty
* @since 1.3
*/
protected boolean isLineEmpty() {
return isLineEmpty;
*** 415,426 ****
return lineSeparator;
}
/**
* Increments the indent level. If indenting would cause
! * <code>getIndentSpace()</code> *<code>getIndentLevel()</code> to be >
! * than <code>getLineLength()</code> this will not cause an indent.
*/
protected void incrIndent() {
// Only increment to a certain point.
if (offsetIndent > 0) {
offsetIndent++;
--- 415,426 ----
return lineSeparator;
}
/**
* Increments the indent level. If indenting would cause
! * {@code getIndentSpace()} *{@code getIndentLevel()} to be >
! * than {@code getLineLength()} this will not cause an indent.
*/
protected void incrIndent() {
// Only increment to a certain point.
if (offsetIndent > 0) {
offsetIndent++;
*** 445,456 ****
}
}
/**
* Returns the current indentation level. That is, the number of times
! * <code>incrIndent</code> has been invoked minus the number of times
! * <code>decrIndent</code> has been invoked.
* @return the current indentation level
* @since 1.3
*/
protected int getIndentLevel() {
return indentLevel;
--- 445,456 ----
}
}
/**
* Returns the current indentation level. That is, the number of times
! * {@code incrIndent} has been invoked minus the number of times
! * {@code decrIndent} has been invoked.
* @return the current indentation level
* @since 1.3
*/
protected int getIndentLevel() {
return indentLevel;
*** 480,490 ****
}
}
/**
* Writes out a character. This is implemented to invoke
! * the <code>write</code> method that takes a char[].
*
* @param ch a char.
* @exception IOException on any I/O error
*/
protected void write(char ch) throws IOException {
--- 480,490 ----
}
}
/**
* Writes out a character. This is implemented to invoke
! * the {@code write} method that takes a char[].
*
* @param ch a char.
* @exception IOException on any I/O error
*/
protected void write(char ch) throws IOException {
*** 495,505 ****
write(tempChars, 0, 1);
}
/**
* Writes out a string. This is implemented to invoke the
! * <code>write</code> method that takes a char[].
*
* @param content a String.
* @exception IOException on any I/O error
*/
protected void write(String content) throws IOException {
--- 495,505 ----
write(tempChars, 0, 1);
}
/**
* Writes out a string. This is implemented to invoke the
! * {@code write} method that takes a char[].
*
* @param content a String.
* @exception IOException on any I/O error
*/
protected void write(String content) throws IOException {
*** 513,524 ****
content.getChars(0, size, tempChars, 0);
write(tempChars, 0, size);
}
/**
! * Writes the line separator. This invokes <code>output</code> directly
! * as well as setting the <code>lineLength</code> to 0.
* @throws IOException on any I/O error
* @since 1.3
*/
protected void writeLineSeparator() throws IOException {
String newline = getLineSeparator();
--- 513,524 ----
content.getChars(0, size, tempChars, 0);
write(tempChars, 0, size);
}
/**
! * Writes the line separator. This invokes {@code output} directly
! * as well as setting the {@code lineLength} to 0.
* @throws IOException on any I/O error
* @since 1.3
*/
protected void writeLineSeparator() throws IOException {
String newline = getLineSeparator();
*** 530,548 ****
output(newlineChars, 0, length);
setCurrentLineLength(0);
}
/**
! * All write methods call into this one. If <code>getCanWrapLines()</code>
! * returns false, this will call <code>output</code> with each sequence
! * of <code>chars</code> that doesn't contain a NEWLINE, followed
! * by a call to <code>writeLineSeparator</code>. On the other hand,
! * if <code>getCanWrapLines()</code> returns true, this will split the
! * string, as necessary, so <code>getLineLength</code> is honored.
* The only exception is if the current string contains no whitespace,
* and won't fit in which case the line length will exceed
! * <code>getLineLength</code>.
*
* @param chars characters to output
* @param startIndex starting index
* @param length length of output
* @throws IOException on any I/O error
--- 530,548 ----
output(newlineChars, 0, length);
setCurrentLineLength(0);
}
/**
! * All write methods call into this one. If {@code getCanWrapLines()}
! * returns false, this will call {@code output} with each sequence
! * of {@code chars} that doesn't contain a NEWLINE, followed
! * by a call to {@code writeLineSeparator}. On the other hand,
! * if {@code getCanWrapLines()} returns true, this will split the
! * string, as necessary, so {@code getLineLength} is honored.
* The only exception is if the current string contains no whitespace,
* and won't fit in which case the line length will exceed
! * {@code getLineLength}.
*
* @param chars characters to output
* @param startIndex starting index
* @param length length of output
* @throws IOException on any I/O error
*** 682,698 ****
}
}
/**
* The last stop in writing out content. All the write methods eventually
! * make it to this method, which invokes <code>write</code> on the
* Writer.
* <p>This method also updates the line length based on
! * <code>length</code>. If this is invoked to output a newline, the
* current line length will need to be reset as will no longer be
* valid. If it is up to the caller to do this. Use
! * <code>writeLineSeparator</code> to write out a newline, which will
* property update the current line length.
*
* @param content characters to output
* @param start starting index
* @param length length of output
--- 682,698 ----
}
}
/**
* The last stop in writing out content. All the write methods eventually
! * make it to this method, which invokes {@code write} on the
* Writer.
* <p>This method also updates the line length based on
! * {@code length}. If this is invoked to output a newline, the
* current line length will need to be reset as will no longer be
* valid. If it is up to the caller to do this. Use
! * {@code writeLineSeparator} to write out a newline, which will
* property update the current line length.
*
* @param content characters to output
* @param start starting index
* @param length length of output
< prev index next >