java.lang.Object
java.io.Writer
java.io.CharArrayWriter
com.aoapps.lang.io.AoCharArrayWriter
- All Implemented Interfaces:
Writable,Closeable,Flushable,Appendable,AutoCloseable
Provides direct access to the internal
char[].- Author:
- AO Industries, Inc.
-
Field Summary
Fields inherited from class java.io.CharArrayWriter
buf, count -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchar[]longGets the number of characters represented by this Writable.booleanChecks if the writable will be able to be converted toString in an extremely efficient manner.toString(int off, int len) Converts a portion of the input data to a string.trim()Trims the contents of this writable, as per rules ofStrings.isWhitespace(int), returning the instance that represents this writable trimmed.voidWrites a streamed version of the object's String representation using the given encoder.voidWrites a streamed version of the object's String representation using the given encoder.voidWrites a portion of the contents of the buffer to another character stream.Methods inherited from class java.io.CharArrayWriter
append, append, append, close, flush, reset, size, toCharArray, toString, write, write, write, writeToMethods inherited from class java.io.Writer
nullWriter, write, write
-
Constructor Details
-
AoCharArrayWriter
public AoCharArrayWriter() -
AoCharArrayWriter
public AoCharArrayWriter(int initialSize)
-
-
Method Details
-
getInternalCharArray
public char[] getInternalCharArray() -
getLength
public long getLength()Description copied from interface:WritableGets the number of characters represented by this Writable. -
isFastToString
public boolean isFastToString()Description copied from interface:WritableChecks 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.- Specified by:
isFastToStringin interfaceWritable
-
toString
Converts a portion of the input data to a string.- Returns:
- the string.
-
writeTo
Writes a portion of the contents of the buffer to another character stream.- Specified by:
writeToin interfaceWritable- Throws:
IOException
-
writeTo
Description copied from interface:WritableWrites 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.- Specified by:
writeToin interfaceWritable- Parameters:
encoder- ifnull, no encoding is performed and will be the same as a call toWritable.writeTo(java.io.Writer)- Throws:
IOException
-
writeTo
Description copied from interface:WritableWrites 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.- Specified by:
writeToin interfaceWritable- Parameters:
encoder- if null, no encoding is performed and will be the same as a call toWritable.writeTo(java.io.Writer, long, long)- Throws:
IOException
-
trim
Description copied from interface:WritableTrims 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
Writable.isFastToString()and then trim the result ofWritable.toString(). However, for non-fast-toString writables, this trim will be more efficient.- Specified by:
trimin interfaceWritable- Throws:
IOException
-
