Package com.alibaba.fastjson2.writer
Class ObjectWriterAdapter<T>
java.lang.Object
com.alibaba.fastjson2.writer.ObjectWriterAdapter<T>
- All Implemented Interfaces:
ObjectWriter<T>
- Direct Known Subclasses:
ObjectWriter1,ObjectWriter10,ObjectWriter11,ObjectWriter12,ObjectWriter2,ObjectWriter3,ObjectWriter4,ObjectWriter5,ObjectWriter6,ObjectWriter7,ObjectWriter8,ObjectWriter9,ObjectWriterException,ObjectWriterRootName
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final FieldWriter[]protected final Stringprotected final longprotected final byte[]protected long -
Constructor Summary
ConstructorsConstructorDescriptionObjectWriterAdapter(Class<T> objectClass, String typeKey, String typeName, long features, List<FieldWriter> fieldWriters) ObjectWriterAdapter(Class<T> objectClass, List<FieldWriter> fieldWriters) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidlongGets the features enabled by this ObjectWriter.getFieldWriter(long hashCode) Gets the FieldWriter for the specified field hash code.Gets the list of FieldWriters associated with this ObjectWriter.final booleanhasFilter(JSONWriter jsonWriter) Checks if the JSONWriter has any filters enabled that would affect serialization.protected final booleanhasFilter0(JSONWriter jsonWriter) voidsetNameFilter(NameFilter nameFilter) Sets the name filter for this ObjectWriter.voidsetPropertyFilter(PropertyFilter propertyFilter) Sets the property filter for this ObjectWriter.voidsetPropertyPreFilter(PropertyPreFilter propertyPreFilter) Sets the property pre-filter for this ObjectWriter.voidsetValueFilter(ValueFilter valueFilter) Sets the value filter for this ObjectWriter.toJSONObject(T object) toJSONObject(T object, long features) toString()voidwrite(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) Writes an object to the JSONWriter with the given field name, field type, and features.voidwriteArrayMappingJSONB(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) Writes an object to the JSONWriter in array mapping JSONB format with additional parameters.protected final voidwriteClassInfo(JSONWriter jsonWriter) voidwriteJSONB(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) Writes an object to the JSONWriter in JSONB format.booleanwriteTypeInfo(JSONWriter jsonWriter) Writes type information to the JSON output.voidwriteWithFilter(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) Writes an object to the JSONWriter with filter support.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.alibaba.fastjson2.writer.ObjectWriter
getFieldValue, getFieldWriter, setFilter, toJSONString, write, writeArrayMapping, writeArrayMappingJSONB, writeWithFilter
-
Field Details
-
fieldWriterArray
-
typeName
-
typeNameHash
protected final long typeNameHash -
typeNameSymbolCache
protected long typeNameSymbolCache -
typeNameJSONB
protected final byte[] typeNameJSONB
-
-
Constructor Details
-
ObjectWriterAdapter
-
ObjectWriterAdapter
-
-
Method Details
-
getFeatures
public long getFeatures()Description copied from interface:ObjectWriterGets the features enabled by this ObjectWriter.- Specified by:
getFeaturesin interfaceObjectWriter<T>- Returns:
- the enabled features as a bit mask
-
getFieldWriter
Description copied from interface:ObjectWriterGets the FieldWriter for the specified field hash code.- Specified by:
getFieldWriterin interfaceObjectWriter<T>- Parameters:
hashCode- the hash code of the field name- Returns:
- the FieldWriter for the field, or null if not found
-
hasFilter
Description copied from interface:ObjectWriterChecks if the JSONWriter has any filters enabled that would affect serialization.- Specified by:
hasFilterin interfaceObjectWriter<T>- Parameters:
jsonWriter- the JSONWriter to check- Returns:
- true if filters are enabled, false otherwise
-
hasFilter0
-
setPropertyFilter
Description copied from interface:ObjectWriterSets the property filter for this ObjectWriter.- Specified by:
setPropertyFilterin interfaceObjectWriter<T>- Parameters:
propertyFilter- the property filter to set
-
setValueFilter
Description copied from interface:ObjectWriterSets the value filter for this ObjectWriter.- Specified by:
setValueFilterin interfaceObjectWriter<T>- Parameters:
valueFilter- the value filter to set
-
setNameFilter
Description copied from interface:ObjectWriterSets the name filter for this ObjectWriter.- Specified by:
setNameFilterin interfaceObjectWriter<T>- Parameters:
nameFilter- the name filter to set
-
setPropertyPreFilter
Description copied from interface:ObjectWriterSets the property pre-filter for this ObjectWriter.- Specified by:
setPropertyPreFilterin interfaceObjectWriter<T>- Parameters:
propertyPreFilter- the property pre-filter to set
-
writeArrayMappingJSONB
public void writeArrayMappingJSONB(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) Description copied from interface:ObjectWriterWrites an object to the JSONWriter in array mapping JSONB format with additional parameters.- Specified by:
writeArrayMappingJSONBin interfaceObjectWriter<T>- Parameters:
jsonWriter- the JSONWriter to which the object should be writtenobject- the object to writefieldName- the name of the field being writtenfieldType- the type of the field being writtenfeatures- the features to use for writing
-
writeJSONB
public void writeJSONB(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) Description copied from interface:ObjectWriterWrites an object to the JSONWriter in JSONB format.- Specified by:
writeJSONBin interfaceObjectWriter<T>- Parameters:
jsonWriter- the JSONWriter to which the object should be writtenobject- the object to writefieldName- the name of the field being writtenfieldType- the type of the field being writtenfeatures- the features to use for writing
-
writeClassInfo
-
write
public void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) Description copied from interface:ObjectWriterWrites an object to the JSONWriter with the given field name, field type, and features.- Specified by:
writein interfaceObjectWriter<T>- Parameters:
jsonWriter- the JSONWriter to which the object should be writtenobject- the object to writefieldName- the name of the field being writtenfieldType- the type of the field being writtenfeatures- the features to use for writing
-
toMap
-
getFieldWriters
Description copied from interface:ObjectWriterGets the list of FieldWriters associated with this ObjectWriter.- Specified by:
getFieldWritersin interfaceObjectWriter<T>- Returns:
- the list of FieldWriters, or an empty list if none are available
-
writeTypeInfo
Description copied from interface:ObjectWriterWrites type information to the JSON output. This is used for polymorphic serialization to include type information in the JSON output.- Specified by:
writeTypeInfoin interfaceObjectWriter<T>- Parameters:
jsonWriter- the JSONWriter to which type information should be written- Returns:
- true if type information was written, false otherwise
-
writeWithFilter
public void writeWithFilter(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) Description copied from interface:ObjectWriterWrites an object to the JSONWriter with filter support.- Specified by:
writeWithFilterin interfaceObjectWriter<T>- Parameters:
jsonWriter- the JSONWriter to which the object should be writtenobject- the object to writefieldName- the name of the field being writtenfieldType- the type of the field being writtenfeatures- the features to use for writing
-
toJSONObject
-
toJSONObject
-
toString
-
errorOnNoneSerializable
protected void errorOnNoneSerializable()
-