< prev index next >
src/java.desktop/share/classes/javax/swing/text/AbstractWriter.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 184,203 ****
canWrapLines = true;
}
/**
* Returns the first offset to be output.
! *
* @since 1.3
*/
public int getStartOffset() {
return startOffset;
}
/**
* Returns the last offset to be output.
! *
* @since 1.3
*/
public int getEndOffset() {
return endOffset;
}
--- 184,203 ----
canWrapLines = true;
}
/**
* Returns the first offset to be output.
! * @return the first offset to be output
* @since 1.3
*/
public int getStartOffset() {
return startOffset;
}
/**
* Returns the last offset to be output.
! * @return the last offset to be output
* @since 1.3
*/
public int getEndOffset() {
return endOffset;
}
*** 211,221 ****
return it;
}
/**
* Returns the Writer that is used to output the content.
! *
* @since 1.3
*/
protected Writer getWriter() {
return out;
}
--- 211,221 ----
return it;
}
/**
* Returns the Writer that is used to output the content.
! * @return the Writer that is used to output the content
* @since 1.3
*/
protected Writer getWriter() {
return out;
}
*** 255,264 ****
--- 255,267 ----
/**
* This abstract method needs to be implemented
* by subclasses. Its responsibility is to
* iterate over the elements and use the write()
* methods to generate output in the desired format.
+ * @throws IOException if an I/O problem has occurred
+ * @throws BadLocationException for an invalid location within
+ * the document
*/
abstract protected void write() throws IOException, BadLocationException;
/**
* Returns the text associated with the element.
*** 312,373 ****
maxLineLength = l;
}
/**
* Returns the maximum line length.
! *
* @since 1.3
*/
protected int getLineLength() {
return maxLineLength;
}
/**
* Sets the current line length.
! *
* @since 1.3
*/
protected void setCurrentLineLength(int length) {
currLength = length;
isLineEmpty = (currLength == 0);
}
/**
* Returns the current line length.
! *
* @since 1.3
*/
protected int getCurrentLineLength() {
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.
! *
* @since 1.3
*/
protected boolean isLineEmpty() {
return isLineEmpty;
}
/**
* Sets whether or not lines can be wrapped. This can be toggled
* during the writing of lines. For example, outputting HTML might
* set this to false when outputting a quoted string.
! *
* @since 1.3
*/
protected void setCanWrapLines(boolean newValue) {
canWrapLines = newValue;
}
/**
* Returns whether or not the lines can be wrapped. If this is false
* no lineSeparator's will be output.
! *
* @since 1.3
*/
protected boolean getCanWrapLines() {
return canWrapLines;
}
--- 315,376 ----
maxLineLength = l;
}
/**
* Returns the maximum line length.
! * @return the maximum line length
* @since 1.3
*/
protected int getLineLength() {
return maxLineLength;
}
/**
* Sets the current line length.
! * @param length the new line length
* @since 1.3
*/
protected void setCurrentLineLength(int length) {
currLength = length;
isLineEmpty = (currLength == 0);
}
/**
* Returns the current line length.
! * @return the current line length
* @since 1.3
*/
protected int getCurrentLineLength() {
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;
}
/**
* Sets whether or not lines can be wrapped. This can be toggled
* during the writing of lines. For example, outputting HTML might
* set this to false when outputting a quoted string.
! * @param newValue new value for line wrapping
* @since 1.3
*/
protected void setCanWrapLines(boolean newValue) {
canWrapLines = newValue;
}
/**
* Returns whether or not the lines can be wrapped. If this is false
* no lineSeparator's will be output.
! * @return whether or not the lines can be wrapped
* @since 1.3
*/
protected boolean getCanWrapLines() {
return canWrapLines;
}
*** 383,413 ****
indentSpace = space;
}
/**
* Returns the amount of space to indent.
! *
* @since 1.3
*/
protected int getIndentSpace() {
return indentSpace;
}
/**
* Sets the String used to represent newlines. This is initialized
* in the constructor from either the Document, or the System property
* line.separator.
! *
* @since 1.3
*/
public void setLineSeparator(String value) {
lineSeparator = value;
}
/**
* Returns the string used to represent newlines.
! *
* @since 1.3
*/
public String getLineSeparator() {
return lineSeparator;
}
--- 386,416 ----
indentSpace = space;
}
/**
* Returns the amount of space to indent.
! * @return the amount of space to indent
* @since 1.3
*/
protected int getIndentSpace() {
return indentSpace;
}
/**
* Sets the String used to represent newlines. This is initialized
* in the constructor from either the Document, or the System property
* line.separator.
! * @param value the new line separator
* @since 1.3
*/
public void setLineSeparator(String value) {
lineSeparator = value;
}
/**
* Returns the string used to represent newlines.
! * @return the string used to represent newlines
* @since 1.3
*/
public String getLineSeparator() {
return lineSeparator;
}
*** 444,454 ****
/**
* 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.
! *
* @since 1.3
*/
protected int getIndentLevel() {
return indentLevel;
}
--- 447,457 ----
/**
* 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;
}
*** 512,522 ****
}
/**
* Writes the line separator. This invokes <code>output</code> directly
* as well as setting the <code>lineLength</code> to 0.
! *
* @since 1.3
*/
protected void writeLineSeparator() throws IOException {
String newline = getLineSeparator();
int length = newline.length();
--- 515,525 ----
}
/**
* 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();
int length = newline.length();
*** 537,546 ****
--- 540,553 ----
* 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
* @since 1.3
*/
protected void write(char[] chars, int startIndex, int length)
throws IOException {
if (!getCanWrapLines()) {
*** 684,693 ****
--- 691,704 ----
* 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
+ * @throws IOException on any I/O error
* @since 1.3
*/
protected void output(char[] content, int start, int length)
throws IOException {
getWriter().write(content, start, length);
< prev index next >