Package org.rapidcontext.core.data
Class PropertiesSerializer
java.lang.Object
org.rapidcontext.core.data.PropertiesSerializer
A data serializer for the Java properties file format. The mapping
to the properties format is not exact, and may omit serialization
of data in some cases. The following basic requirements must be
met in order to serialize an object:
- No circular references are permitted.
- String, Integer, Boolean, Date, Array and Dict values are supported.
- Other value types are converted to strings.
- Property key names should consist of printable ISO-8859-1 characters, without spaces or dots.
- Property key names should not be numeric, as that will convert to an array index.
- Array null values will be omitted, renumbering the remaining indices.
- Version:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Serializes an object into a properties representation.static void
serialize
(Object obj, OutputStream os) Serializes an object into a properties representation.static Object
Unserializes an object from a properties representation, typically a properties file.static void
Serializes an object into a properties file.
-
Method Details
-
serialize
Serializes an object into a properties representation.- Parameters:
obj
- the object to serialize, or nullos
- the output stream to write to- Throws:
IOException
- if the data couldn't be serialized
-
serialize
Serializes an object into a properties representation.- Parameters:
obj
- the object to serialize, or null- Returns:
- a properties file representation
- Throws:
IOException
- if the data couldn't be serialized
-
unserialize
Unserializes an object from a properties representation, typically a properties file. The property names are preserved as dictionary keys, except for structural interpretation. Dot ('.') characters in names are interpreted as sub-object separators, and numbers are interpreted as an array indices. Values are stored as booleans, integers or strings.- Parameters:
is
- the input stream to load- Returns:
- the object read
- Throws:
IOException
- if an error occurred while reading
-
write
Serializes an object into a properties file.- Parameters:
file
- the file to writeobj
- the object value, or null- Throws:
IOException
- if the data couldn't be serialized
-