Class NeqSimXtream
java.lang.Object
neqsim.util.serialization.NeqSimXtream
NeqSimXtream class for serializing and deserializing NeqSim objects.
Provides compressed XML serialization using XStream with ZIP compression. The resulting .neqsim files are compact and portable.
Features:
- Automatic ThreadLocal field exclusion
- ZIP compression for compact storage
- Full object graph preservation with ID references
- Graceful handling of unknown fields/classes for cross-version compatibility
- Version:
- 1.0
- Author:
- esol
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classMapper that skips ThreadLocal fields during serialization.private static classMapper that silently ignores unknown elements during deserialization. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.apache.logging.log4j.LoggerLogger for this class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static com.thoughtworks.xstream.XStreamCreates a configured XStream instance with sensible defaults for NeqSim serialization.static ObjectopenNeqsim(String filename) Opens and deserializes an object from a compressed .neqsim file.static booleansaveNeqsim(Object javaobject, String filename) Saves an object to a compressed .neqsim file.
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger loggerLogger for this class.
-
-
Constructor Details
-
NeqSimXtream
public NeqSimXtream()
-
-
Method Details
-
openNeqsim
Opens and deserializes an object from a compressed .neqsim file.- Parameters:
filename- the path to the .neqsim file- Returns:
- the deserialized object
- Throws:
IOException- if the file cannot be read or is not a valid .neqsim fileFileNotFoundException- if the file does not exist or process.xml is not found in ZIP
-
saveNeqsim
Saves an object to a compressed .neqsim file.The object is serialized to XML using XStream and compressed using ZIP compression.
- Parameters:
javaobject- the object to serialize (typically ProcessSystem or ProcessModel)filename- the path to save to (recommended extension: .neqsim)- Returns:
- true if save was successful, false otherwise
-
createConfiguredXStream
private static com.thoughtworks.xstream.XStream createConfiguredXStream()Creates a configured XStream instance with sensible defaults for NeqSim serialization.Uses the default reflection provider (sun.misc.Unsafe when available) to avoid ExceptionInInitializerError that occurs with PureJavaReflectionProvider on JDK 11+. Includes mapper wrappers to skip ThreadLocal fields and gracefully ignore unknown elements for cross-version compatibility.
- Returns:
- a configured XStream instance
-