@SuppressWarnings("unchecked") public StdEscapeHTMLSerializerProvider(SerializationConfig serializationConfig) throws JsonMappingException { super(serializationConfig, new StdSerializerProvider(), BeanSerializerFactory.instance); JsonSerializer stringEscapeHTMLSerializer = new StringEscapeHTMLSerializer(); _serializerCache.addAndResolveNonTypedSerializer(String.class, stringEscapeHTMLSerializer, this); JavaType javaType = TypeFactory.fromCanonical(String.class.getName()); _serializerCache.addAndResolveNonTypedSerializer(javaType, stringEscapeHTMLSerializer, this); }
/** * * @param jf JsonFactory to use: if null, a new {@link MappingJsonFactory} will be constructed * @param sp SerializerProvider to use: if null, a {@link StdSerializerProvider} will be constructed * @param dp DeserializerProvider to use: if null, a {@link StdDeserializerProvider} will be constructed * @param sconfig Serialization configuration to use; if null, basic {@link SerializationConfig} * will be constructed * @param dconfig Deserialization configuration to use; if null, basic {@link DeserializationConfig} * will be constructed */ public ObjectMapper(JsonFactory jf, SerializerProvider sp, DeserializerProvider dp, SerializationConfig sconfig, DeserializationConfig dconfig) { /* 02-Mar-2009, tatu: Important: we MUST default to using * the mapping factory, otherwise tree serialization will * have problems with POJONodes. * 03-Jan-2010, tatu: and obviously we also must pass 'this', * to create actual linking. */ _jsonFactory = (jf == null) ? new MappingJsonFactory(this) : jf; // visibility checker; usually default _visibilityChecker = STD_VISIBILITY_CHECKER; _serializationConfig = (sconfig != null) ? sconfig : new SerializationConfig(DEFAULT_INTROSPECTOR, DEFAULT_ANNOTATION_INTROSPECTOR, _visibilityChecker); _deserializationConfig = (dconfig != null) ? dconfig : new DeserializationConfig(DEFAULT_INTROSPECTOR, DEFAULT_ANNOTATION_INTROSPECTOR, _visibilityChecker); _serializerProvider = (sp == null) ? new StdSerializerProvider() : sp; _deserializerProvider = (dp == null) ? new StdDeserializerProvider() : dp; // Default serializer factory is stateless, can just assign _serializerFactory = BeanSerializerFactory.instance; // and use standard JsonNodeFactory initially _nodeFactory = JsonNodeFactory.instance; }
/** * 重写createInstance函数 * * @param config * @param jsf * @return */ @Override protected StdSerializerProvider createInstance(SerializationConfig config, SerializerFactory jsf) { return new StdEscapeHTMLSerializerProvider(config, this, jsf); }