Package org.apache.pivot.serialization
Class PropertiesSerializer
- java.lang.Object
-
- org.apache.pivot.serialization.PropertiesSerializer
-
- All Implemented Interfaces:
Serializer<Map<?,?>>
public class PropertiesSerializer extends java.lang.Object implements Serializer<Map<?,?>>
Implementation of theSerializer
interface that reads data from and writes data to the Java properties file format.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
MIME_TYPE
static java.lang.String
PROPERTIES_EXTENSION
-
Constructor Summary
Constructors Constructor Description PropertiesSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getMIMEType(Map<?,?> object)
Returns the MIME type of the data read and written by this serializer.Map<?,?>
readObject(java.io.InputStream inputStream)
Reads data from a properties stream.void
writeObject(Map<?,?> object, java.io.OutputStream outputStream)
Writes data to a properties stream.
-
-
-
Field Detail
-
PROPERTIES_EXTENSION
public static final java.lang.String PROPERTIES_EXTENSION
- See Also:
- Constant Field Values
-
MIME_TYPE
public static final java.lang.String MIME_TYPE
- See Also:
- Constant Field Values
-
-
Method Detail
-
readObject
public Map<?,?> readObject(java.io.InputStream inputStream) throws java.io.IOException, SerializationException
Reads data from a properties stream.- Specified by:
readObject
in interfaceSerializer<Map<?,?>>
- Parameters:
inputStream
- The input stream from which data will be read.- Returns:
- An instance of
Map
containing the data read from the properties file. Both keys and values are strings. - Throws:
java.io.IOException
- for any errors accessing or reading the object.SerializationException
- for any formatting errors encountered while deserializing the object.
-
writeObject
public void writeObject(Map<?,?> object, java.io.OutputStream outputStream) throws java.io.IOException, SerializationException
Writes data to a properties stream.- Specified by:
writeObject
in interfaceSerializer<Map<?,?>>
- Parameters:
object
- An instance ofMap
containing the data to be written to the properties file. Keys must be strings, and values will be converted to strings.outputStream
- The output stream to which data will be written.- Throws:
java.io.IOException
- for any errors accessing or reading the object.SerializationException
- for any formatting errors encountered while deserializing the object.
-
getMIMEType
public java.lang.String getMIMEType(Map<?,?> object)
Description copied from interface:Serializer
Returns the MIME type of the data read and written by this serializer.- Specified by:
getMIMEType
in interfaceSerializer<Map<?,?>>
- Parameters:
object
- 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.
-
-