-
- All Known Implementing Classes:
AoCharArrayWriter
public interface WritableSomething that may be written to a Writer output instead of being converted toString and then having the String written.- Author:
- AO Industries, Inc.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidappendTo(Encoder encoder, Appendable out)Appends a streamed version of the object's String representation using the given encoder.default voidappendTo(Encoder encoder, Appendable out, long start, long end)Appends a streamed version of the object's String representation using the given encoder.default voidappendTo(Appendable out)Appends a streamed version of the object's String representation.default voidappendTo(Appendable out, long start, long end)Appends a streamed version of the object's String representation.longgetLength()Gets the number of characters represented by this Writable.booleanisFastToString()Checks if the writable will be able to be converted toString in an extremely efficient manner.StringtoString()Anything writable must have atoStringconsistent with what would be written by thewriteToandappendTomethods.Writabletrim()Trims the contents of this writable, as per rules ofStrings.isWhitespace(int), returning the instance that represents this writable trimmed.voidwriteTo(Encoder encoder, Writer out)Writes a streamed version of the object's String representation using the given encoder.voidwriteTo(Encoder encoder, Writer out, long off, long len)Writes a streamed version of the object's String representation using the given encoder.voidwriteTo(Writer out)Writes a streamed version of the object's String representation.voidwriteTo(Writer out, long off, long len)Writes a streamed version of the object's String representation.
-
-
-
Method Detail
-
getLength
long getLength() throws IOExceptionGets the number of characters represented by this Writable.- Throws:
IOException
-
isFastToString
boolean isFastToString()
Checks if the writable will be able to be converted toString in an extremely efficient manner. This means without allocating any new buffer space or string copies. Callers should prefertoStringoverwriteToorappendTowhenisFastToStringreturns true.Note: As of Java 1.7.0_06,
String.substring(int, int)and related operations now copy underlying buffers.
-
toString
String toString()
Anything writable must have atoStringconsistent with what would be written by thewriteToandappendTomethods. For larger amounts of data, it is likely much more efficient to call the most appropriatewriteToorappendTomethod.
-
writeTo
void writeTo(Writer out) throws IOException
Writes a streamed version of the object's String representation. What is written must be the same as ifout.write(this.toString())were called, but may be a much more efficient implementation.- Throws:
IOException
-
writeTo
void writeTo(Writer out, long off, long len) throws IOException
Writes a streamed version of the object's String representation. What is written must be the same as ifout.write(this.toString(), off, len)were called, but may be a much more efficient implementation.- Throws:
IOException
-
writeTo
void writeTo(Encoder encoder, Writer out) throws IOException
Writes a streamed version of the object's String representation using the given encoder. What is written must be the same as ifencoder.write(this.toString(), out)were called, but may be a much more efficient implementation.- Parameters:
encoder- ifnull, no encoding is performed and will be the same as a call towriteTo(java.io.Writer)- Throws:
IOException
-
writeTo
void writeTo(Encoder encoder, Writer out, long off, long len) throws IOException
Writes a streamed version of the object's String representation using the given encoder. What is written must be the same as ifencoder.write(this.toString(), off, len, out)were called, but may be a much more efficient implementation.- Parameters:
encoder- if null, no encoding is performed and will be the same as a call towriteTo(java.io.Writer, long, long)- Throws:
IOException
-
appendTo
default void appendTo(Appendable out) throws IOException
Appends a streamed version of the object's String representation. What is appended must be the same as ifout.append(this.toString())were called, but may be a much more efficient implementation.- Throws:
IOException
-
appendTo
default void appendTo(Appendable out, long start, long end) throws IOException
Appends a streamed version of the object's String representation. What is appended must be the same as ifout.append(this.toString(), start, end)were called, but may be a much more efficient implementation.- Throws:
IOException
-
appendTo
default void appendTo(Encoder encoder, Appendable out) throws IOException
Appends a streamed version of the object's String representation using the given encoder. What is appended must be the same as ifencoder.append(this.toString(), out)were called, but may be a much more efficient implementation.- Parameters:
encoder- ifnull, no encoding is performed and will be the same as a call toappendTo(java.lang.Appendable)- Throws:
IOException
-
appendTo
default void appendTo(Encoder encoder, Appendable out, long start, long end) throws IOException
Appends a streamed version of the object's String representation using the given encoder. What is appended must be the same as ifencoder.append(this.toString(), start, end, out)were called, but may be a much more efficient implementation.- Parameters:
encoder- if null, no encoding is performed and will be the same as a call toappendTo(java.lang.Appendable, long, long)- Throws:
IOException
-
trim
Writable trim() throws IOException
Trims the contents of this writable, as per rules ofStrings.isWhitespace(int), returning the instance that represents this writable trimmed.It will most likely be faster to check
isFastToString()and then trim the result oftoString(). However, for non-fast-toString writables, this trim will be more efficient.- Throws:
IOException
-
-