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
-
Method Summary
Modifier and TypeMethodDescriptionchar[]
long
Gets the number of characters represented by this Writable.boolean
Checks 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.void
Writes a streamed version of the object's String representation using the given encoder.void
Writes a streamed version of the object's String representation using the given encoder.void
Writes 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, writeTo
Methods 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:Writable
Gets the number of characters represented by this Writable. -
isFastToString
public boolean isFastToString()Description copied from interface:Writable
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 prefertoString
overwriteTo
orappendTo
whenisFastToString
returns true.Note: As of Java 1.7.0_06,
String.substring(int, int)
and related operations now copy underlying buffers.- Specified by:
isFastToString
in 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:
writeTo
in interfaceWritable
- Throws:
IOException
-
writeTo
Description copied from interface:Writable
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.- Specified by:
writeTo
in 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:Writable
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.- Specified by:
writeTo
in 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:Writable
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
Writable.isFastToString()
and then trim the result ofWritable.toString()
. However, for non-fast-toString writables, this trim will be more efficient.- Specified by:
trim
in interfaceWritable
- Throws:
IOException
-