Javolution 6.0.0 java
javolution.io.AppendableWriter Class Reference
Inheritance diagram for javolution.io.AppendableWriter:
[legend]
Collaboration diagram for javolution.io.AppendableWriter:
[legend]

Public Member Functions

 AppendableWriter ()
 
AppendableWriter setOutput (Appendable output)
 
void write (char c) throws IOException
 
void write (int c) throws IOException
 
void write (char cbuf[], int off, int len) throws IOException
 
void write (String str, int off, int len) throws IOException
 
void write (CharSequence csq) throws IOException
 
void flush ()
 
void close ()
 
void reset ()
 

Private Attributes

Appendable _output
 
char[] _tmpBuffer
 
final CharSequence _tmpBufferAsCharSequence
 

Detailed Description

This class allows any Appendable to be used as a writer.

Author
Jean-Marie Dautelle
Version
3.8, May 8, 2006

Definition at line 22 of file AppendableWriter.java.

Constructor & Destructor Documentation

◆ AppendableWriter()

javolution.io.AppendableWriter.AppendableWriter ( )

Creates a new appendable writer for which the appendable output is not set.

See also
setOutput(Appendable)

Definition at line 35 of file AppendableWriter.java.

35 {}

Member Function Documentation

◆ close()

void javolution.io.AppendableWriter.close ( )

Closes and resets this writer for reuse.

Definition at line 153 of file AppendableWriter.java.

153  {
154  if (_output != null) {
155  reset();
156  }
157  }

References javolution.io.AppendableWriter._output, and javolution.io.AppendableWriter.reset().

Here is the call graph for this function:

◆ flush()

void javolution.io.AppendableWriter.flush ( )

Flushes the stream.

Definition at line 146 of file AppendableWriter.java.

146  {
147  // Do nothing (no buffer).
148  }

◆ reset()

void javolution.io.AppendableWriter.reset ( )

Definition at line 159 of file AppendableWriter.java.

159  {
160  _output = null;
161  _tmpBuffer = null;
162  }

References javolution.io.AppendableWriter._output, and javolution.io.AppendableWriter._tmpBuffer.

Referenced by javolution.io.AppendableWriter.close(), and javolution.xml.ws.WebServiceClient.invoke().

Here is the caller graph for this function:

◆ setOutput()

AppendableWriter javolution.io.AppendableWriter.setOutput ( Appendable  output)

Sets the appendable output being written to. For example:[code] Writer writer = new AppendableWriter().setOutput(new TextBuilder()); [/code]

Parameters
outputthe appendable written to.
Returns
this writer.
Exceptions
IllegalStateExceptionif this writer is being reused and it has not been closed or reset.

Definition at line 48 of file AppendableWriter.java.

48  {
49  if (_output != null)
50  throw new IllegalStateException("Writer not closed or reset");
51  _output = output;
52  return this;
53  }

References javolution.io.AppendableWriter._output.

Referenced by javolution.xml.ws.WebServiceClient.invoke().

Here is the caller graph for this function:

◆ write() [1/5]

void javolution.io.AppendableWriter.write ( char  c) throws IOException

Writes a single character.

Parameters
cchar the character to be written.
Exceptions
IOExceptionif an I/O error occurs.

Definition at line 61 of file AppendableWriter.java.

61  {
62  if (_output == null)
63  throw new IOException("Writer closed");
64  _output.append(c);
65  }

References javolution.io.AppendableWriter._output.

◆ write() [2/5]

void javolution.io.AppendableWriter.write ( char  cbuf[],
int  off,
int  len 
) throws IOException

Writes a portion of an array of characters.

Parameters
cbufthe array of characters.
offthe offset from which to start writing characters.
lenthe number of characters to write.
Exceptions
IOExceptionif an I/O error occurs.

Definition at line 88 of file AppendableWriter.java.

88  {
89  if (_output == null)
90  throw new IOException("Writer closed");
91  _tmpBuffer = cbuf;
92  _output.append(_tmpBufferAsCharSequence, off, off + len);
93  _tmpBuffer = null; // Removes temporary references.
94  }

References javolution.io.AppendableWriter._output, javolution.io.AppendableWriter._tmpBuffer, and javolution.io.AppendableWriter._tmpBufferAsCharSequence.

◆ write() [3/5]

void javolution.io.AppendableWriter.write ( CharSequence  csq) throws IOException

Writes the specified character sequence.

Parameters
csqthe character sequence.
Exceptions
IOExceptionif an I/O error occurs

Definition at line 137 of file AppendableWriter.java.

137  {
138  if (_output == null)
139  throw new IOException("Writer closed");
140  _output.append(csq);
141  }

References javolution.io.AppendableWriter._output.

◆ write() [4/5]

void javolution.io.AppendableWriter.write ( int  c) throws IOException

Writes the 16 low-order bits of the given integer value; the 16 high-order bits are ignored.

Parameters
cthe value of the character to be written.
Exceptions
IOExceptionif an I/O error occurs.

Definition at line 74 of file AppendableWriter.java.

74  {
75  if (_output == null)
76  throw new IOException("Writer closed");
77  _output.append((char) c);
78  }

References javolution.io.AppendableWriter._output.

◆ write() [5/5]

void javolution.io.AppendableWriter.write ( String  str,
int  off,
int  len 
) throws IOException

Writes a portion of a string.

Parameters
stra String.
offthe offset from which to start writing characters.
lenthe number of characters to write.
Exceptions
IOExceptionif an I/O error occurs

Definition at line 120 of file AppendableWriter.java.

120  {
121  if (_output == null)
122  throw new IOException("Writer closed");
123  Object obj = str;
124  if (obj instanceof CharSequence) {
125  _output.append((CharSequence) obj);
126  } else {
127  _output.append(Text.valueOf(str));
128  }
129  }

References javolution.io.AppendableWriter._output, and javolution.text.Text.valueOf().

Here is the call graph for this function:

Member Data Documentation

◆ _output

Appendable javolution.io.AppendableWriter._output
private

◆ _tmpBuffer

char [] javolution.io.AppendableWriter._tmpBuffer
private

◆ _tmpBufferAsCharSequence

final CharSequence javolution.io.AppendableWriter._tmpBufferAsCharSequence
private
Initial value:
= new CharSequence() {
public int length() {
return _tmpBuffer.length;
}
public char charAt(int index) {
return _tmpBuffer[index];
}
public CharSequence subSequence(int start, int end) {
throw new UnsupportedOperationException();
}
}

Definition at line 98 of file AppendableWriter.java.

Referenced by javolution.io.AppendableWriter.write().


The documentation for this class was generated from the following file:
javolution.io.AppendableWriter._output
Appendable _output
Definition: AppendableWriter.java:27
javolution.io.AppendableWriter.reset
void reset()
Definition: AppendableWriter.java:159
javolution.io.AppendableWriter._tmpBufferAsCharSequence
final CharSequence _tmpBufferAsCharSequence
Definition: AppendableWriter.java:98
javolution.io.AppendableWriter._tmpBuffer
char[] _tmpBuffer
Definition: AppendableWriter.java:96