Package org.apache.sis.io
Class AppendableWriter
java.lang.Object
java.io.Writer
org.apache.sis.io.AppendableWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
Wraps a
Appendable as a Writer.- Since:
- 0.3
- Version:
- 0.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AppendableThe underlying character output stream or buffer. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new filtered formatter which will send its output to the given stream or buffer. -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) Forwards the given single character toout.append(CharSequence sequence) Forwards the given character sequence toout.append(CharSequence sequence, int start, int end) Forwards the given character sub-sequence toout.voidclose()voidflush()private static ObjectgetLock(Appendable out) Returns the synchronization lock to use for writing to the givenAppendable.toString()Returns the content of the underlyingAppendableas a string if possible, or the localized "Unavailable content" string otherwise.voidwrite(char[] cbuf, int offset, int length) Forwards the given character array toout.voidwrite(int c) Forwards the given single character toout.voidForwards the given string toout.voidForwards the given sub-string toout.
-
Field Details
-
out
The underlying character output stream or buffer.
-
-
Constructor Details
-
AppendableWriter
AppendableWriter(Appendable out) Creates a new filtered formatter which will send its output to the given stream or buffer.- Parameters:
out- the underlying character output stream or buffer.
-
-
Method Details
-
getLock
Returns the synchronization lock to use for writing to the givenAppendable. In particular if the final destination is aStringBuffer, we want to lock on that buffer since it is already synchronized on itself (so we get only one lock, not two). If the final destination is another writer, we would use itsWriter.lockfield if it wasn't protected... As a fallback we use the writer itself, since writers are often synchronized on themselves. -
append
Forwards the given single character toout.- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
IOException
-
write
Forwards the given single character toout.- Overrides:
writein classWriter- Throws:
IOException
-
append
Forwards the given character sequence toout.- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
IOException
-
write
Forwards the given string toout.- Overrides:
writein classWriter- Throws:
IOException
-
append
Forwards the given character sub-sequence toout.- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter- Throws:
IOException
-
write
Forwards the given sub-string toout.- Overrides:
writein classWriter- Throws:
IOException
-
write
Forwards the given character array toout.- Specified by:
writein classWriter- Throws:
IOException
-
flush
IfoutimplementsFlushable, or is aAppenderwrapper around a flushable object, delegates to that object. Otherwise do nothing.- Specified by:
flushin interfaceFlushable- Specified by:
flushin classWriter- Throws:
IOException
-
close
IfoutimplementsCloseable, or is aAppenderwrapper around a closeable object, delegates to that object. Otherwise just flush (if possible).- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException
-
toString
Returns the content of the underlyingAppendableas a string if possible, or the localized "Unavailable content" string otherwise.
-