Class CPythonSerializer
Adds rudimentary handling of unexpected null values before we try to serialize the data (i.e. thus avoiding an NPE). The main source of an unexpected null would be the input data, e.g. we read an integer attribute from the shapefile, but the value stored is null.
Note that this does not perfectly avoid every possible NPE when serializing. It just aims to be 'good enough' to avoid falling over when the exposure-layer shapefile contains null values. Thus, we don't guarantee null-safe handling of nullable structs for example (yes, a hazard vector layer could still have null values, but users are more likely to define a type, or pick a single attribute, for the hazard-layer).
-
Field Summary
Modifier and TypeFieldDescriptionType name mappings used for python type info serialization - this just cleans them up a little in error messages, BUT it makes them inconsistent with their names in java error messages... -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic nz.org.riskscape.engine.types.Type
nullSafeType
(nz.org.riskscape.engine.types.Type type) Returns an equivalent type that will handle unexpected null values in the underlying input data.void
serialize
(DataOutputStream output, nz.org.riskscape.engine.types.Type type, Object value) Serializes the given type/value to the given output stream with additional null-safety checks.static String
serializerType
(nz.org.riskscape.engine.types.Type type) Turn the type into a string form that the serializer.py script can parse.
-
Field Details
-
TYPE_ALIASES
Type name mappings used for python type info serialization - this just cleans them up a little in error messages, BUT it makes them inconsistent with their names in java error messages... sooo... FIXME get this to be a riskscape type expression, or at least equivalent-ish?
-
-
Constructor Details
-
CPythonSerializer
public CPythonSerializer()
-
-
Method Details
-
serializerType
Turn the type into a string form that the serializer.py script can parse.
-
serialize
public void serialize(DataOutputStream output, nz.org.riskscape.engine.types.Type type, Object value) throws IOException Serializes the given type/value to the given output stream with additional null-safety checks.
- Throws:
IOException
-
nullSafeType
public static nz.org.riskscape.engine.types.Type nullSafeType(nz.org.riskscape.engine.types.Type type) Returns an equivalent type that will handle unexpected null values in the underlying input data.
- Returns:
- either the same type, or a new equivalent type that is null-safe
-