Package org.apache.pivot.wtk.text
Class PlainTextSerializer
- java.lang.Object
-
- org.apache.pivot.wtk.text.PlainTextSerializer
-
- All Implemented Interfaces:
Serializer<Document>
public class PlainTextSerializer extends java.lang.Object implements Serializer<Document>
Implementation of theSerializerinterface that reads and writes a plain text document.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringMIME_TYPE
-
Constructor Summary
Constructors Constructor Description PlainTextSerializer()PlainTextSerializer(java.lang.String charsetName)PlainTextSerializer(java.nio.charset.Charset charset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetBufferSize()booleangetExpandTabs()java.lang.StringgetMIMEType(Document document)Returns the MIME type of the data read and written by this serializer.intgetTabWidth()DocumentreadObject(java.io.InputStream inputStream)Reads an object from an input stream.DocumentreadObject(java.io.Reader reader)voidsetBufferSize(int bufferSize)Sets the buffer size used internally for reading and writing.voidsetExpandTabs(boolean expandTabs)Sets whether tab characters (\t) are expanded to an appropriate number of spaces while reading the text.voidsetTabWidth(int tabWidth)voidwriteObject(Document document, java.io.OutputStream outputStream)Writes an object to an output stream.voidwriteObject(Document document, java.io.Writer writer)
-
-
-
Field Detail
-
MIME_TYPE
public static final java.lang.String MIME_TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getTabWidth
public int getTabWidth()
-
setTabWidth
public void setTabWidth(int tabWidth)
-
getExpandTabs
public boolean getExpandTabs()
-
setExpandTabs
public void setExpandTabs(boolean expandTabs)
Sets whether tab characters (\t) are expanded to an appropriate number of spaces while reading the text.- Parameters:
expandTabs-trueto replace tab characters with space characters (depending on the setting of thegetTabWidth()value) orfalseto leave tabs alone.
-
getBufferSize
public int getBufferSize()
-
setBufferSize
public void setBufferSize(int bufferSize)
Sets the buffer size used internally for reading and writing. The default value isConstants.BUFFER_SIZE. A value of0will use the default value in theBufferedReaderandBufferedWriterclasses (probably 8192).- Parameters:
bufferSize- The new buffer size to use (or 0 to use the system default).
-
readObject
public Document readObject(java.io.InputStream inputStream) throws java.io.IOException
Description copied from interface:SerializerReads an object from an input stream.- Specified by:
readObjectin interfaceSerializer<Document>- Parameters:
inputStream- The data stream from which the object will be read.- Returns:
- The deserialized object.
- Throws:
java.io.IOException- for any errors accessing or reading the object.
-
readObject
public Document readObject(java.io.Reader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
writeObject
public void writeObject(Document document, java.io.OutputStream outputStream) throws java.io.IOException
Description copied from interface:SerializerWrites an object to an output stream.- Specified by:
writeObjectin interfaceSerializer<Document>- Parameters:
document- The object to serialize.outputStream- The data stream to which the object will be written.- Throws:
java.io.IOException- for any errors accessing or reading the object.
-
writeObject
public void writeObject(Document document, java.io.Writer writer) throws java.io.IOException
- Throws:
java.io.IOException
-
getMIMEType
public java.lang.String getMIMEType(Document document)
Description copied from interface:SerializerReturns the MIME type of the data read and written by this serializer.- Specified by:
getMIMETypein interfaceSerializer<Document>- Parameters:
document- If provided, allows the serializer to attach parameters to the returned MIME type containing more detailed information about the data. Ifnull, the base MIME type is returned.- Returns:
- The MIME type of the current data.
-
-