Class CourseDescriptionDeserializer
java.lang.Object
com.fasterxml.jackson.databind.JsonDeserializer<String>
dev.jcputney.elearning.parser.input.aicc.CourseDescriptionDeserializer
- All Implemented Interfaces:
com.fasterxml.jackson.databind.deser.NullValueProvider
public class CourseDescriptionDeserializer
extends com.fasterxml.jackson.databind.JsonDeserializer<String>
Custom deserializer for AICC course descriptions that provides backward compatibility with legacy
JSON data.
In earlier versions (pre-867d2d1), course descriptions were stored as Map<String,
String> to handle multi-line descriptions from AICC .crs files. Current versions use
String directly since the parser extracts raw text via
AiccParser.extractCourseDescription(dev.jcputney.elearning.parser.util.EncodingDetector.EncodingAwareInputStream, java.lang.String).
This deserializer handles both formats:
- Current format (String): Returns the string value directly
- Legacy format (Map/Object): Reconstructs multi-line text by joining map entries, treating empty values as plain text lines and non-empty values as "key: value" pairs
- See Also:
-
AiccCourse.courseDescription
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.JsonDeserializer
com.fasterxml.jackson.databind.JsonDeserializer.None -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondeserialize(com.fasterxml.jackson.core.JsonParser parser, com.fasterxml.jackson.databind.DeserializationContext context) Deserializes a JSON value into a course description string.Methods inherited from class com.fasterxml.jackson.databind.JsonDeserializer
deserialize, deserializeWithType, deserializeWithType, findBackReference, getAbsentValue, getDelegatee, getEmptyAccessPattern, getEmptyValue, getEmptyValue, getKnownPropertyNames, getNullAccessPattern, getNullValue, getNullValue, getObjectIdReader, handledType, isCachable, logicalType, replaceDelegatee, supportsUpdate, unwrappingDeserializer
-
Constructor Details
-
CourseDescriptionDeserializer
public CourseDescriptionDeserializer()Default constructor for the deserializer.
-
-
Method Details
-
deserialize
public String deserialize(com.fasterxml.jackson.core.JsonParser parser, com.fasterxml.jackson.databind.DeserializationContext context) throws IOException Deserializes a JSON value into a course description string.Supports two formats:
- String:
"Course_Description": "Simple text"→ returns the string - Object/Map:
"Course_Description": {"line1": "", "line2": "value"}→ reconstructs as "line1\nline2: value"
- Specified by:
deserializein classcom.fasterxml.jackson.databind.JsonDeserializer<String>- Parameters:
parser- the JsonParser to read the value fromcontext- context for the deserialization process- Returns:
- the course description as a String, or null if the field is null
- Throws:
IOException- if the value cannot be parsed
- String:
-