Package com.alibaba.fastjson.serializer
Class SerializeWriter
- java.lang.Object
-
- java.io.Writer
-
- com.alibaba.fastjson.serializer.SerializeWriter
-
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
public final class SerializeWriter extends Writer
- Author:
- wenshao[szujobs@hotmail.com]
-
-
Constructor Summary
Constructors Constructor Description SerializeWriter()SerializeWriter(int initialSize)SerializeWriter(SerializerFeature... features)SerializeWriter(Writer writer)SerializeWriter(Writer writer, int initialSize)SerializeWriter(Writer writer, int defaultFeatures, SerializerFeature... features)SerializeWriter(Writer writer, SerializerFeature... features)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SerializeWriterappend(char c)SerializeWriterappend(CharSequence csq)SerializeWriterappend(CharSequence csq, int start, int end)voidclose()Close the stream.voidconfig(SerializerFeature feature, boolean state)voidexpandCapacity(int minimumCapacity)voidflush()intgetBufferLength()intgetMaxBufSize()booleanisEnabled(int feature)booleanisEnabled(SerializerFeature feature)booleanisNotWriteDefaultValue()booleanisSortField()voidreset()Deprecated.voidsetMaxBufSize(int maxBufSize)intsize()byte[]toBytes(String charsetName)byte[]toBytes(Charset charset)char[]toCharArray()Returns a copy of the input data.char[]toCharArrayForSpringWebSocket()only for springwebsocketStringtoString()voidwrite(boolean value)voidwrite(char[] c, int off, int len)Writes characters to the buffer.voidwrite(int c)Writes a character to the buffer.voidwrite(String text)voidwrite(String str, int off, int len)Write a portion of a string to the buffer.voidwrite(List<String> list)voidwriteByteArray(byte[] bytes)voidwriteDouble(double value, boolean checkWriteClassName)voidwriteEnum(Enum<?> value)voidwriteFieldName(String key)voidwriteFieldName(String key, boolean checkSpecial)voidwriteFieldNameDirect(String text)voidwriteFieldValue(char seperator, String name, boolean value)voidwriteFieldValue(char seperator, String name, char value)voidwriteFieldValue(char seperator, String name, double value)voidwriteFieldValue(char seperator, String name, float value)voidwriteFieldValue(char seperator, String name, int value)voidwriteFieldValue(char seperator, String name, long value)voidwriteFieldValue(char seperator, String name, Enum<?> value)voidwriteFieldValue(char seperator, String name, String value)voidwriteFieldValue(char seperator, String name, BigDecimal value)voidwriteFieldValueStringWithDoubleQuote(char seperator, String name, String value)voidwriteFieldValueStringWithDoubleQuoteCheck(char seperator, String name, String value)voidwriteFloat(float value, boolean checkWriteClassName)voidwriteHex(byte[] bytes)voidwriteInt(int i)voidwriteLong(long i)voidwriteLongAndChar(long i, char c)Deprecated.voidwriteNull()voidwriteNull(int beanFeatures, int feature)voidwriteNull(SerializerFeature feature)voidwriteString(char[] chars)voidwriteString(String text)voidwriteString(String text, char seperator)voidwriteStringWithDoubleQuote(char[] text, char seperator)voidwriteStringWithDoubleQuote(String text, char seperator)voidwriteTo(OutputStream out, String charsetName)voidwriteTo(OutputStream out, Charset charset)voidwriteTo(Writer out)Writes the contents of the buffer to another character stream.intwriteToEx(OutputStream out, Charset charset)-
Methods inherited from class java.io.Writer
nullWriter, write
-
-
-
-
Constructor Detail
-
SerializeWriter
public SerializeWriter()
-
SerializeWriter
public SerializeWriter(Writer writer)
-
SerializeWriter
public SerializeWriter(SerializerFeature... features)
-
SerializeWriter
public SerializeWriter(Writer writer, SerializerFeature... features)
-
SerializeWriter
public SerializeWriter(Writer writer, int defaultFeatures, SerializerFeature... features)
- Parameters:
writer-defaultFeatures-features-- Since:
- 1.2.9
-
SerializeWriter
public SerializeWriter(int initialSize)
-
SerializeWriter
public SerializeWriter(Writer writer, int initialSize)
-
-
Method Detail
-
getMaxBufSize
public int getMaxBufSize()
-
setMaxBufSize
public void setMaxBufSize(int maxBufSize)
-
getBufferLength
public int getBufferLength()
-
config
public void config(SerializerFeature feature, boolean state)
-
isSortField
public boolean isSortField()
-
isNotWriteDefaultValue
public boolean isNotWriteDefaultValue()
-
isEnabled
public boolean isEnabled(SerializerFeature feature)
-
isEnabled
public boolean isEnabled(int feature)
-
write
public void write(char[] c, int off, int len)Writes characters to the buffer.
-
expandCapacity
public void expandCapacity(int minimumCapacity)
-
append
public SerializeWriter append(CharSequence csq)
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
public SerializeWriter append(CharSequence csq, int start, int end)
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
public SerializeWriter append(char c)
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
write
public void write(String str, int off, int len)
Write a portion of a string to the buffer.
-
writeTo
public void writeTo(Writer out) throws IOException
Writes the contents of the buffer to another character stream.- Parameters:
out- the output stream to write to- Throws:
IOException- If an I/O error occurs.
-
writeTo
public void writeTo(OutputStream out, String charsetName) throws IOException
- Throws:
IOException
-
writeTo
public void writeTo(OutputStream out, Charset charset) throws IOException
- Throws:
IOException
-
writeToEx
public int writeToEx(OutputStream out, Charset charset) throws IOException
- Throws:
IOException
-
toCharArray
public char[] toCharArray()
Returns a copy of the input data.- Returns:
- an array of chars copied from the input data.
-
toCharArrayForSpringWebSocket
public char[] toCharArrayForSpringWebSocket()
only for springwebsocket- Returns:
-
toBytes
public byte[] toBytes(String charsetName)
-
toBytes
public byte[] toBytes(Charset charset)
-
size
public int size()
-
close
public void close()
Close the stream. This method does not release the buffer, since its contents might still be required. Note: Invoking this method in this class will have no effect.
-
writeInt
public void writeInt(int i)
-
writeByteArray
public void writeByteArray(byte[] bytes)
-
writeHex
public void writeHex(byte[] bytes)
-
writeFloat
public void writeFloat(float value, boolean checkWriteClassName)
-
writeDouble
public void writeDouble(double value, boolean checkWriteClassName)
-
writeEnum
public void writeEnum(Enum<?> value)
-
writeLongAndChar
public void writeLongAndChar(long i, char c) throws IOExceptionDeprecated.- Throws:
IOException
-
writeLong
public void writeLong(long i)
-
writeNull
public void writeNull()
-
writeNull
public void writeNull(SerializerFeature feature)
-
writeNull
public void writeNull(int beanFeatures, int feature)
-
writeStringWithDoubleQuote
public void writeStringWithDoubleQuote(String text, char seperator)
-
writeStringWithDoubleQuote
public void writeStringWithDoubleQuote(char[] text, char seperator)
-
writeFieldNameDirect
public void writeFieldNameDirect(String text)
-
writeFieldValue
public void writeFieldValue(char seperator, String name, char value)
-
writeFieldValue
public void writeFieldValue(char seperator, String name, boolean value)
-
write
public void write(boolean value)
-
writeFieldValue
public void writeFieldValue(char seperator, String name, int value)
-
writeFieldValue
public void writeFieldValue(char seperator, String name, long value)
-
writeFieldValue
public void writeFieldValue(char seperator, String name, float value)
-
writeFieldValue
public void writeFieldValue(char seperator, String name, double value)
-
writeFieldValueStringWithDoubleQuoteCheck
public void writeFieldValueStringWithDoubleQuoteCheck(char seperator, String name, String value)
-
writeFieldValueStringWithDoubleQuote
public void writeFieldValueStringWithDoubleQuote(char seperator, String name, String value)
-
writeFieldValue
public void writeFieldValue(char seperator, String name, BigDecimal value)
-
writeString
public void writeString(String text, char seperator)
-
writeString
public void writeString(String text)
-
writeString
public void writeString(char[] chars)
-
writeFieldName
public void writeFieldName(String key)
-
writeFieldName
public void writeFieldName(String key, boolean checkSpecial)
-
flush
public void flush()
-
reset
public void reset()
Deprecated.
-
-